| 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 #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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |