Locale Format
Problem:
Currently, we can get formats like the following:
Chinese (Simplified Han)
Simplified Chinese (Singapore)
Chinese (Simplified Han, Singapore)
English (United States)
American English
English (United States, Variant)
American English (Variant)
But we want to be able to have formats like:
Chinese (Simplified, Singapore)
Chinese (Simplified)
English (US), or English (American)
English (UK), or English (British)
English (US, Variant)
Here is a proposal for how to do this:
Our current data looks like this (English):
<localeDisplayPattern>
<localePattern>{0} ({1})</localePattern>
<localeSeparator>, </localeSeparator>
</localeDisplayPattern>
- <language type=”zh_Hans”>Simplified Chinese</language>
- <language type=”zh_Hant”>Traditional Chinese</language>
- <language type=”en_US”>U.S. English</language>
- <script type=”Hans”>Simplified Han</script>
- <script type=”Hant”>Traditional Han</script>
What happens is that in formatting, the fields that are not present in the type are put into {1} in the localePattern, separated by the localeSeparator (if there is more than one).
We would change it slightly so that we could have patterns like:
- <language type=”zh_Hans”>Chinese (Simplified{SEP_LEFT})</language>
- <language type=”en_US”>English (US{SEP_LEFT})</language>
{SEP_LEFT} is whatever is left: separated by localeSeparator, and with localeSeparator in front
{LEFT} is whatever is left: separated by localeSeparator, but with no initial localeSeparator
Then we get:
en_US_VARIANT => English (US, Variant)
If there is no placeholder in the pattern, it works the old way.
Issue:
- Add context=””, “standalone”, “short”, “short standalone”
- If you have type=”en_US”, then it will get one of the following:
- ””: English (American) or English (United States)
- “short”: English (US)
- “standalone”: American English
- “short standalone”: US English
- We would also add context=”short” on Regions, to get “US”, and use it if there wasn’t a short form of en_US context=”short” or “short standalone”
Fallbacks:
- short standalone => standalone => “”
- short => “”