Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated list of supported locales is incorrect #113

Open
fl0cke opened this issue Oct 16, 2019 · 2 comments
Open

Generated list of supported locales is incorrect #113

fl0cke opened this issue Oct 16, 2019 · 2 comments

Comments

@fl0cke
Copy link

fl0cke commented Oct 16, 2019

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.

@fl0cke fl0cke changed the title Generated locales incorrect Generated list of supported locales is incorrect Oct 16, 2019
@noordawod noordawod self-assigned this Oct 16, 2019
@noordawod
Copy link
Contributor

Could be a bug indeed, but if a change is introduce now which fixes your problem, it will most probably break all other uses. Any chance you can just add an empty countryCode for each of the locales and check if this fixes the problem?

This can be fixed to follow the rules when we increase the major version number, but not before I think.

@fl0cke
Copy link
Author

fl0cke commented Oct 16, 2019

Any chance you can just add an empty countryCode for each of the locales and check if this fixes the problem?

Haven't checked that. But one can use the provided resolutionCallback and set withCountry to false, which also fixed the problem. However, since the current implementation is clearly in violation of the Locale spec, it should be fixed at some point in the future 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants