Proposal - UN M.49 region support to IETF language (#43) #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposal implementation for the region support in IETF language tag.
This proposed change adds a
region
attribute to theLanguage
class which makes this a non-backwards compatible change. It would be possible to reuse thecountry
attribute to pass a country alpha2 code or a UN M.49 region code, but that would be a misuse of that attribute. Open to discuss alternatives.The UN M.49 is a 3-letter numerical code. Since it is numerical and it should be 3-letter, the code should always be
str
, e.g.:'001'
,'419'
, etcThe data use was the official CSV downloaded from United Nations Statistics Division
A
Region
class was created to be as simple as theScript
class. Although it has an English name, no converters forRegion
is created (similar toScript
where there's no converter as well)Some regions have country alpha2 code because they represent the country itself. So a country converter was added to be able to create countries from an UN M.49 code.
Not all countries have a UN M.49 code, like
TW
When creating a language, the
region
attribute is defaulted to the country region, if any. Or thecountry
attribute is defaulted if creating a language using the region code and the region represents a country.The behaviour can be described with the sample snippet:
And one last point that I noticed that's not really related to this change:
In wikipedia (as quoted above), the
script
sub-tag comes before thecountry/region
sub-tag:Also mentioned here:
https://www.w3.org/International/questions/qa-choosing-language-tags
with some examples:
zh-Latn-CN-pinyin
So,
fra-FR-Latn
in the tests should befra-Latn-FR
That itself could result already in a non-backwards compatible fix in babelfish.