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

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

Issue 269943004: Remove base version of GetCanonicalLocale() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASE + rm gitmodules Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | no next file » | 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 }; 301 };
302 302
303 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits> 303 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits>
304 g_available_locales = LAZY_INSTANCE_INITIALIZER; 304 g_available_locales = LAZY_INSTANCE_INITIALIZER;
305 305
306 } // namespace 306 } // namespace
307 307
308 namespace l10n_util { 308 namespace l10n_util {
309 309
310 std::string GetCanonicalLocale(const std::string& locale) { 310 std::string GetCanonicalLocale(const std::string& locale) {
311 return base::i18n::GetCanonicalLocale(locale.c_str()); 311 return base::i18n::GetLocaleString(
312 icu::Locale::createCanonical(locale.c_str()));
312 } 313 }
313 314
314 std::string GetLanguage(const std::string& locale) { 315 std::string GetLanguage(const std::string& locale) {
315 const std::string::size_type hyphen_pos = locale.find('-'); 316 const std::string::size_type hyphen_pos = locale.find('-');
316 return std::string(locale, 0, hyphen_pos); 317 return std::string(locale, 0, hyphen_pos);
317 } 318 }
318 319
319 bool CheckAndResolveLocale(const std::string& locale, 320 bool CheckAndResolveLocale(const std::string& locale,
320 std::string* resolved_locale) { 321 std::string* resolved_locale) {
321 #if defined(OS_MACOSX) 322 #if defined(OS_MACOSX)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // GLib implements correct environment variable parsing with 455 // GLib implements correct environment variable parsing with
455 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. 456 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
456 // We used to use our custom parsing code along with ICU for this purpose. 457 // We used to use our custom parsing code along with ICU for this purpose.
457 // If we have a port that does not depend on GTK, we have to 458 // If we have a port that does not depend on GTK, we have to
458 // restore our custom code for that port. 459 // restore our custom code for that port.
459 const char* const* languages = g_get_language_names(); 460 const char* const* languages = g_get_language_names();
460 DCHECK(languages); // A valid pointer is guaranteed. 461 DCHECK(languages); // A valid pointer is guaranteed.
461 DCHECK(*languages); // At least one entry, "C", is guaranteed. 462 DCHECK(*languages); // At least one entry, "C", is guaranteed.
462 463
463 for (; *languages != NULL; ++languages) { 464 for (; *languages != NULL; ++languages) {
464 candidates.push_back(base::i18n::GetCanonicalLocale(*languages)); 465 candidates.push_back(GetCanonicalLocale(*languages));
465 } 466 }
466 467
467 #else 468 #else
468 469
469 // By default, use the application locale preference. This applies to ChromeOS 470 // By default, use the application locale preference. This applies to ChromeOS
470 // and linux systems without glib. 471 // and linux systems without glib.
471 if (!pref_locale.empty()) 472 if (!pref_locale.empty())
472 candidates.push_back(pref_locale); 473 candidates.push_back(pref_locale);
473 474
474 #endif 475 #endif
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 876
876 const char* const* GetAcceptLanguageListForTesting() { 877 const char* const* GetAcceptLanguageListForTesting() {
877 return kAcceptLanguageList; 878 return kAcceptLanguageList;
878 } 879 }
879 880
880 size_t GetAcceptLanguageListSizeForTesting() { 881 size_t GetAcceptLanguageListSizeForTesting() {
881 return arraysize(kAcceptLanguageList); 882 return arraysize(kAcceptLanguageList);
882 } 883 }
883 884
884 } // namespace l10n_util 885 } // namespace l10n_util
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698