diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index e0e95c9e6a2..290226e5a1d 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -633,7 +633,7 @@ public class CLDRConverter { /** * Examine if the id includes the country (territory) code. If it does, it returns * the country code. - * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG". + * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it returns "SG". * It does NOT return UN M.49 code, e.g., '001', as those three digit numbers cannot * be translated into package names. */ @@ -645,13 +645,21 @@ public class CLDRConverter { /** * Examine if the id includes the region code. If it does, it returns * the region code. - * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG". + * Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it returns "SG". * It DOES return UN M.49 code, e.g., '001', as well as ISO 3166 two letter country codes. */ static String getRegionCode(String id) { return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry(); } + /** + * Examine if the id includes the script code. If it does, it returns + * the script code. + */ + static String getScriptCode(String id) { + return Locale.forLanguageTag(id.replaceAll("_", "-")).getScript(); + } + private static class KeyComparator implements Comparator { static KeyComparator INSTANCE = new KeyComparator(); @@ -1020,6 +1028,7 @@ public class CLDRConverter { private static void setupBaseLocales(String localeList) { Arrays.stream(localeList.split(",")) .map(Locale::forLanguageTag) + .map(l -> new Locale.Builder().setLocale(l).setScript("Latn").build()) .map(l -> Control.getControl(Control.FORMAT_DEFAULT) .getCandidateLocales("", l)) .forEach(BASE_LOCALES::addAll); diff --git a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java index 344bb0ea21f..6b2b5b4c0c0 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java @@ -417,11 +417,11 @@ class ResourceBundleGenerator implements BundleGenerator { private static final Locale.Builder LOCALE_BUILDER = new Locale.Builder(); private static boolean isBaseLocale(String localeID) { localeID = localeID.replaceAll("-", "_"); - // ignore script here Locale locale = LOCALE_BUILDER .clear() .setLanguage(CLDRConverter.getLanguageCode(localeID)) .setRegion(CLDRConverter.getRegionCode(localeID)) + .setScript(CLDRConverter.getScriptCode(localeID)) .build(); return CLDRConverter.BASE_LOCALES.contains(locale); }