Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.
Expand All @@ -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}';
},
);
},
Expand Down
9 changes: 5 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Ushie marked this conversation as resolved.
Show resolved Hide resolved
logcat:
git:
url: https://github.com/BenjaminHalko/logcat
Expand Down