mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: Improve language distinguishness and resolve language-specific issues (#1706)
This commit is contained in:
parent
f4dea6e58c
commit
6d866d4424
@ -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<void> showLanguagesDialog(BuildContext parentContext) {
|
||||
final ValueNotifier<String> selectedLanguageCode =
|
||||
ValueNotifier(LocaleSettings.currentLocale.languageCode);
|
||||
final ValueNotifier<String> 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: languageNativeName,
|
||||
value: locale.languageCode == selectedLanguageCode.value,
|
||||
subtitle: Text(
|
||||
'${languageCode.nativeName} (${locale.languageCode}${locale.countryCode != null ? '-${locale.countryCode}' : ''})',
|
||||
),
|
||||
value: '${locale.languageCode}-${locale.countryCode}' ==
|
||||
selectedLanguageCode.value,
|
||||
groupValue: true,
|
||||
onChanged: (value) {
|
||||
selectedLanguageCode.value = locale.languageCode;
|
||||
selectedLanguageCode.value =
|
||||
'${locale.languageCode}-${locale.countryCode}';
|
||||
},
|
||||
);
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user