| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/common/l10n_util.h" | 7 #include "chrome/common/l10n_util.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 bool IsLocaleAvailable(const std::wstring& locale, | 122 bool IsLocaleAvailable(const std::wstring& locale, |
| 123 const std::wstring& locale_path) { | 123 const std::wstring& locale_path) { |
| 124 std::wstring test_locale = locale; | 124 std::wstring test_locale = locale; |
| 125 // If locale has any illegal characters in it, we don't want to try to | 125 // If locale has any illegal characters in it, we don't want to try to |
| 126 // load it because it may be pointing outside the locale data file directory. | 126 // load it because it may be pointing outside the locale data file directory. |
| 127 file_util::ReplaceIllegalCharacters(&test_locale, ' '); | 127 file_util::ReplaceIllegalCharacters(&test_locale, ' '); |
| 128 if (test_locale != locale) | 128 if (test_locale != locale) |
| 129 return false; | 129 return false; |
| 130 | 130 |
| 131 if (!l10n_util::IsLocaleSupportedByOS(locale)) |
| 132 return false; |
| 133 |
| 131 FilePath test_path = FilePath::FromWStringHack(locale_path) | 134 FilePath test_path = FilePath::FromWStringHack(locale_path) |
| 132 .Append(FilePath::FromWStringHack(locale)) | 135 .Append(FilePath::FromWStringHack(locale)) |
| 133 .ReplaceExtension(kLocaleFileExtension); | 136 .ReplaceExtension(kLocaleFileExtension); |
| 134 return file_util::PathExists(test_path) && SetICUDefaultLocale(locale); | 137 return file_util::PathExists(test_path) && SetICUDefaultLocale(locale); |
| 135 } | 138 } |
| 136 | 139 |
| 137 bool CheckAndResolveLocale(const std::wstring& locale, | 140 bool CheckAndResolveLocale(const std::wstring& locale, |
| 138 const std::wstring& locale_path, | 141 const std::wstring& locale_path, |
| 139 std::wstring* resolved_locale) { | 142 std::wstring* resolved_locale) { |
| 140 if (IsLocaleAvailable(locale, locale_path)) { | 143 if (IsLocaleAvailable(locale, locale_path)) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 661 |
| 659 const std::vector<std::string>& GetAvailableLocales() { | 662 const std::vector<std::string>& GetAvailableLocales() { |
| 660 static std::vector<std::string> locales; | 663 static std::vector<std::string> locales; |
| 661 if (locales.empty()) { | 664 if (locales.empty()) { |
| 662 int num_locales = uloc_countAvailable(); | 665 int num_locales = uloc_countAvailable(); |
| 663 for (int i = 0; i < num_locales; ++i) { | 666 for (int i = 0; i < num_locales; ++i) { |
| 664 std::string locale_name = uloc_getAvailable(i); | 667 std::string locale_name = uloc_getAvailable(i); |
| 665 // Filter out the names that have aliases. | 668 // Filter out the names that have aliases. |
| 666 if (IsDuplicateName(locale_name)) | 669 if (IsDuplicateName(locale_name)) |
| 667 continue; | 670 continue; |
| 671 if (!IsLocaleSupportedByOS(ASCIIToWide(locale_name))) |
| 672 continue; |
| 668 // Normalize underscores to hyphens because that's what our locale files | 673 // Normalize underscores to hyphens because that's what our locale files |
| 669 // use. | 674 // use. |
| 670 std::replace(locale_name.begin(), locale_name.end(), '_', '-'); | 675 std::replace(locale_name.begin(), locale_name.end(), '_', '-'); |
| 671 | 676 |
| 672 // Map the Chinese locale names over to zh-CN and zh-TW. | 677 // Map the Chinese locale names over to zh-CN and zh-TW. |
| 673 if (LowerCaseEqualsASCII(locale_name, "zh-hans")) { | 678 if (LowerCaseEqualsASCII(locale_name, "zh-hans")) { |
| 674 locale_name = "zh-CN"; | 679 locale_name = "zh-CN"; |
| 675 } else if (LowerCaseEqualsASCII(locale_name, "zh-hant")) { | 680 } else if (LowerCaseEqualsASCII(locale_name, "zh-hant")) { |
| 676 locale_name = "zh-TW"; | 681 locale_name = "zh-TW"; |
| 677 } | 682 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 } | 732 } |
| 728 | 733 |
| 729 void BiDiLineIterator::GetLogicalRun(int start, | 734 void BiDiLineIterator::GetLogicalRun(int start, |
| 730 int* end, | 735 int* end, |
| 731 UBiDiLevel* level) { | 736 UBiDiLevel* level) { |
| 732 DCHECK(bidi_ != NULL); | 737 DCHECK(bidi_ != NULL); |
| 733 ubidi_getLogicalRun(bidi_, start, end, level); | 738 ubidi_getLogicalRun(bidi_, start, end, level); |
| 734 } | 739 } |
| 735 | 740 |
| 736 } | 741 } |
| OLD | NEW |