williamhjcho / i18next Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nubank/i18next
License: Apache License 2.0
This project forked from nubank/i18next
License: Apache License 2.0
When I launch more than one testWidgets in series with my app and I use I18NextLocalizationDelegate, my tests fails.
In particular from the second testWidgets, it's unable to launch the home Widget defined inside my MaterialApp.
Hi!
I would like to know how to setup widget Tests using this library, probably adding to the example folder? It's kind of related with the issue #13 but if possible adding some basic example
Thank you!
As the title says, allow the user to choice between any of these fallback behaviours:
If none of these behaviours is provided, use the default behaviour (return the key).
After I have implemented a great Generic LanguagePackage API, I need to retrieve my Namespace which I have registered through the ResourceStore on Runtime.
I solved it really fast by adding this method to ResourceStore
class:
/// get all data from [locale] and [namespace]
Map<String, dynamic>? getNamespace(Locale locale, String namespace) =>
_data[locale]?[namespace];
Then I get everything to work with.
Is it possible to add this to the current package?
Thanks a lot ❤️
When using I18NextLocalizationDelegate
, a black screen appears when loading the locale.
When the loading is quick, this results in a flickering on startup.
When the loading itself takes a long time, e.g. when loading assets from the network, this results in black screen that makes the user think the app is freezed and possibly closing the app.
This issue is not specific to this app but is caused by async operations in LocalizationsDelegate.load
.
See also:
flutter/flutter#76086
ilteoood/flutter_i18n#42
Suggested solution
My suggestion is to provide a delegate implementation with the suggested workaround as well:
SynchronousFuture
with the I18Next
objectresourceStore
This way, it is the responsibility of the user to make sure the datasource is already loaded before it is used, but no black screen will be shown in either case.
This could be done in a new SyncI18NextLocalizationDelegate
as to not break current behaviour.
Let me know what you think about this.
/// An [I18NextLocalizationDelegate] that synchronously returns a [I18Next] instance.
/// The loading process is not awaited.
/// It is the responsibility of the user to ensure the data is loaded when this delegate is used.
/// This can be done by awaiting the loading process before using the delegate, e.g. in the main function.
///
/// Synchronously returning an [I18Next] instance prevents a black screen being shown while the locale is being loaded.
/// See also:
/// * [https://github.com/flutter/flutter/issues/76086](flutter/flutter#76086)
/// * [https://github.com/ilteoood/flutter_i18n/issues/42](ilteoood/flutter_i18n#42)
class SynchronousI18NextLocalizationDelegate extends I18NextLocalizationDelegate {
SynchronousI18NextLocalizationDelegate({
required super.locales,
required super.dataSource,
super.resourceStore,
super.options,
});
@override
Future<I18Next> load(Locale locale) {
// ignore: parameter_assignments
locale = normalizeLocale(locale);
super.load(locale);
return SynchronousFuture(I18Next(locale, resourceStore, options: options));
}
}
Officially it's possible to cache translations: https://www.i18next.com/how-to/caching
Is it planned to implement Caching Mechanisms for this package?
It would be great if you can set Remote and Locale Cache Backends.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.