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

Feature Request: Fallback for language variants to it's superset #120

Open
8 tasks done
NoLdman opened this issue Feb 2, 2018 · 0 comments
Open
8 tasks done

Feature Request: Fallback for language variants to it's superset #120

NoLdman opened this issue Feb 2, 2018 · 0 comments

Comments

@NoLdman
Copy link

NoLdman commented Feb 2, 2018

Description

Many languages have locale (country-specific) variants. In such variants only specific words/phrases differ from the general language. Currently you have to duplicate the whole language-pack and replace the region specific phrases, which makes maintenance a nuisance.

Since intl-messageformat conforms BCP 47 I'd suggest that during translation the code should check if there is a translation that matches the first part of the language string:

var similarLanguage = language.split("-")[0];
var translatedValue;

if (!key || !resources || !language || !(resources[language] || resources[similarLanguage]))
  return;

// Cache the key/value pairs for the same language, so that we don't
// do extra work if we're just reusing strings across an application.
if(resources[language])
  translatedValue = resources[language][key];

if(!translatedValue && resources[similarLanguage])
  translatedValue = resources[similarLanguage][key];

Expected outcome

The translation of it's superset should be output.

Actual outcome

Nothing is output.

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant