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:
Brian Stell 2018-06-19 16:53:28 -07:00 committed by Commit Bot
parent 3e5eff73fe
commit 2aee9abee0

View File

@ -1143,14 +1143,7 @@ std::set<std::string> IntlUtil::GetAvailableLocales(const IcuService& service) {
std::string shortened_locale; std::string shortened_locale;
if (IntlUtil::RemoveLocaleScriptTag(icu_name, &shortened_locale)) { if (IntlUtil::RemoveLocaleScriptTag(icu_name, &shortened_locale)) {
error = U_ZERO_ERROR; std::replace(shortened_locale.begin(), shortened_locale.end(), '_', '-');
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;
}
locales.insert(shortened_locale); locales.insert(shortened_locale);
} }
} }