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

Side by Side Diff: ui/base/l10n/l10n_util.cc

Issue 878723002: Upgrade ICU to 54.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add en-GB display name test Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « build/secondary/third_party/icu/BUILD.gn ('k') | ui/base/l10n/l10n_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/base/l10n/l10n_util.h" 5 #include "ui/base/l10n/l10n_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <iterator> 9 #include <iterator>
10 #include <string> 10 #include <string>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 "zh-CN", // Chinese (Simplified) 184 "zh-CN", // Chinese (Simplified)
185 "zh-TW", // Chinese (Traditional) 185 "zh-TW", // Chinese (Traditional)
186 "zu", // Zulu 186 "zu", // Zulu
187 }; 187 };
188 188
189 // Returns true if |locale_name| has an alias in the ICU data file. 189 // Returns true if |locale_name| has an alias in the ICU data file.
190 bool IsDuplicateName(const std::string& locale_name) { 190 bool IsDuplicateName(const std::string& locale_name) {
191 static const char* const kDuplicateNames[] = { 191 static const char* const kDuplicateNames[] = {
192 "en", 192 "en",
193 "en_001", 193 "en_001",
194 "pt", 194 "pt", // pt-BR and pt-PT are used.
195 "zh", 195 "zh",
196 "zh_hans_cn", 196 "zh_hans_cn",
197 "zh_hant_hk", 197 "zh_hant_hk",
198 "zh_hant_mo", 198 "zh_hant_mo",
199 "zh_hans_sg", 199 "zh_hans_sg",
200 "zh_hant_tw" 200 "zh_hant_tw"
201 }; 201 };
202 202
203 // Skip all 'es_RR'. Currently, we use 'es' for es-ES (Spanish in Spain). 203 // Skip all the es_Foo other than es_419 for now.
204 // 'es-419' (Spanish in Latin America) is not available in ICU so that it 204 if (StartsWithASCII(locale_name, "es_", false))
205 // has to be added manually in GetAvailableLocales(). 205 return !EndsWith(locale_name, "419", true);
206 if (LowerCaseEqualsASCII(locale_name.substr(0, 3), "es_")) 206
207 return true;
208 for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) { 207 for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) {
209 if (base::strcasecmp(kDuplicateNames[i], locale_name.c_str()) == 0) 208 if (base::strcasecmp(kDuplicateNames[i], locale_name.c_str()) == 0)
210 return true; 209 return true;
211 } 210 }
212 return false; 211 return false;
213 } 212 }
214 213
215 // We added 30+ minimally populated locales with only a few entries 214 // We added 30+ minimally populated locales with only a few entries
216 // (exemplar character set, script, writing direction and its own 215 // (exemplar character set, script, writing direction and its own
217 // lanaguage name). These locales have to be distinguished from the 216 // lanaguage name). These locales have to be distinguished from the
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 289
291 // Map the Chinese locale names over to zh-CN and zh-TW. 290 // Map the Chinese locale names over to zh-CN and zh-TW.
292 if (LowerCaseEqualsASCII(locale_name, "zh-hans")) { 291 if (LowerCaseEqualsASCII(locale_name, "zh-hans")) {
293 locale_name = "zh-CN"; 292 locale_name = "zh-CN";
294 } else if (LowerCaseEqualsASCII(locale_name, "zh-hant")) { 293 } else if (LowerCaseEqualsASCII(locale_name, "zh-hant")) {
295 locale_name = "zh-TW"; 294 locale_name = "zh-TW";
296 } 295 }
297 locales->push_back(locale_name); 296 locales->push_back(locale_name);
298 } 297 }
299 298
300 // Manually add 'es-419' to the list. See the comment in IsDuplicateName().
301 locales->push_back("es-419");
302 return locales; 299 return locales;
303 } 300 }
304 }; 301 };
305 302
306 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits> 303 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits>
307 g_available_locales = LAZY_INSTANCE_INITIALIZER; 304 g_available_locales = LAZY_INSTANCE_INITIALIZER;
308 305
309 } // namespace 306 } // namespace
310 307
311 namespace l10n_util { 308 namespace l10n_util {
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 872
876 const char* const* GetAcceptLanguageListForTesting() { 873 const char* const* GetAcceptLanguageListForTesting() {
877 return kAcceptLanguageList; 874 return kAcceptLanguageList;
878 } 875 }
879 876
880 size_t GetAcceptLanguageListSizeForTesting() { 877 size_t GetAcceptLanguageListSizeForTesting() {
881 return arraysize(kAcceptLanguageList); 878 return arraysize(kAcceptLanguageList);
882 } 879 }
883 880
884 } // namespace l10n_util 881 } // namespace l10n_util
OLDNEW
« no previous file with comments | « build/secondary/third_party/icu/BUILD.gn ('k') | ui/base/l10n/l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698