Code Monkey home page Code Monkey logo

Comments (4)

woody-worakorn avatar woody-worakorn commented on May 18, 2024 2

Same issue but I resolved it now, Because I forgot add asset in pubspec.yaml

assets:

  • resources/langs/en-US.json
  • resources/langs/th-TH.json

Hope this can help you.

from easy_localization.

woody-worakorn avatar woody-worakorn commented on May 18, 2024 2

The one thing can make your app to black screen is "EasyLocalizationProvider", You need to wrap everything with it like this.

Widget build(BuildContext context) {
var data = EasyLocalizationProvider.of(context).data;
data.changeLocale(Locale("th","TH"));
return EasyLocalizationProvider(
data: data,
child: MaterialApp(
...
...

from easy_localization.

ftognetto avatar ftognetto commented on May 18, 2024 1

yes, me too.
This happen during load in the delegate

EasylocaLizationDelegate

class EasylocaLizationDelegate extends LocalizationsDelegate<AppLocalizations> {
  final Locale locale;
  final String path;
  final String loadPath;

  ///  * use only the lang code to generate i18n file path like en.json or ar.json
  final bool useOnlyLangCode;

  EasylocaLizationDelegate({
    @required this.locale,
    this.path,
    this.loadPath,
    this.useOnlyLangCode = false,
  });

  @override
  bool isSupported(Locale locale) => locale != null;

  @override
  Future<AppLocalizations> load(Locale value) async {
    final SharedPreferences _preferences =
        await SharedPreferences.getInstance();
    var _codeLang = _preferences.getString('codeL');
    var _codeCoun = _preferences.getString('codeC');
    if (_codeLang == null || _codeCoun == null) {
      //value = Locale(this.locale.languageCode, this.locale.countryCode);
      await _preferences.setString('codeC', value.countryCode);
      await _preferences.setString('codeL', value.languageCode);
    } else
      value = Locale(_codeLang, _codeCoun);
    AppLocalizations localizations = AppLocalizations(value,
        path: path, loadPath: loadPath, useOnlyLangCode: useOnlyLangCode);
    await localizations.load();
    return localizations;
  }

  @override
  bool shouldReload(LocalizationsDelegate<AppLocalizations> old) => true;
}

It would be useful to load delegate before the runApp method so the app would stay in its splash screen

from easy_localization.

siva563 avatar siva563 commented on May 18, 2024

anyone has solution for this?

from easy_localization.

Related Issues (20)

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.