Simplify bcp47 conversion of locale without script tag.
Change-Id: I741d53f3e132a4770fa738b7e902c1f24eafd594 Reviewed-on: https://chromium-review.googlesource.com/1107237 Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Jungshik Shin <jshin@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#53895}
This commit is contained in:
parent
3e5eff73fe
commit
2aee9abee0
@ -1143,14 +1143,7 @@ std::set<std::string> IntlUtil::GetAvailableLocales(const IcuService& service) {
|
||||
|
||||
std::string shortened_locale;
|
||||
if (IntlUtil::RemoveLocaleScriptTag(icu_name, &shortened_locale)) {
|
||||
error = U_ZERO_ERROR;
|
||||
char bcp47_result[ULOC_FULLNAME_CAPACITY];
|
||||
uloc_toLanguageTag(shortened_locale.c_str(), bcp47_result,
|
||||
ULOC_FULLNAME_CAPACITY, true, &error);
|
||||
if (U_FAILURE(error) || error == U_STRING_NOT_TERMINATED_WARNING) {
|
||||
// This shouldn't happen, but lets not break the user.
|
||||
continue;
|
||||
}
|
||||
std::replace(shortened_locale.begin(), shortened_locale.end(), '_', '-');
|
||||
locales.insert(shortened_locale);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user