Skip to content

Allow a generic language map for each language to reduce key duplication#3414

Open
SteveHawes wants to merge 6 commits intojonataslaw:masterfrom
SteveHawes:master
Open

Allow a generic language map for each language to reduce key duplication#3414
SteveHawes wants to merge 6 commits intojonataslaw:masterfrom
SteveHawes:master

Conversation

@SteveHawes
Copy link
Copy Markdown

Enhanced the Internationalisation so that if a key is not found in the specific country variant map (or the country variant map is not found) the first choice for the fallback is a generic language file.

e.g. If the locale is currently "en_GB" and the requested key does not exist in the "en_GB" translations map (or "en_GB" does not exist at all) then it will first look for a map with the key "en".
If that exists then this is the translation map that will be used otherwise it will use the current behaviour.
Every PR must update the corresponding documentation in the code, and also the readme in english with the following changes.

Pre-launch Checklist

  • [X ] I updated/added relevant documentation (doc comments with ///).
  • [X ] I added new tests to check the change I am making or feature I am adding, or @jonataslaw said the PR is test-exempt.
  • [X ] All existing and new tests are passing.

…e specific country variant map (or the country variant map is not found) the first choice for the fallback is a generic language file.

e.g. If the locale is currently "en_GB" and the requested key does not exist in the "en_GB" translations map (or "en_GB" does not exist at all) then it will first look for a map with the key "en".
If that exists then this is the translation map that will be used otherwise it will use the current behaviour.

In this way you can supply a single language map for each language that contains all the keys and then add only the keys that need to be overridden for a specific country variant. e.g.

"en"          - contains all keys for the English language
"en_AU"   - contains only the country specific keys that are different to the main map such as date format etc.
"en_GB"   - contains only the country specific keys that are different to the main map such as date format etc.
"en_US"   - contains only the country specific keys that are different to the main map such as date format etc.
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

Successfully merging this pull request may close these issues.

1 participant