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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 if (!base::StartsWithASCII(locale_code, "zh-Han", true)) { | 542 if (!base::StartsWithASCII(locale_code, "zh-Han", true)) { |
543 display_name = GetDisplayNameForLocale(locale_code, display_locale); | 543 display_name = GetDisplayNameForLocale(locale_code, display_locale); |
544 } else | 544 } else |
545 #endif | 545 #endif |
546 { | 546 { |
547 UErrorCode error = U_ZERO_ERROR; | 547 UErrorCode error = U_ZERO_ERROR; |
548 const int kBufferSize = 1024; | 548 const int kBufferSize = 1024; |
549 | 549 |
550 int actual_size = uloc_getDisplayName( | 550 int actual_size = uloc_getDisplayName( |
551 locale_code.c_str(), display_locale.c_str(), | 551 locale_code.c_str(), display_locale.c_str(), |
552 WriteInto(&display_name, kBufferSize), kBufferSize - 1, &error); | 552 base::WriteInto(&display_name, kBufferSize), kBufferSize - 1, &error); |
553 DCHECK(U_SUCCESS(error)); | 553 DCHECK(U_SUCCESS(error)); |
554 display_name.resize(actual_size); | 554 display_name.resize(actual_size); |
555 } | 555 } |
556 | 556 |
557 // Add directional markup so parentheses are properly placed. | 557 // Add directional markup so parentheses are properly placed. |
558 if (is_for_ui && base::i18n::IsRTL()) | 558 if (is_for_ui && base::i18n::IsRTL()) |
559 base::i18n::AdjustStringForLocaleDirection(&display_name); | 559 base::i18n::AdjustStringForLocaleDirection(&display_name); |
560 return display_name; | 560 return display_name; |
561 } | 561 } |
562 | 562 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 base::string16 pattern = GetStringUTF16(message_id); | 827 base::string16 pattern = GetStringUTF16(message_id); |
828 UErrorCode err = U_ZERO_ERROR; | 828 UErrorCode err = U_ZERO_ERROR; |
829 icu::MessageFormat format( | 829 icu::MessageFormat format( |
830 icu::UnicodeString(FALSE, pattern.data(), pattern.length()), err); | 830 icu::UnicodeString(FALSE, pattern.data(), pattern.length()), err); |
831 icu::UnicodeString result_unistring; | 831 icu::UnicodeString result_unistring; |
832 FormatNumberInPlural(format, number, &result_unistring, &err); | 832 FormatNumberInPlural(format, number, &result_unistring, &err); |
833 int capacity = result_unistring.length() + 1; | 833 int capacity = result_unistring.length() + 1; |
834 DCHECK_GT(capacity, 1); | 834 DCHECK_GT(capacity, 1); |
835 base::string16 result; | 835 base::string16 result; |
836 result_unistring.extract( | 836 result_unistring.extract( |
837 static_cast<UChar*>(WriteInto(&result, capacity)), capacity, err); | 837 static_cast<UChar*>(base::WriteInto(&result, capacity)), capacity, err); |
838 DCHECK(U_SUCCESS(err)); | 838 DCHECK(U_SUCCESS(err)); |
839 return result; | 839 return result; |
840 } | 840 } |
841 | 841 |
842 std::string GetPluralStringFUTF8(int message_id, int number) { | 842 std::string GetPluralStringFUTF8(int message_id, int number) { |
843 return base::UTF16ToUTF8(GetPluralStringFUTF16(message_id, number)); | 843 return base::UTF16ToUTF8(GetPluralStringFUTF16(message_id, number)); |
844 } | 844 } |
845 | 845 |
846 void SortStrings16(const std::string& locale, | 846 void SortStrings16(const std::string& locale, |
847 std::vector<base::string16>* strings) { | 847 std::vector<base::string16>* strings) { |
(...skipping 25 matching lines...) Expand all Loading... |
873 | 873 |
874 const char* const* GetAcceptLanguageListForTesting() { | 874 const char* const* GetAcceptLanguageListForTesting() { |
875 return kAcceptLanguageList; | 875 return kAcceptLanguageList; |
876 } | 876 } |
877 | 877 |
878 size_t GetAcceptLanguageListSizeForTesting() { | 878 size_t GetAcceptLanguageListSizeForTesting() { |
879 return arraysize(kAcceptLanguageList); | 879 return arraysize(kAcceptLanguageList); |
880 } | 880 } |
881 | 881 |
882 } // namespace l10n_util | 882 } // namespace l10n_util |
OLD | NEW |