| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 } | 817 } |
| 818 | 818 |
| 819 base::string16 GetStringFUTF16Int(int message_id, int a) { | 819 base::string16 GetStringFUTF16Int(int message_id, int a) { |
| 820 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::IntToString(a))); | 820 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::IntToString(a))); |
| 821 } | 821 } |
| 822 | 822 |
| 823 base::string16 GetStringFUTF16Int(int message_id, int64 a) { | 823 base::string16 GetStringFUTF16Int(int message_id, int64 a) { |
| 824 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a))); | 824 return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a))); |
| 825 } | 825 } |
| 826 | 826 |
| 827 // Specialization of operator() method for base::string16 version. | |
| 828 template <> | |
| 829 bool StringComparator<base::string16>::operator()(const base::string16& lhs, | |
| 830 const base::string16& rhs) { | |
| 831 // If we can not get collator instance for specified locale, just do simple | |
| 832 // string compare. | |
| 833 if (!collator_) | |
| 834 return lhs < rhs; | |
| 835 return base::i18n::CompareString16WithCollator(collator_, lhs, rhs) == | |
| 836 UCOL_LESS; | |
| 837 }; | |
| 838 | |
| 839 base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, | 827 base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, |
| 840 int number) { | 828 int number) { |
| 841 scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids); | 829 scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids); |
| 842 DCHECK(format); | 830 DCHECK(format); |
| 843 | 831 |
| 844 UErrorCode err = U_ZERO_ERROR; | 832 UErrorCode err = U_ZERO_ERROR; |
| 845 icu::UnicodeString result_files_string = format->format(number, err); | 833 icu::UnicodeString result_files_string = format->format(number, err); |
| 846 int capacity = result_files_string.length() + 1; | 834 int capacity = result_files_string.length() + 1; |
| 847 DCHECK_GT(capacity, 1); | 835 DCHECK_GT(capacity, 1); |
| 848 base::string16 result; | 836 base::string16 result; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 875 |
| 888 const char* const* GetAcceptLanguageListForTesting() { | 876 const char* const* GetAcceptLanguageListForTesting() { |
| 889 return kAcceptLanguageList; | 877 return kAcceptLanguageList; |
| 890 } | 878 } |
| 891 | 879 |
| 892 size_t GetAcceptLanguageListSizeForTesting() { | 880 size_t GetAcceptLanguageListSizeForTesting() { |
| 893 return arraysize(kAcceptLanguageList); | 881 return arraysize(kAcceptLanguageList); |
| 894 } | 882 } |
| 895 | 883 |
| 896 } // namespace l10n_util | 884 } // namespace l10n_util |
| OLD | NEW |