Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: ui/base/l10n/l10n_util.cc

Issue 382973002: ChromeOS: should not show "Language changed" notification for certain languages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/chromeos/locale_change_guard.cc ('K') | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util.cc
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 44d8df505471a3b163fbd0a238fead49b4795b89..7315573fc287b2763d5eed6484c0fb5e43166c4b 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -311,6 +311,11 @@ std::string GetCanonicalLocale(const std::string& locale) {
return base::i18n::GetCanonicalLocale(locale.c_str());
}
+std::string GetLanguage(const std::string& locale) {
+ const std::string::size_type hyphen_pos = locale.find('-');
+ return std::string(locale, 0, hyphen_pos);
+}
+
bool CheckAndResolveLocale(const std::string& locale,
std::string* resolved_locale) {
#if defined(OS_MACOSX)
@@ -334,10 +339,9 @@ bool CheckAndResolveLocale(const std::string& locale,
// does not support but available on Windows. We fall
// back to en-US in GetApplicationLocale so that it's a not critical,
// but we can do better.
- std::string::size_type hyphen_pos = locale.find('-');
- std::string lang(locale, 0, hyphen_pos);
- if (hyphen_pos != std::string::npos && hyphen_pos > 0) {
- std::string region(locale, hyphen_pos + 1);
+ const std::string lang(GetLanguage(locale));
+ if (lang != locale) {
+ std::string region(locale, lang.size());
std::string tmp_locale(lang);
// Map es-RR other than es-ES to es-419 (Chrome's Latin American
// Spanish locale).
« chrome/browser/chromeos/locale_change_guard.cc ('K') | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698