[loc-en-dev] Builder / Locale API detailed review
Yoshito Umaoka
y.umaoka at gmail.com
Wed Jul 7 13:13:26 PDT 2010
Doug Felt wrote:
>
>
>
> 2) Locale.forLanguageTag("en-x-jvariant-WIN") vs. new
> Builder().setLanguage("en").setExtension("x-jvariant-WIN").build()
>
> In the last call, we thought private use "jvariant-*" should be
> treated as Java variant. I think above two should create the same
> Locale - en__WIN. Are there any objections with this behavior?
>
> If we decide to parse private use "jvariant-*" into variant, we
> need to resolve one more issue.
>
> new
> Builder().setLanguage("en").setVariant("Windows").setExtension("x-jvariant-XP").build()
>
> We have two choices. setExtension above to set "XP" to variant, or
> append "XP" to the variant. So the result Locale would be either:
>
> a) en__XP
> b) en__Windows_XP
>
> I prefer option b) that means, "append". This behavior is somewhat
> consistent with toLanguageTag() - new Locale("en", "",
> "Windows_XP").toLanguageTag() returns "en-Windows-x-jvariant-XP".
>
> I think there's a few more issues to clarify:
>
> 1) what does ... setExtension("x-jvariant-XP").setVariant("Windows")
> return?
> 2) what does ...
> setExtension("x-jvariant-XP").setExtension("x-jvariant-NY") return?
> 3) what does ...
> setExtension("x-jvariant-XP").setVariant("Windows").setExtension("x-jvariant-NY")
> return?
>
> The usual behavior for setExtension is to replace, not append. So it
> seems we're special-casing extensions starting with "x-jvariant-" to
> append. If so, we need to explain this special case in the javadoc.
>
> Alternatively, we can wait until we resolve to a Locale, and then if
> we have an x-extension starting with jvariant- we can append the
> variants at that time (and strip this data from the x-extension).
I actually thought about deferring create() to handle x-jvariant-* at
first. For some reason, I thought it would require create() to throw an
exception in an error case (for now, this is not necessary). But now, I
realize it is not necessary and it looks like the cleanest design (so we
do not need to worry about ordering). Thus, I agree to defer this when a
Locale is created (stripping off jvariant-* from 'x' extension, append
it to variant).
-Yoshito
More information about the locale-enhancement-dev
mailing list