mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8263202: Update Hebrew/Indonesian/Yiddish ISO 639 language codes to current
Reviewed-by: joehw
This commit is contained in:
parent
9c346a1ec7
commit
a4c46e1e4f
35 changed files with 345 additions and 146 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -444,18 +444,26 @@ import sun.util.locale.provider.TimeZoneNameUtility;
|
|||
* in <a href="#special_cases_constructor">Special Cases</a>, only
|
||||
* for the two cases th_TH_TH and ja_JP_JP.
|
||||
*
|
||||
* <h4>Legacy language codes</h4>
|
||||
* <h4><a id="legacy_language_codes">Legacy language codes</a></h4>
|
||||
*
|
||||
* <p>Locale's constructor has always converted three language codes to
|
||||
* their earlier, obsoleted forms: {@code he} maps to {@code iw},
|
||||
* {@code yi} maps to {@code ji}, and {@code id} maps to
|
||||
* {@code in}. This continues to be the case, in order to not break
|
||||
* backwards compatibility.
|
||||
* {@code in}. Since Java SE 17, this is no longer the case. Each
|
||||
* language maps to its new form; {@code iw} maps to {@code he}, {@code ji}
|
||||
* maps to {@code yi}, and {@code in} maps to {@code id}.
|
||||
*
|
||||
* <p>For the backward compatible behavior, the system property
|
||||
* {@systemProperty java.locale.useOldISOCodes} reverts the behavior
|
||||
* back to prior to Java SE 17 one. If the system property is set
|
||||
* to {@code true}, those three current language codes are mapped to their
|
||||
* backward compatible forms.
|
||||
*
|
||||
* <p>The APIs added in 1.7 map between the old and new language codes,
|
||||
* maintaining the old codes internal to Locale (so that
|
||||
* {@code getLanguage} and {@code toString} reflect the old
|
||||
* code), but using the new codes in the BCP 47 language tag APIs (so
|
||||
* maintaining the mapped codes internal to Locale (so that
|
||||
* {@code getLanguage} and {@code toString} reflect the mapped
|
||||
* code, which depends on the {@code java.locale.useOldISOCodes} system
|
||||
* property), but using the new codes in the BCP 47 language tag APIs (so
|
||||
* that {@code toLanguageTag} reflects the new one). This
|
||||
* preserves the equivalence between Locales no matter which code or
|
||||
* API is used to construct them. Java's default resource bundle
|
||||
|
@ -720,13 +728,11 @@ public final class Locale implements Cloneable, Serializable {
|
|||
* Construct a locale from language, country and variant.
|
||||
* This constructor normalizes the language value to lowercase and
|
||||
* the country value to uppercase.
|
||||
* <p>
|
||||
* <b>Note:</b>
|
||||
* @implNote
|
||||
* <ul>
|
||||
* <li>ISO 639 is not a stable standard; some of the language codes it defines
|
||||
* (specifically "iw", "ji", and "in") have changed. This constructor accepts both the
|
||||
* old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
|
||||
* API on Locale will return only the OLD codes.
|
||||
* <li>Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to
|
||||
* their current forms. See <a href="#legacy_language_codes">Legacy language
|
||||
* codes</a> for more information.
|
||||
* <li>For backward compatibility reasons, this constructor does not make
|
||||
* any syntactic checks on the input.
|
||||
* <li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
|
||||
|
@ -754,13 +760,11 @@ public final class Locale implements Cloneable, Serializable {
|
|||
* Construct a locale from language and country.
|
||||
* This constructor normalizes the language value to lowercase and
|
||||
* the country value to uppercase.
|
||||
* <p>
|
||||
* <b>Note:</b>
|
||||
* @implNote
|
||||
* <ul>
|
||||
* <li>ISO 639 is not a stable standard; some of the language codes it defines
|
||||
* (specifically "iw", "ji", and "in") have changed. This constructor accepts both the
|
||||
* old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
|
||||
* API on Locale will return only the OLD codes.
|
||||
* <li>Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to
|
||||
* their current forms. See <a href="#legacy_language_codes">Legacy language
|
||||
* codes</a> for more information.
|
||||
* <li>For backward compatibility reasons, this constructor does not make
|
||||
* any syntactic checks on the input.
|
||||
* </ul>
|
||||
|
@ -779,13 +783,11 @@ public final class Locale implements Cloneable, Serializable {
|
|||
/**
|
||||
* Construct a locale from a language code.
|
||||
* This constructor normalizes the language value to lowercase.
|
||||
* <p>
|
||||
* <b>Note:</b>
|
||||
* @implNote
|
||||
* <ul>
|
||||
* <li>ISO 639 is not a stable standard; some of the language codes it defines
|
||||
* (specifically "iw", "ji", and "in") have changed. This constructor accepts both the
|
||||
* old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
|
||||
* API on Locale will return only the OLD codes.
|
||||
* <li>Obsolete ISO 639 codes ("iw", "ji", and "in") are mapped to
|
||||
* their current forms. See <a href="#legacy_language_codes">Legacy language
|
||||
* codes</a> for more information.
|
||||
* <li>For backward compatibility reasons, this constructor does not make
|
||||
* any syntactic checks on the input.
|
||||
* </ul>
|
||||
|
@ -1207,19 +1209,10 @@ public final class Locale implements Cloneable, Serializable {
|
|||
/**
|
||||
* Returns the language code of this Locale.
|
||||
*
|
||||
* <p><b>Note:</b> ISO 639 is not a stable standard— some languages' codes have changed.
|
||||
* Locale's constructor recognizes both the new and the old codes for the languages
|
||||
* whose codes have changed, but this function always returns the old code. If you
|
||||
* want to check for a specific language whose code has changed, don't do
|
||||
* <pre>
|
||||
* if (locale.getLanguage().equals("he")) // BAD!
|
||||
* ...
|
||||
* </pre>
|
||||
* Instead, do
|
||||
* <pre>
|
||||
* if (locale.getLanguage().equals(new Locale("he").getLanguage()))
|
||||
* ...
|
||||
* </pre>
|
||||
* @implNote This method returns the new forms for the obsolete ISO 639
|
||||
* codes ("iw", "ji", and "in"). See <a href="#legacy_language_codes">
|
||||
* Legacy language codes</a> for more information.
|
||||
*
|
||||
* @return The language code, or the empty string if none is defined.
|
||||
* @see #getDisplayLanguage
|
||||
*/
|
||||
|
@ -1607,9 +1600,11 @@ public final class Locale implements Cloneable, Serializable {
|
|||
*
|
||||
* <li>The language code "und" is mapped to language "".
|
||||
*
|
||||
* <li>The language codes "he", "yi", and "id" are mapped to "iw",
|
||||
* "ji", and "in" respectively. (This is the same canonicalization
|
||||
* that's done in Locale's constructors.)
|
||||
* <li>The language codes "iw", "ji", and "in" are mapped to "he",
|
||||
* "yi", and "id" respectively. (This is the same canonicalization
|
||||
* that's done in Locale's constructors.) See
|
||||
* <a href="#legacy_language_codes">Legacy language codes</a>
|
||||
* for more information.
|
||||
*
|
||||
* <li>The portion of a private use subtag prefixed by "lvariant",
|
||||
* if any, is removed and appended to the variant field in the
|
||||
|
@ -2396,17 +2391,9 @@ public final class Locale implements Cloneable, Serializable {
|
|||
|
||||
private static String convertOldISOCodes(String language) {
|
||||
// we accept both the old and the new ISO codes for the languages whose ISO
|
||||
// codes have changed, but we always store the OLD code, for backward compatibility
|
||||
language = LocaleUtils.toLowerString(language).intern();
|
||||
if (language == "he") {
|
||||
return "iw";
|
||||
} else if (language == "yi") {
|
||||
return "ji";
|
||||
} else if (language == "id") {
|
||||
return "in";
|
||||
} else {
|
||||
return language;
|
||||
}
|
||||
// codes have changed, but we always store the NEW code, unless the property
|
||||
// java.locale.useOldISOCodes is set to "true"
|
||||
return BaseLocale.convertOldISOCodes(LocaleUtils.toLowerString(language).intern());
|
||||
}
|
||||
|
||||
private static LocaleExtensions getCompatibilityExtensions(String language,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue