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

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: Created 6 years, 7 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
« base/i18n/rtl.h ('K') | « 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 bool CheckAndResolveLocale(const std::string& locale, 315 bool CheckAndResolveLocale(const std::string& locale,
315 std::string* resolved_locale) { 316 std::string* resolved_locale) {
316 #if defined(OS_MACOSX) 317 #if defined(OS_MACOSX)
317 NOTIMPLEMENTED(); 318 NOTIMPLEMENTED();
318 return false; 319 return false;
319 #else 320 #else
320 if (IsLocaleAvailable(locale)) { 321 if (IsLocaleAvailable(locale)) {
321 *resolved_locale = locale; 322 *resolved_locale = locale;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // GLib implements correct environment variable parsing with 457 // GLib implements correct environment variable parsing with
457 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. 458 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
458 // We used to use our custom parsing code along with ICU for this purpose. 459 // We used to use our custom parsing code along with ICU for this purpose.
459 // If we have a port that does not depend on GTK, we have to 460 // If we have a port that does not depend on GTK, we have to
460 // restore our custom code for that port. 461 // restore our custom code for that port.
461 const char* const* languages = g_get_language_names(); 462 const char* const* languages = g_get_language_names();
462 DCHECK(languages); // A valid pointer is guaranteed. 463 DCHECK(languages); // A valid pointer is guaranteed.
463 DCHECK(*languages); // At least one entry, "C", is guaranteed. 464 DCHECK(*languages); // At least one entry, "C", is guaranteed.
464 465
465 for (; *languages != NULL; ++languages) { 466 for (; *languages != NULL; ++languages) {
466 candidates.push_back(base::i18n::GetCanonicalLocale(*languages)); 467 candidates.push_back(GetCanonicalLocale(*languages));
467 } 468 }
468 469
469 #else 470 #else
470 471
471 // By default, use the application locale preference. This applies to ChromeOS 472 // By default, use the application locale preference. This applies to ChromeOS
472 // and linux systems without glib. 473 // and linux systems without glib.
473 if (!pref_locale.empty()) 474 if (!pref_locale.empty())
474 candidates.push_back(pref_locale); 475 candidates.push_back(pref_locale);
475 476
476 #endif 477 #endif
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 881 }
881 882
882 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { 883 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) {
883 int width = 0; 884 int width = 0;
884 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); 885 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width);
885 DCHECK_GT(width, 0); 886 DCHECK_GT(width, 0);
886 return width; 887 return width;
887 } 888 }
888 889
889 } // namespace l10n_util 890 } // namespace l10n_util
OLDNEW
« base/i18n/rtl.h ('K') | « ui/base/l10n/l10n_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698