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.
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:Expected outcome
The translation of it's superset should be output.
Actual outcome
Nothing is output.
Browsers Affected