fix constructor of collator and pluralRules

Signed-off-by: sunyaozu <sunyaozu@huawei.com>
This commit is contained in:
sunyaozu
2022-05-18 11:24:38 +08:00
parent 6fe3f32bb0
commit 30d54de601
2 changed files with 3 additions and 6 deletions
+1 -3
View File
@@ -66,9 +66,7 @@ Collator::Collator(std::vector<std::string> &localeTags, std::map<std::string, s
ParseAllOptions(options);
UErrorCode status = UErrorCode::U_ZERO_ERROR;
if (!localeTags.size()) {
localeTags.push_back(LocaleConfig::GetSystemLocale());
}
localeTags.push_back(LocaleConfig::GetSystemLocale());
for (size_t i = 0; i < localeTags.size(); i++) {
std::string curLocale = localeTags[i];
locale = icu::Locale::forLanguageTag(icu::StringPiece(curLocale), status);
+2 -3
View File
@@ -81,9 +81,7 @@ void PluralRules::InitPluralRules(std::vector<std::string> &localeTags,
{
UPluralType uPluralType = (type == "cardinal") ? UPLURAL_TYPE_CARDINAL : UPLURAL_TYPE_ORDINAL;
UErrorCode status = UErrorCode::U_ZERO_ERROR;
if (!localeTags.size()) {
localeTags.push_back(LocaleConfig::GetSystemLocale());
}
localeTags.push_back(LocaleConfig::GetSystemLocale());
for (size_t i = 0; i < localeTags.size(); i++) {
std::string curLocale = localeTags[i];
locale = icu::Locale::forLanguageTag(icu::StringPiece(curLocale), status);
@@ -95,6 +93,7 @@ void PluralRules::InitPluralRules(std::vector<std::string> &localeTags,
if (status != UErrorCode::U_ZERO_ERROR || !pluralRules) {
continue;
}
break;
}
}
if (status != UErrorCode::U_ZERO_ERROR || !pluralRules) {