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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 "pt", // pt-BR and pt-PT are used. | 194 "pt", // pt-BR and pt-PT are used. |
195 "zh", | 195 "zh", |
196 "zh_hans_cn", | 196 "zh_hans_cn", |
197 "zh_hant_hk", | 197 "zh_hant_hk", |
198 "zh_hant_mo", | 198 "zh_hant_mo", |
199 "zh_hans_sg", | 199 "zh_hans_sg", |
200 "zh_hant_tw" | 200 "zh_hant_tw" |
201 }; | 201 }; |
202 | 202 |
203 // Skip all the es_Foo other than es_419 for now. | 203 // Skip all the es_Foo other than es_419 for now. |
204 if (StartsWithASCII(locale_name, "es_", false)) | 204 if (base::StartsWithASCII(locale_name, "es_", false)) |
205 return !EndsWith(locale_name, "419", true); | 205 return !EndsWith(locale_name, "419", true); |
206 | 206 |
207 for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) { | 207 for (size_t i = 0; i < arraysize(kDuplicateNames); ++i) { |
208 if (base::strcasecmp(kDuplicateNames[i], locale_name.c_str()) == 0) | 208 if (base::strcasecmp(kDuplicateNames[i], locale_name.c_str()) == 0) |
209 return true; | 209 return true; |
210 } | 210 } |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 // We added 30+ minimally populated locales with only a few entries | 214 // We added 30+ minimally populated locales with only a few entries |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 else if (locale_code == "mo") | 532 else if (locale_code == "mo") |
533 locale_code = "ro-MD"; | 533 locale_code = "ro-MD"; |
534 | 534 |
535 base::string16 display_name; | 535 base::string16 display_name; |
536 #if defined(OS_ANDROID) | 536 #if defined(OS_ANDROID) |
537 // Use Java API to get locale display name so that we can remove most of | 537 // Use Java API to get locale display name so that we can remove most of |
538 // the lang data from icu data to reduce binary size, except for zh-Hans and | 538 // the lang data from icu data to reduce binary size, except for zh-Hans and |
539 // zh-Hant because the current Android Java API doesn't support scripts. | 539 // zh-Hant because the current Android Java API doesn't support scripts. |
540 // TODO(wangxianzhu): remove the special handling of zh-Hans and zh-Hant once | 540 // TODO(wangxianzhu): remove the special handling of zh-Hans and zh-Hant once |
541 // Android Java API supports scripts. | 541 // Android Java API supports scripts. |
542 if (!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 WriteInto(&display_name, kBufferSize), kBufferSize - 1, &error); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |