feat: Improve language distinguishness and resolve language-specific issues (#1706)

This commit is contained in:
Ushie 2024-02-26 04:08:14 +03:00 committed by GitHub
parent f4dea6e58c
commit 6d866d4424
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 26 deletions

View file

@ -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}';
},
);
},

View file

@ -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

View file

@ -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