mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-22 17:19:42 +02:00
Add language names and enable Spanish
This commit is contained in:
@@ -27,15 +27,16 @@ const String currentReleaseTag =
|
|||||||
|
|
||||||
const int bgUpdateCheckAlarmId = 666;
|
const int bgUpdateCheckAlarmId = 666;
|
||||||
|
|
||||||
const supportedLocales = [
|
List<MapEntry<Locale, String>> supportedLocales = const [
|
||||||
Locale('en'),
|
MapEntry(Locale('en'), 'English'),
|
||||||
Locale('zh'),
|
MapEntry(Locale('zh'), '汉语'),
|
||||||
Locale('it'),
|
MapEntry(Locale('it'), 'Italiano'),
|
||||||
Locale('ja'),
|
MapEntry(Locale('ja'), '日本語'),
|
||||||
Locale('hu'),
|
MapEntry(Locale('hu'), 'Magyar'),
|
||||||
Locale('de'),
|
MapEntry(Locale('de'), 'Deutsch'),
|
||||||
Locale('fa'),
|
MapEntry(Locale('fa'), 'فارسی'),
|
||||||
Locale('fr')
|
MapEntry(Locale('fr'), 'Français'),
|
||||||
|
MapEntry(Locale('es'), 'Español'),
|
||||||
];
|
];
|
||||||
const fallbackLocale = Locale('en');
|
const fallbackLocale = Locale('en');
|
||||||
const localeDir = 'assets/translations';
|
const localeDir = 'assets/translations';
|
||||||
@@ -52,7 +53,7 @@ Future<void> loadTranslations() async {
|
|||||||
saveLocale: true,
|
saveLocale: true,
|
||||||
forceLocale: forceLocale != null ? Locale(forceLocale) : null,
|
forceLocale: forceLocale != null ? Locale(forceLocale) : null,
|
||||||
fallbackLocale: fallbackLocale,
|
fallbackLocale: fallbackLocale,
|
||||||
supportedLocales: supportedLocales,
|
supportedLocales: supportedLocales.map((e) => e.key).toList(),
|
||||||
assetLoader: const RootBundleAssetLoader(),
|
assetLoader: const RootBundleAssetLoader(),
|
||||||
useOnlyLangCode: true,
|
useOnlyLangCode: true,
|
||||||
useFallbackTranslations: true,
|
useFallbackTranslations: true,
|
||||||
@@ -171,7 +172,7 @@ void main() async {
|
|||||||
Provider(create: (context) => LogsProvider())
|
Provider(create: (context) => LogsProvider())
|
||||||
],
|
],
|
||||||
child: EasyLocalization(
|
child: EasyLocalization(
|
||||||
supportedLocales: supportedLocales,
|
supportedLocales: supportedLocales.map((e) => e.key).toList(),
|
||||||
path: localeDir,
|
path: localeDir,
|
||||||
fallbackLocale: fallbackLocale,
|
fallbackLocale: fallbackLocale,
|
||||||
useOnlyLangCode: true,
|
useOnlyLangCode: true,
|
||||||
@@ -221,7 +222,7 @@ class _ObtainiumState extends State<Obtainium> {
|
|||||||
], onlyIfExists: false);
|
], onlyIfExists: false);
|
||||||
}
|
}
|
||||||
if (!supportedLocales
|
if (!supportedLocales
|
||||||
.map((e) => e.languageCode)
|
.map((e) => e.key.languageCode)
|
||||||
.contains(context.locale.languageCode) ||
|
.contains(context.locale.languageCode) ||
|
||||||
settingsProvider.forcedLocale == null &&
|
settingsProvider.forcedLocale == null &&
|
||||||
context.deviceLocale.languageCode !=
|
context.deviceLocale.languageCode !=
|
||||||
|
@@ -144,8 +144,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
child: Text(tr('followSystem')),
|
child: Text(tr('followSystem')),
|
||||||
),
|
),
|
||||||
...supportedLocales.map((e) => DropdownMenuItem(
|
...supportedLocales.map((e) => DropdownMenuItem(
|
||||||
value: e.toLanguageTag(),
|
value: e.key.toLanguageTag(),
|
||||||
child: Text(e.toLanguageTag().toUpperCase()),
|
child: Text(e.value),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
@@ -216,7 +216,7 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
String? get forcedLocale {
|
String? get forcedLocale {
|
||||||
var fl = prefs?.getString('forcedLocale');
|
var fl = prefs?.getString('forcedLocale');
|
||||||
return supportedLocales
|
return supportedLocales
|
||||||
.where((element) => element.toLanguageTag() == fl)
|
.where((element) => element.key.toLanguageTag() == fl)
|
||||||
.isNotEmpty
|
.isNotEmpty
|
||||||
? fl
|
? fl
|
||||||
: null;
|
: null;
|
||||||
@@ -226,7 +226,7 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
if (fl == null) {
|
if (fl == null) {
|
||||||
prefs?.remove('forcedLocale');
|
prefs?.remove('forcedLocale');
|
||||||
} else if (supportedLocales
|
} else if (supportedLocales
|
||||||
.where((element) => element.toLanguageTag() == fl)
|
.where((element) => element.key.toLanguageTag() == fl)
|
||||||
.isNotEmpty) {
|
.isNotEmpty) {
|
||||||
prefs?.setString('forcedLocale', fl);
|
prefs?.setString('forcedLocale', fl);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user