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

Unified Diff: chrome/browser/ui/webui/chromeos/login/l10n_util.cc

Issue 483523005: Default to current UI locale when recommended locales are invalid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: chrome/browser/ui/webui/chromeos/login/l10n_util.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/l10n_util.cc b/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
index aa8d38bb45148ad52dc6a7de5cb05fa9d4fbc2bc..3bb24e8cf092301cd55e0ffa7ac8f4987ac3c45d 100644
--- a/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
+++ b/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
@@ -370,6 +370,29 @@ scoped_ptr<base::ListValue> GetUILanguageList(
return languages_list.Pass();
}
+std::string FindMostRelevantLocale(
+ const std::vector<std::string>* most_relevant_language_codes,
+ const base::ListValue& available_locales,
+ const std::string& fallback_locale) {
+ if (!most_relevant_language_codes)
+ return fallback_locale;
+
+ for (std::vector<std::string>::const_iterator most_relevant_it =
+ most_relevant_language_codes->begin();
+ most_relevant_it != most_relevant_language_codes->end();
+ ++most_relevant_it) {
+ base::StringValue most_relevant_locale(*most_relevant_it);
+ for (base::ListValue::const_iterator available_it =
+ available_locales.begin();
+ available_it != available_locales.end(); ++available_it) {
+ if (most_relevant_locale.Equals(*available_it))
+ return *most_relevant_it;
+ }
+ }
+
+ return fallback_locale;
+}
+
scoped_ptr<base::ListValue> GetAcceptLanguageList() {
// Collect the language codes from the supported accept-languages.
const std::string app_locale = g_browser_process->GetApplicationLocale();

Powered by Google App Engine
This is Rietveld 408576698