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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // This file declares a helper class for selecting a supported language from a
6 // set of candidates.
7
8 #ifndef CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
9 #define CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
10 #pragma once
11
12 #include <string>
13 #include <vector>
14
15 #include "base/basictypes.h"
16
17 namespace installer_util {
18
19 // A helper class for selecting a supported language from a set of candidates.
20 // By default, the candidates are retrieved from the operating system.
21 class LanguageSelector {
22 public:
23 // Default constructor will select from the set of languages supported by the
24 // operating system.
25 LanguageSelector();
26
27 // Constructor for testing purposes.
28 explicit LanguageSelector(const std::vector<std::wstring>& candidates);
29
30 ~LanguageSelector();
31
32 // The offset of the matched language (i.e., IDS_L10N_OFFSET_*).
33 int offset() const { return offset_; }
34
35 // The full name of the candidate language for which a match was found.
36 const std::wstring& matched_candidate() const { return matched_candidate_; }
37
38 // The name of the selected translation.
39 std::wstring selected_translation() const { return GetLanguageName(offset_); }
40
41 // Returns the name of a translation given its offset.
42 static std::wstring GetLanguageName(int offset);
43
44 private:
45 typedef bool (*SelectPred_Fn)(const std::wstring&, int*);
46
47 static bool SelectIf(const std::vector<std::wstring>& candidates,
48 SelectPred_Fn select_predicate,
49 std::wstring* matched_name, int* matched_offset);
50 void DoSelect(const std::vector<std::wstring>& candidates);
51
52 std::wstring matched_candidate_;
53 int offset_;
54
55 DISALLOW_COPY_AND_ASSIGN(LanguageSelector);
56 };
57
58 } // namespace installer_util.
59
60 #endif // CHROME_INSTALLER_UTIL_LANGUAGE_SELECTOR_H_
OLDNEW
« 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