| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file defines a helper class for selecting a supported language from a | 5 // This file defines a helper class for selecting a supported language from a |
| 6 // set of candidates. | 6 // set of candidates. |
| 7 | 7 |
| 8 #include "chrome/installer/util/language_selector.h" | 8 #include "chrome/installer/util/language_selector.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 struct LangToOffset { | 22 struct LangToOffset { |
| 23 const wchar_t* language; | 23 const wchar_t* language; |
| 24 int offset; | 24 int offset; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // The language we fall back upon when all else fails. | 27 // The language we fall back upon when all else fails. |
| 28 const wchar_t kFallbackLanguage[] = L"en-us"; | 28 const wchar_t kFallbackLanguage[] = L"en-us"; |
| 29 const int kFallbackLanguageOffset = IDS_L10N_OFFSET_EN_US; | 29 const int kFallbackLanguageOffset = IDS_L10N_OFFSET_EN_US; |
| 30 | 30 |
| 31 // http://tools.ietf.org/html/rfc5646 Section 2.3.3 | |
| 32 const std::wstring::size_type kScriptSubtagLength = 4; | |
| 33 | |
| 34 // A sorted array of language identifiers (and their offsets) for which | 31 // A sorted array of language identifiers (and their offsets) for which |
| 35 // translations are available. The contents of the array are generated by | 32 // translations are available. The contents of the array are generated by |
| 36 // create_string_rc.py. | 33 // create_string_rc.py. |
| 37 const LangToOffset kLanguageOffsetPairs[] = { | 34 const LangToOffset kLanguageOffsetPairs[] = { |
| 38 #define HANDLE_LANGUAGE(l_, o_) { L ## #l_, o_ }, | 35 #define HANDLE_LANGUAGE(l_, o_) { L ## #l_, o_ }, |
| 39 DO_LANGUAGES | 36 DO_LANGUAGES |
| 40 #undef HANDLE_LANGUAGE | 37 #undef HANDLE_LANGUAGE |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 // A sorted array of language identifiers that are aliases to other languages | 40 // A sorted array of language identifiers that are aliases to other languages |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 VLOG(1) << "No suitable language found for any candidates."; | 283 VLOG(1) << "No suitable language found for any candidates."; |
| 287 | 284 |
| 288 // Our fallback is "en-us" | 285 // Our fallback is "en-us" |
| 289 matched_candidate_.assign(&kFallbackLanguage[0], | 286 matched_candidate_.assign(&kFallbackLanguage[0], |
| 290 arraysize(kFallbackLanguage) - 1); | 287 arraysize(kFallbackLanguage) - 1); |
| 291 offset_ = kFallbackLanguageOffset; | 288 offset_ = kFallbackLanguageOffset; |
| 292 } | 289 } |
| 293 } | 290 } |
| 294 | 291 |
| 295 } // namespace installer | 292 } // namespace installer |
| OLD | NEW |