Fix Portuguese locale

This commit is contained in:
problematicconsumer
2024-02-20 19:47:56 +03:30
parent 7072593bab
commit c279e3550e
4 changed files with 11 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ extension AppLocaleX on AppLocale {
"zh_TW" => "中文 (台湾)",
"tr" => "Türkçe",
"es" => "Spanish",
"pt_BR" => "Portuguese (Brazil)",
_ => "Unknown",
};
}

View File

@@ -1,11 +1,12 @@
import 'package:hiddify/core/preferences/preferences_provider.dart';
import 'package:hiddify/gen/translations.g.dart';
import 'package:hiddify/utils/custom_loggers.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'locale_preferences.g.dart';
@Riverpod(keepAlive: true)
class LocalePreferences extends _$LocalePreferences {
class LocalePreferences extends _$LocalePreferences with AppLogger {
@override
AppLocale build() {
final persisted =
@@ -15,7 +16,12 @@ class LocalePreferences extends _$LocalePreferences {
if (persisted == "zh") {
return AppLocale.zhCn;
}
try {
return AppLocale.values.byName(persisted);
} catch (e) {
loggy.error("error setting locale: [$persisted]", e);
return AppLocale.en;
}
}
Future<void> changeLocale(AppLocale value) async {

View File

@@ -8,7 +8,8 @@
"ru",
"tr",
"zh-CN",
"zh-TW"
"zh-TW",
"pt-BR"
],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@4/dist/index.js",