-
Notifications
You must be signed in to change notification settings - Fork 65
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
No fallback? #2
Comments
It should fallback, yes. It should try, in order:
But, at the moment, the locale in the constructor should not be general. Try In other words, try this:
If it doesn't work, please let me know. But even if it works, you are right that it should accept Also, have a look at https://github.com/marcglasberg/i18n_extension/blob/master/test/i18n_extension_test.dart and see that it tests the fallbacks. If you can, try to modify some of the tests there to create a failing test to help me fix the problem. |
Phone: English, United States static var t = Translations("pt_br") +
{
"pt": "ENTRAR COM GOOGLE",
"en": "ENTER WITH GOOGLE",
"es": "INICIA COM GOOGLE",
}; Error: `No default translation for 'pt_br'. But I don't want just br, I want all portuguese variants! static var t = Translations("pt_br") +
{
"pt_br": "ENTRAR COM GOOGLE",
"en": "ENTER WITH GOOGLE",
"es": "INICIA COM GOOGLE",
}; Button remains in portuguese (should be english). Can't figure out how this plugin works =\ |
Ok, no problem. Can you please provide me with some minimum runnable code (with main method and all) demonstrating the problem? I need to reproduce it to be able to fix it. By the way, have you tried running the example? https://github.com/marcglasberg/i18n_extension/blob/master/example/lib/main.dart |
Working as this: On main.dart: return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: Catcher.navigatorKey,
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale("pt"), Locale("en"), Locale("es")],
localeResolutionCallback: (locale, locales) {
print("FALLBACK TO ${locale.toLanguageTag()}");
if (locale.languageCode == "pt") {
return const Locale("pt", "BR");
} else if (locale.languageCode == "en") {
return const Locale("en");
} else if (locale.languageCode == "es") {
return const Locale("es");
}
return const Locale("en");
}, (needed to fallback to pt-BR when language is pt-*, otherwise, it won't work) Then, with this translations: static var t = Translations("pt_br") +
{
"pt_br": "ENTRAR COM GOOGLE",
"en": "ENTER WITH GOOGLE",
"es": "INICIA COM GOOGLE",
}; Now it works as intended (with my phone set to English United State, it calls the fallback code, so I set it to "en" and it works). |
You must wrap your widgets with @override
Widget build(BuildContext context) {
return MaterialApp(
home: I18n(child: ...)
);
} |
Considering:
Results in:
I was expecting something like pt_pt, pt_ao, pt_br too fallback to pt (I'm lazy and don't want to translate every variant of portuguese, english and spanish)
BTW, my phone is en_US (don't know why it is trying to find pt_br)
The text was updated successfully, but these errors were encountered: