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

Unified Diff: chrome/installer/util/language_selector.h

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 | « chrome/installer/util/l10n_string_util.cc ('k') | chrome/installer/util/language_selector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/language_selector.h
===================================================================
--- chrome/installer/util/language_selector.h (revision 0)
+++ chrome/installer/util/language_selector.h (revision 0)
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// This file declares a helper class for selecting a supported language from a
+// set of candidates.
+
+#ifndef CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
+#define CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+
+namespace installer_util {
+
+// A helper class for selecting a supported language from a set of candidates.
+// By default, the candidates are retrieved from the operating system.
+class LanguageSelector {
+ public:
+ // Default constructor will select from the set of languages supported by the
+ // operating system.
+ LanguageSelector();
+
+ // Constructor for testing purposes.
+ explicit LanguageSelector(const std::vector<std::wstring>& candidates);
+
+ ~LanguageSelector();
+
+ // The offset of the matched language (i.e., IDS_L10N_OFFSET_*).
+ int offset() const { return offset_; }
+
+ // The full name of the candidate language for which a match was found.
+ const std::wstring& matched_candidate() const { return matched_candidate_; }
+
+ // The name of the selected translation.
+ std::wstring selected_translation() const { return GetLanguageName(offset_); }
+
+ // Returns the name of a translation given its offset.
+ static std::wstring GetLanguageName(int offset);
+
+ private:
+ typedef bool (*SelectPred_Fn)(const std::wstring&, int*);
+
+ static bool SelectIf(const std::vector<std::wstring>& candidates,
+ SelectPred_Fn select_predicate,
+ std::wstring* matched_name, int* matched_offset);
+ void DoSelect(const std::vector<std::wstring>& candidates);
+
+ std::wstring matched_candidate_;
+ int offset_;
+
+ DISALLOW_COPY_AND_ASSIGN(LanguageSelector);
+};
+
+} // namespace installer_util.
+
+#endif // CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
Property changes on: chrome\installer\util\language_selector.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/installer/util/l10n_string_util.cc ('k') | chrome/installer/util/language_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698