diff --git a/icu4c/source/common/loclikelysubtags.cpp b/icu4c/source/common/loclikelysubtags.cpp index 8800111d166e..3eed4361b337 100644 --- a/icu4c/source/common/loclikelysubtags.cpp +++ b/icu4c/source/common/loclikelysubtags.cpp @@ -709,7 +709,7 @@ LSR LikelySubtags::maximize(StringPiece language, StringPiece script, StringPiec matchRegion = true; } } else { - retainRegion = true; + retainRegion = !region.empty() && !isMacroregion(region, errorCode); if (state == 0) { value = defaultLsrIndex; } else { diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 8134fca6ae15..1a4b9869679e 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -3832,8 +3832,8 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() { "es_419" }, { "und_150", - "en_Latn_150", - "en_150" + "en_Latn_US", + "en" }, { "und_AT", "de_Latn_AT", diff --git a/icu4c/source/test/testdata/cldr/localeIdentifiers/likelySubtags.txt b/icu4c/source/test/testdata/cldr/localeIdentifiers/likelySubtags.txt index 1f9e3557fff3..a7bd27364f74 100644 --- a/icu4c/source/test/testdata/cldr/localeIdentifiers/likelySubtags.txt +++ b/icu4c/source/test/testdata/cldr/localeIdentifiers/likelySubtags.txt @@ -980,8 +980,8 @@ uk-Cyrl ; uk-Cyrl-UA ; uk ; uk-Egyp ; uk-Egyp-UA ; uk-Egyp ; uk-UA ; uk-Cyrl-UA ; uk ; und ; en-Latn-US ; en ; -und-001 ; en-Latn-001 ; en-001 ; -und-150 ; en-Latn-150 ; en-150 ; +und-001 ; en-Latn-US ; en ; +und-150 ; en-Latn-US ; en ; und-419 ; es-Latn-419 ; es-419 ; und-AD ; ca-Latn-AD ; ca-AD ; und-AE ; ar-Arab-AE ; ar-AE ; @@ -1014,7 +1014,7 @@ und-Adlm-NG ; ff-Adlm-NG ; ; und-Adlm-SL ; ff-Adlm-SL ; ; und-Adlm-SN ; ff-Adlm-SN ; ; und-Arab ; ar-Arab-EG ; ar ; -und-Arab-001 ; ar-Arab-001 ; ar-001 ; +und-Arab-001 ; ar-Arab-EG ; ar ; und-Arab-AE ; ar-Arab-AE ; ar-AE ; und-Arab-AF ; fa-Arab-AF ; fa-AF ; und-Arab-AQ ; ar-Arab-AQ ; ar-AQ ; @@ -1255,8 +1255,8 @@ und-Laoo ; lo-Laoo-LA ; lo ; und-Laoo-AQ ; lo-Laoo-AQ ; lo-AQ ; und-Laoo-LA ; lo-Laoo-LA ; lo ; und-Latn ; en-Latn-US ; en ; -und-Latn-001 ; en-Latn-001 ; en-001 ; -und-Latn-150 ; en-Latn-150 ; en-150 ; +und-Latn-001 ; en-Latn-US ; en ; +und-Latn-150 ; en-Latn-US ; en ; und-Latn-419 ; es-Latn-419 ; es-419 ; und-Latn-AD ; ca-Latn-AD ; ca-AD ; und-Latn-AE ; en-Latn-AE ; en-AE ; diff --git a/icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/util/ULocaleTest.java index 4c6e36cc00a4..4e89791c4b47 100644 --- a/icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -4114,8 +4114,8 @@ else if (!res.toString().equals(exp)) { "es_419" }, { "und_150", - "en_Latn_150", - "en_150" + "en_Latn_US", + "en" }, { "und_AT", "de_Latn_AT", diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/impl/locale/LikelySubtags.java b/icu4j/main/core/src/main/java/com/ibm/icu/impl/locale/LikelySubtags.java index 6d5a35379378..bcee84660b0f 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/impl/locale/LikelySubtags.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/impl/locale/LikelySubtags.java @@ -269,7 +269,12 @@ private LSR makeMaximizedLsr(String language, String script, String region, Stri * Helper method to find out a region is a macroregion */ private boolean isMacroregion(String region) { - Region.RegionType type = Region.getInstance(region).getType(); + Region.RegionType type; + try { + type = Region.getInstance(region).getType(); + } catch (Exception e) { + return false; // return false for unrecognized region. + } return type == Region.RegionType.WORLD || type == Region.RegionType.CONTINENT || type == Region.RegionType.SUBCONTINENT ; @@ -356,7 +361,7 @@ private LSR maximize(String language, String script, String region, boolean retu matchRegion = true; } } else { - retainRegion = true; + retainRegion = !region.isEmpty() && !isMacroregion(region); if (state == 0) { value = defaultLsrIndex; } else { diff --git a/icu4j/main/core/src/test/resources/com/ibm/icu/dev/data/cldr/localeIdentifiers/likelySubtags.txt b/icu4j/main/core/src/test/resources/com/ibm/icu/dev/data/cldr/localeIdentifiers/likelySubtags.txt index 1f9e3557fff3..a7bd27364f74 100644 --- a/icu4j/main/core/src/test/resources/com/ibm/icu/dev/data/cldr/localeIdentifiers/likelySubtags.txt +++ b/icu4j/main/core/src/test/resources/com/ibm/icu/dev/data/cldr/localeIdentifiers/likelySubtags.txt @@ -980,8 +980,8 @@ uk-Cyrl ; uk-Cyrl-UA ; uk ; uk-Egyp ; uk-Egyp-UA ; uk-Egyp ; uk-UA ; uk-Cyrl-UA ; uk ; und ; en-Latn-US ; en ; -und-001 ; en-Latn-001 ; en-001 ; -und-150 ; en-Latn-150 ; en-150 ; +und-001 ; en-Latn-US ; en ; +und-150 ; en-Latn-US ; en ; und-419 ; es-Latn-419 ; es-419 ; und-AD ; ca-Latn-AD ; ca-AD ; und-AE ; ar-Arab-AE ; ar-AE ; @@ -1014,7 +1014,7 @@ und-Adlm-NG ; ff-Adlm-NG ; ; und-Adlm-SL ; ff-Adlm-SL ; ; und-Adlm-SN ; ff-Adlm-SN ; ; und-Arab ; ar-Arab-EG ; ar ; -und-Arab-001 ; ar-Arab-001 ; ar-001 ; +und-Arab-001 ; ar-Arab-EG ; ar ; und-Arab-AE ; ar-Arab-AE ; ar-AE ; und-Arab-AF ; fa-Arab-AF ; fa-AF ; und-Arab-AQ ; ar-Arab-AQ ; ar-AQ ; @@ -1255,8 +1255,8 @@ und-Laoo ; lo-Laoo-LA ; lo ; und-Laoo-AQ ; lo-Laoo-AQ ; lo-AQ ; und-Laoo-LA ; lo-Laoo-LA ; lo ; und-Latn ; en-Latn-US ; en ; -und-Latn-001 ; en-Latn-001 ; en-001 ; -und-Latn-150 ; en-Latn-150 ; en-150 ; +und-Latn-001 ; en-Latn-US ; en ; +und-Latn-150 ; en-Latn-US ; en ; und-Latn-419 ; es-Latn-419 ; es-419 ; und-Latn-AD ; ca-Latn-AD ; ca-AD ; und-Latn-AE ; en-Latn-AE ; en-AE ;