summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoralemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 19:49:20 +0000
committeralemate@chromium.org <alemate@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 19:50:29 +0000
commit0cccbeed42d59713a1c191e3ff1cfae6eff3bcb5 (patch)
tree251595810e68dc97bbeb80812958766ae8c46c70 /ui
parent3960aadeebbab3801cbbdd426990feba87d5a668 (diff)
downloadchromium_src-0cccbeed42d59713a1c191e3ff1cfae6eff3bcb5.zip
chromium_src-0cccbeed42d59713a1c191e3ff1cfae6eff3bcb5.tar.gz
chromium_src-0cccbeed42d59713a1c191e3ff1cfae6eff3bcb5.tar.bz2
ChromeOS: should not show "Language changed" notification for certain languages.
BUG=317718 TEST=manually tested Review URL: https://codereview.chromium.org/382973002 Cr-Commit-Position: refs/heads/master@{#289985} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/l10n/l10n_util.cc20
-rw-r--r--ui/base/l10n/l10n_util.h7
2 files changed, 23 insertions, 4 deletions
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 55c4d04..54b2848 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.size() < locale.size()) {
+ std::string region(locale, lang.size() + 1);
std::string tmp_locale(lang);
// Map es-RR other than es-ES to es-419 (Chrome's Latin American
// Spanish locale).
@@ -877,4 +881,12 @@ int GetLocalizedContentsWidthInPixels(int pixel_resource_id) {
return width;
}
+const char* const* GetAcceptLanguageListForTesting() {
+ return kAcceptLanguageList;
+}
+
+size_t GetAcceptLanguageListSizeForTesting() {
+ return arraysize(kAcceptLanguageList);
+}
+
} // namespace l10n_util
diff --git a/ui/base/l10n/l10n_util.h b/ui/base/l10n/l10n_util.h
index a71240c..bc0ff60 100644
--- a/ui/base/l10n/l10n_util.h
+++ b/ui/base/l10n/l10n_util.h
@@ -24,6 +24,9 @@ namespace l10n_util {
// std::string as an argument.
UI_BASE_EXPORT std::string GetCanonicalLocale(const std::string& locale);
+// Takes normalized locale as |locale|. Returns language part (before '-').
+UI_BASE_EXPORT std::string GetLanguage(const std::string& locale);
+
// This method translates a generic locale name to one of the locally defined
// ones. This method returns true if it succeeds.
UI_BASE_EXPORT bool CheckAndResolveLocale(const std::string& locale,
@@ -185,6 +188,10 @@ UI_BASE_EXPORT void GetAcceptLanguagesForLocale(
// designer given constraints which might dependent on the language used.
UI_BASE_EXPORT int GetLocalizedContentsWidthInPixels(int pixel_resource_id);
+const char* const* GetAcceptLanguageListForTesting();
+
+size_t GetAcceptLanguageListSizeForTesting();
+
} // namespace l10n_util
#endif // UI_BASE_L10N_L10N_UTIL_H_