[loc-en-dev] Conclusion of ja_JP_JP/th_TH_TH problem

Yoshito Umaoka y.umaoka at gmail.com
Mon Jul 26 19:07:52 PDT 2010


Hi all,

I think below is our conclusion for ja_JP_JP/th_TH_TH problem in the 
proposal. If you think I'm misunderstanding about this, please respond.

1. Constructor will add Unicode locale extension - u-ca-japanese /u-nu-thai

new Locale("ja", "JP", "JP").getUnicodeLocaleType("ca") -> "japanese"
new Locale("th", "TH', "TH").getUnicodeLocaleType("nu") -> "thai"

2.  Serialization

- writeObject writes out eveything into data stream
- readObject read everything into Locale fields + special handling for 
ja_JP_JP/th_TH_TH. If language/country/variant is exactly "ja"/"JP"/"JP" 
or "th"/"TH"/"TH" and if the serialized Locale object does not have any 
extensions, then add the locale extension "u-ca-japanese" / "u-nu-thai" 
in readObject.

3. toLanguageTag() writes the variant as x-lvariant-xxx

new Locale("ja", "JP", "JP").toLanguageTag() -> 
"ja-JP-u-ca-japanese-x-lvariant-JP"
new Locale("th", "TH", "TH").toLanguageTag() -> 
"th-TH-u-nu-thai-x-lvariant-TH"

4. forLanguageTag(String)

- Restore -x-lvariant to Locale's variant always, which may result 
variant JP/TH.
- After processing -x-lvariant-xxxx, language/country/variant are 
exactly ja/JP/JP or th/TH/TH and no extensions, u-ca-japanese/u-nu-thai 
will be appended

Note: With this proposal, Java will never create a Locale ja_JP_JP / 
th_TH_TH without extensions. Although, forLanguageTag may create a 
Locale ja_JP_JP with other extensions.  For example:

Locale.forLanguageTag("ja-JP-u-ca-gregory-x-lvariant-JP") -> ja_JP_JP 
with extension u-ca-gregory

5. Builder.setLocale(Locale)

- setLocale accepts Locale("ja", "JP", "JP") / Locale("th", "TH", "TH"), 
but the ill-formed variant is dropped.

new Builder().setLocale(new Locale("ja", "JP", "JP")).build().toString() 
-> "ja_JP_#u-ca-japanese" (Note: extension u-ca-japanese is appended by 
the Locale constructor)


-Yoshito




More information about the locale-enhancement-dev mailing list