ICU-22765 fix uloc_addLikelySubtags on "und@x=private"

This commit is contained in:
Frank Tang 2024-10-15 10:20:39 -07:00 committed by Frank Yung-Fong Tang
parent ca9fcca3c7
commit 1dcb4bcb2d
4 changed files with 26 additions and 2 deletions

View file

@ -527,7 +527,7 @@ LSR LikelySubtags::makeMaximizedLsrFrom(const Locale &locale,
return {};
}
const char *name = locale.getName();
if (uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
if (!returnInputIfUnmatch && uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
// Private use language tag x-subtag-subtag... which CLDR changes to
// und-x-subtag-subtag...
return LSR(name, "", "", LSR::EXPLICIT_LSR);

View file

@ -3924,6 +3924,13 @@ const char* const basic_maximize_data[][2] = {
// ICU-22545 & ICU-22742
"ru_XC",
"ru_Cyrl_XC"
}, {
// ICU-22765
"und@x=private",
"en_Latn_US@x=private",
}, {
"th@x=private",
"th_Thai_TH@x=private",
}
};

View file

@ -4124,6 +4124,15 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() {
"en_PSCRACK",
"en_Latn_US_PSCRACK",
"en__PSCRACK"
}, {
// ICU-22765
"th@x=private",
"th_Thai_TH@x=private",
"th@x=private",
}, {
"und@x=private",
"en_Latn_US@x=private",
"en@x=private",
}
};

View file

@ -4162,7 +4162,15 @@ public class ULocaleTest extends CoreTestFmwk {
"und_US",
"en_Latn_US",
"en"
}
}, {
"th@x=private",
"th_Thai_TH@x=private",
"th@x=private",
}, {
"und@x=private",
"en_Latn_US@x=private",
"en@x=private",
}
};
for (int i = 0; i < full_data.length; i++) {