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

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

Issue 270183002: Move IsStringUTF8/ASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor nit 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
« no previous file with comments | « sync/util/cryptographer_unittest.cc ('k') | webkit/common/database/database_identifier.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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 bool IsLocaleNameTranslated(const char* locale, 498 bool IsLocaleNameTranslated(const char* locale,
499 const std::string& display_locale) { 499 const std::string& display_locale) {
500 base::string16 display_name = 500 base::string16 display_name =
501 l10n_util::GetDisplayNameForLocale(locale, display_locale, false); 501 l10n_util::GetDisplayNameForLocale(locale, display_locale, false);
502 // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not 502 // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not
503 // uloc_getDisplayName returns the actual translation or the default 503 // uloc_getDisplayName returns the actual translation or the default
504 // value (locale code), we have to rely on this hack to tell whether 504 // value (locale code), we have to rely on this hack to tell whether
505 // the translation is available or not. If ICU doesn't have a translated 505 // the translation is available or not. If ICU doesn't have a translated
506 // name for this locale, GetDisplayNameForLocale will just return the 506 // name for this locale, GetDisplayNameForLocale will just return the
507 // locale code. 507 // locale code.
508 return !IsStringASCII(display_name) || 508 return !base::IsStringASCII(display_name) ||
509 base::UTF16ToASCII(display_name) != locale; 509 base::UTF16ToASCII(display_name) != locale;
510 } 510 }
511 511
512 base::string16 GetDisplayNameForLocale(const std::string& locale, 512 base::string16 GetDisplayNameForLocale(const std::string& locale,
513 const std::string& display_locale, 513 const std::string& display_locale,
514 bool is_for_ui) { 514 bool is_for_ui) {
515 std::string locale_code = locale; 515 std::string locale_code = locale;
516 // Internally, we use the language code of zh-CN and zh-TW, but we want the 516 // Internally, we use the language code of zh-CN and zh-TW, but we want the
517 // display names to be Chinese (Simplified) and Chinese (Traditional) instead 517 // display names to be Chinese (Simplified) and Chinese (Traditional) instead
518 // of Chinese (China) and Chinese (Taiwan). To do that, we pass zh-Hans 518 // of Chinese (China) and Chinese (Taiwan). To do that, we pass zh-Hans
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 880 }
881 881
882 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { 882 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) {
883 int width = 0; 883 int width = 0;
884 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); 884 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width);
885 DCHECK_GT(width, 0); 885 DCHECK_GT(width, 0);
886 return width; 886 return width;
887 } 887 }
888 888
889 } // namespace l10n_util 889 } // namespace l10n_util
OLDNEW
« no previous file with comments | « sync/util/cryptographer_unittest.cc ('k') | webkit/common/database/database_identifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698