Fixed i18n stuff before merging PR #13
This commit is contained in:
parent
6f6bc29a72
commit
b48450657d
|
|
@ -31,9 +31,26 @@ class _AppState extends State<App> with PreferencesMixin {
|
||||||
themeMode: appTheme.themeMode,
|
themeMode: appTheme.themeMode,
|
||||||
home: const MainPage(title: 'Quickgui - A Flutter frontend for Quickget and Quickemu'),
|
home: const MainPage(title: 'Quickgui - A Flutter frontend for Quickget and Quickemu'),
|
||||||
supportedLocales: const [
|
supportedLocales: const [
|
||||||
/// List of locales we have translations for.
|
/*
|
||||||
Locale('en', ''),
|
* List of locales (language + country) we have translations for.
|
||||||
Locale('fr', ''),
|
*
|
||||||
|
* If there is a file for the tuple (langue, country) in assets/lib/i18n, then this
|
||||||
|
* will be used for translation.
|
||||||
|
*
|
||||||
|
* If there is not, then we'll look for a file for the language only.
|
||||||
|
*
|
||||||
|
* If there is no file for the language code, we'll fallback to the english file.
|
||||||
|
*
|
||||||
|
* Example : let's say the locale is fr_CH. We will look for "assets/lib/i18n/fr_CH.po",
|
||||||
|
* "assets/lib/i18n/fr.po", and "assets/lib/i18n/en.po", stopping at the first file we
|
||||||
|
* find.
|
||||||
|
*
|
||||||
|
* Translation files are not merged, meaning if some translations are missing in fr_CH.po
|
||||||
|
* but are present in fr.po, the missing translations will not be picked up from fr.po,
|
||||||
|
* and thus will show up in english.
|
||||||
|
*/
|
||||||
|
Locale('en'),
|
||||||
|
Locale('fr'),
|
||||||
Locale('fr', 'CH'),
|
Locale('fr', 'CH'),
|
||||||
],
|
],
|
||||||
localizationsDelegates: [
|
localizationsDelegates: [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import 'package:quickgui/src/i18n/quickgui_localizations.dart';
|
||||||
|
|
||||||
class QuickguiLocalizationsDelegate extends LocalizationsDelegate<QuickguiLocalizations> {
|
class QuickguiLocalizationsDelegate extends LocalizationsDelegate<QuickguiLocalizations> {
|
||||||
@override
|
@override
|
||||||
bool isSupported(Locale locale) => ['fr', 'en'].contains(locale.languageCode);
|
bool isSupported(Locale locale) => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<QuickguiLocalizations> load(Locale locale) async {
|
Future<QuickguiLocalizations> load(Locale locale) async {
|
||||||
|
|
@ -12,7 +12,11 @@ class QuickguiLocalizationsDelegate extends LocalizationsDelegate<QuickguiLocali
|
||||||
try {
|
try {
|
||||||
poContent = await rootBundle.loadString('assets/i18n/${locale.languageCode}_${locale.countryCode}.po');
|
poContent = await rootBundle.loadString('assets/i18n/${locale.languageCode}_${locale.countryCode}.po');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
try {
|
||||||
poContent = await rootBundle.loadString('assets/i18n/${locale.languageCode}.po');
|
poContent = await rootBundle.loadString('assets/i18n/${locale.languageCode}.po');
|
||||||
|
} catch (e) {
|
||||||
|
poContent = await rootBundle.loadString('assets/i18n/en.po');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QuickguiLocalizations.fromPO(poContent);
|
return QuickguiLocalizations.fromPO(poContent);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue