long1eu/flutter_i18n

Generated list of supported locales is incorrect

Open

#113 opened on Oct 16, 2019

 (2 comments) (0 reactions) (1 assignee)Dart (51 forks)github user discovery
enhancementgood first issue

Repository metrics

Stars
 (249 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I have manually specified the order of locales in my app as

supportedLocales: const [
  Locale('en'),
  Locale('nb'),
],

together with two translation files for en and nb. However, everytime i start the app i get the message that the application's locale (en) not support by the localization delegate. So after investigating i noticed that the plugin generates the following list of supported locales:

List<Locale> get supportedLocales {
  return const <Locale>[
    Locale("nb", ""),
    Locale("en", ""),
  ];
}

Which, according to the official documentation, is not correct and probably the reason why the locale resolution fails (emphasis mine):

The primary language subtag must not be null. The region subtag is optional. When there is no region/country subtag, the parameter should be omitted or passed null instead of an empty-string.

Contributor guide