Skip to content

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

@NoLdman

Description

@NoLdman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions