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

Unified Diff: app/l10n_util_win.cc

Issue 4139010: The UI language rather than the locale is now used to pick Chrome's language ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « app/l10n_util_win.h ('k') | base/base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/l10n_util_win.cc
===================================================================
--- app/l10n_util_win.cc (revision 66182)
+++ app/l10n_util_win.cc (working copy)
@@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "app/l10n_util.h"
+#include "app/l10n_util_win.h"
+#include <windowsx.h>
#include <algorithm>
-#include <windowsx.h>
+#include <iterator>
-#include "app/l10n_util_win.h"
+#include "app/l10n_util.h"
#include "base/i18n/rtl.h"
+#include "base/lazy_instance.h"
#include "base/string_number_conversions.h"
+#include "base/win/i18n.h"
#include "base/win/windows_version.h"
#include "grit/app_locale_settings.h"
@@ -52,6 +55,21 @@
return wcscmp(font_name, actual_font_name) == 0;
}
+class OverrideLocaleHolder {
+ public:
+ OverrideLocaleHolder() {}
+ const std::vector<std::string>& value() const { return value_; }
+ void swap_value(std::vector<std::string>* override_value) {
+ value_.swap(*override_value);
+ }
+ private:
+ std::vector<std::string> value_;
+ DISALLOW_COPY_AND_ASSIGN(OverrideLocaleHolder);
+};
+
+base::LazyInstance<OverrideLocaleHolder>
+ override_locale_holder(base::LINKER_INITIALIZED);
+
} // namespace
namespace l10n_util {
@@ -147,4 +165,21 @@
}
}
+void OverrideLocaleWithUILanguageList() {
+ std::vector<std::wstring> ui_languages;
+ if (base::win::i18n::GetThreadPreferredUILanguageList(&ui_languages)) {
+ std::vector<std::string> ascii_languages;
+ ascii_languages.reserve(ui_languages.size());
+ std::transform(ui_languages.begin(), ui_languages.end(),
+ std::back_inserter(ascii_languages), &WideToASCII);
+ override_locale_holder.Get().swap_value(&ascii_languages);
+ } else {
+ NOTREACHED() << "Failed to determine the UI language for locale override.";
+ }
+}
+
+const std::vector<std::string>& GetLocaleOverrides() {
+ return override_locale_holder.Get().value();
+}
+
} // namespace l10n_util
« no previous file with comments | « app/l10n_util_win.h ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698