8357275: Locale.Builder.setLanguageTag should mention conversions made on language tag

Reviewed-by: naoto
This commit is contained in:
Justin Lu 2025-05-29 17:39:08 +00:00
parent e306367813
commit e509997fe8

View File

@ -1800,7 +1800,7 @@ public final class Locale implements Cloneable, Serializable {
* to {@link Locale.Builder#setLanguageTag(String)} which throws an exception
* in this case.
*
* <p>The following <b>conversions</b> are performed:<ul>
* <p>The following <b id="langtag_conversions">conversions</b> are performed:<ul>
*
* <li>The language code "und" is mapped to language "".
*
@ -1826,13 +1826,19 @@ public final class Locale implements Cloneable, Serializable {
* loc.getExtension('x'); // returns "urp"
* }
*
* <li>When the languageTag argument contains an extlang subtag,
* the first such subtag is used as the language, and the primary
* language subtag and other extlang subtags are ignored:
* <li> BCP 47 language tags permit up to three extlang subtags. However,
* the second and third extlang subtags are always ignored. As such,
* the first extlang subtag in {@code languageTag} is used as the language,
* and the primary language subtag and other extlang subtags are ignored.
* Language tags that exceed three extlang subtags are considered
* ill-formed starting at the offending extlang subtag.
*
* {@snippet lang=java :
* Locale.forLanguageTag("ar-aao").getLanguage(); // returns "aao"
* Locale.forLanguageTag("en-abc-def-us").toString(); // returns "abc_US"
* Locale.forLanguageTag("zh-yue-gan-cmn-czh-CN").toString();
* // returns "yue"; "czh" exceeds the extlang limit, and subsequent
* // subtags are considered ill-formed
* }
*
* <li>Case is normalized except for variant tags, which are left
@ -2787,6 +2793,9 @@ public final class Locale implements Cloneable, Serializable {
* just discards ill-formed and following portions of the
* tag).
*
* <p>See {@link Locale##langtag_conversions converions} for a full list
* of conversions that are performed on {@code languageTag}.
*
* @param languageTag the language tag
* @return This builder.
* @throws IllformedLocaleException if {@code languageTag} is ill-formed