diff --git a/lib/ui/views/settings/settingsFragment/settings_update_language.dart b/lib/ui/views/settings/settingsFragment/settings_update_language.dart index 48ff2519c9..96939edb2e 100644 --- a/lib/ui/views/settings/settingsFragment/settings_update_language.dart +++ b/lib/ui/views/settings/settingsFragment/settings_update_language.dart @@ -1,6 +1,5 @@ // ignore_for_file: use_build_context_synchronously -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:language_code/language_code.dart'; import 'package:revanced_manager/app/app.locator.dart'; @@ -35,8 +34,9 @@ class SUpdateLanguage extends BaseViewModel { } Future showLanguagesDialog(BuildContext parentContext) { - final ValueNotifier selectedLanguageCode = - ValueNotifier(LocaleSettings.currentLocale.languageCode); + final ValueNotifier selectedLanguageCode = ValueNotifier( + '${LocaleSettings.currentLocale.languageCode}-${LocaleSettings.currentLocale.countryCode}', + ); // initLang(); // Return a dialog with list for each language supported by the application. @@ -55,30 +55,24 @@ class SUpdateLanguage extends BaseViewModel { child: ListBody( children: AppLocale.values.map( (locale) { - LanguageCodes? languageCode; - Text? languageNativeName; - - try { - languageCode = - LanguageCodes.fromCode(locale.languageCode); - } catch (e) { - if (kDebugMode) { - print(e); - } - } - if (languageCode != null) { - languageNativeName = Text(languageCode.nativeName); - } + final LanguageCodes languageCode = LanguageCodes.fromCode( + '${locale.languageCode}_${locale.countryCode}', + orElse: () => LanguageCodes.fromCode(locale.languageCode), + ); return RadioListTile( title: Text( - languageCode?.englishName ?? locale.languageCode, + languageCode.englishName, + ), + subtitle: Text( + '${languageCode.nativeName} (${locale.languageCode}${locale.countryCode != null ? '-${locale.countryCode}' : ''})', ), - subtitle: languageNativeName, - value: locale.languageCode == selectedLanguageCode.value, + value: '${locale.languageCode}-${locale.countryCode}' == + selectedLanguageCode.value, groupValue: true, onChanged: (value) { - selectedLanguageCode.value = locale.languageCode; + selectedLanguageCode.value = + '${locale.languageCode}-${locale.countryCode}'; }, ); }, diff --git a/pubspec.lock b/pubspec.lock index aa25900152..e99decbf79 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -562,10 +562,11 @@ packages: language_code: dependency: "direct main" description: - name: language_code - sha256: ca1e026cc5d4ceeeb03beb73c6fc695ff091e00cec76e089394a365917a37909 - url: "https://pub.dev" - source: hosted + path: "." + ref: "21b71892d1ce07fb8ea51ac2b474e435360fb6f7" + resolved-ref: "21b71892d1ce07fb8ea51ac2b474e435360fb6f7" + url: "https://github.com/Ushie/language_code" + source: git version: "0.4.0" leak_tracker: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 9efe6b3bc9..11a3ecacb0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,7 +41,10 @@ dependencies: injectable: ^2.1.1 intl: ^0.18.0 json_annotation: ^4.8.1 - language_code: ^0.4.0 + language_code: + git: + url: https://github.com/Ushie/language_code + ref: 21b71892d1ce07fb8ea51ac2b474e435360fb6f7 # Branch: feat/add-Filipino, Upstream PR: https://github.com/lamnhan066/language_code/pull/1 logcat: git: url: https://github.com/BenjaminHalko/logcat