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" => "中文 (台湾)", "zh_TW" => "中文 (台湾)",
"tr" => "Türkçe", "tr" => "Türkçe",
"es" => "Spanish", "es" => "Spanish",
"pt_BR" => "Portuguese (Brazil)",
_ => "Unknown", _ => "Unknown",
}; };
} }

View File

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

View File

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