Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22594 Fix likelysubtags for macroregion 001 and 150 #2725

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion icu4c/source/common/loclikelysubtags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/test/intltest/loctest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3832,8 +3832,8 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() {
"es_419"
}, {
"und_150",
"en_Latn_150",
"en_150"
"en_Latn_US",
"en"
}, {
"und_AT",
"de_Latn_AT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 ;
Expand Down Expand Up @@ -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 ;
Expand Down
Loading