question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make plurals fallback to those of locale fallback

See original GitHub issue

Is your feature request related to a problem? Please describe. TLDR; Make plurals fallback to those of locale fallback.

We are migrating to Lingui for our preact web application. We choosed @lingui/detect-locale to detect the browser locale with fromNavigator. But, we only have full support for english (en) , spanish (es) and portuguese (pt). In any other case, we would like to fallback to en locale, and use plurals rules for that locale too.

At .linguirc we set up the following, in order to accomplish this:

{
...,
"fallbackLocales": {
      default: "en"
   }
}

Now, when we a user with japanese (ja) locale use the app, we get this error message in the console:

Plurals for locale ja aren't loaded. Use i18n.loadLocaleData method to load plurals for specific locale. Using other plural rule as a fallback.

And effectively “other plural” rule is always used.

Describe proposed solution This issue is related to https://github.com/lingui/js-lingui/issues/798. But that one was considered closed by falling back to the other plural rule always. I think it would be better, and more intuitive to fallback both locale and plural rules to the default fallback locale.

Additional context Other non so user-friendly experience with fallback locales that we have:

  • If the user’s browser is en-US for instance, by default fallback to its CLDR parent locale en, but again the plurals rules do not fallback to en plural rules.

Describe alternatives you’ve considered We ended up trimming the “country” specification from the browser locale before locale activation to avoid plural rules errors regarding CLDR parent locales. But of course this is not what we want to do with our i18n.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

2reactions
germanferrerocommented, Mar 29, 2022

Hey, maybe stale bot shouldn’t be marking this as stale, don’t you think?

2reactions
stale[bot]commented, Mar 29, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS - How to create a fallback language function with ...
How can I create a function that makes the locale default to en or es when a language is not found? import {...
Read more >
Plurals - i18next documentation
You may need to polyfill the Intl.PluralRules API, in case it is not available it will fallback to the i18next JSON format v3...
Read more >
Intl.PluralRules - JavaScript - MDN Web Docs
Chrome Edge PluralRules Full support. Chrome63. Toggle history Full support. Edge18. Tog... PluralRules() constructor Full support. Chrome63. Toggle history Full support. Edge18. Tog... resolvedOptions Full support....
Read more >
Allow customizing the fallback language from the locale ...
In my specific case I wrote a sub class from LocaleMiddleware in order to use add_fallback whenever a language gets detected that is...
Read more >
Configuring a Fallback Chain for a Locale
Select the locale for which you want to set the fallback locale. Click SET FALLBACK. Click the fallback locale that you want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found