GithubHelp home page GithubHelp logo

i18next's People

Contributors

ahmadre avatar luluferraco avatar lynn avatar miguelslemos avatar rebarah avatar twister21 avatar wferem1 avatar williamhjcho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

i18next's Issues

Test failed with I18NextLocalizationDelegate

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.

Date formatting incorrect

I'm running the example app. In this app the date is not formatted:

image

I then saw in the readme that the dates can be formatted with {{date, datetime(format:dd/MM/yyyy)}}, this however does not produce the expected result as well (I think it has something to do with the escaping of the slash):

image

[ResourceStore]: Add `getNamespace`

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 ❤️

Black screen while loading locale

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:

  • return a SynchronousFuture with the I18Next object
  • don't await the loading of the namespaces and putting them in the resourceStore

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));
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.