Comments (5)
It should fallback, yes. It should try, in order:
- The exact locale (for example, if the device is "pt_br" and it finds "pt_br").
- Then the general language (for example, if the device is "pt_br" and it finds "pt").
- Then any locale with that language (for example, if the device is "pt_br" and it finds "pt_ao").
But, at the moment, the locale in the constructor should not be general. Try Translations("pt_br")
instead of Translations("pt")
.
In other words, try this:
static var t = Translations("pt_br") +
{
"pt_br": "ENTRAR COM GOOGLE",
"en": "ENTER WITH GOOGLE",
"es": "INICIA COM GOOGLE",
};
If it doesn't work, please let me know.
But even if it works, you are right that it should accept Translations("pt")
. In a future version I will change that. I just need Dart 2.6 to go to the stable channel so that I can work in this package again.
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.
from i18n_extension.
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 =\
from i18n_extension.
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
from i18n_extension.
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).
from i18n_extension.
You must wrap your widgets with I18n(child: ...)
and you don't seem to be doing that:
@override
Widget build(BuildContext context) {
return MaterialApp(
home: I18n(child: ...)
);
}
from i18n_extension.
Related Issues (20)
- Error "Translation key in 'en_us' is missing: [...]" while using custom modifiers
- Issue with updating the app language accross the app from the child widget to ancestor widget. HOT 3
- I can't seem to make it work with async_redux. HOT 1
- Support Analyzer 4 HOT 2
- Incorrect plural forms from po files HOT 2
- "Translation key in 'en' is missing..." logs in my debug console HOT 2
- mark a string for getstrings but don't actually translate HOT 8
- We need to update the intl dependency HOT 6
- JSONImporter and getStrings was moved outside of the lib directory. HOT 10
- build fail with v8.0.0 HOT 6
- EXCEPTION CAUGHT BY WIDGETS LIBRARY when running a test HOT 4
- Use intl 0.18.0 HOT 11
- What happened to the JSONImporter? HOT 4
- Error on import package:i18n_extension/io/import.dart in version 9.0.0 HOT 2
- How to use with po files? HOT 4
- Could not find bin/getstrings.dart in package i18n_extension. HOT 1
- There are no translations in 'en_us' HOT 2
- [v11.0.11] Method signature suggestion HOT 1
- Problem with Flutter 3.22.0 HOT 2
- With Flutter 3.22.0 the I18n() widget results in a blank screen on web and disables all gestures on other platforms (iOS, Android, etc.) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n_extension.