| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 void AdjustParagraphDirectionality(base::string16* paragraph) { | 256 void AdjustParagraphDirectionality(base::string16* paragraph) { |
| 257 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 257 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 258 if (base::i18n::IsRTL() && | 258 if (base::i18n::IsRTL() && |
| 259 base::i18n::StringContainsStrongRTLChars(*paragraph)) { | 259 base::i18n::StringContainsStrongRTLChars(*paragraph)) { |
| 260 paragraph->insert(0, 1, | 260 paragraph->insert(0, 1, |
| 261 static_cast<base::char16>(base::i18n::kRightToLeftMark)); | 261 static_cast<base::char16>(base::i18n::kRightToLeftMark)); |
| 262 } | 262 } |
| 263 #endif | 263 #endif |
| 264 } | 264 } |
| 265 | 265 |
| 266 #if defined(OS_WIN) | |
| 267 std::string GetCanonicalLocale(const std::string& locale) { | |
| 268 return base::i18n::GetCanonicalLocale(locale.c_str()); | |
| 269 } | |
| 270 #endif | |
| 271 | |
| 272 struct AvailableLocalesTraits | 266 struct AvailableLocalesTraits |
| 273 : base::DefaultLazyInstanceTraits<std::vector<std::string> > { | 267 : base::DefaultLazyInstanceTraits<std::vector<std::string> > { |
| 274 static std::vector<std::string>* New(void* instance) { | 268 static std::vector<std::string>* New(void* instance) { |
| 275 std::vector<std::string>* locales = | 269 std::vector<std::string>* locales = |
| 276 base::DefaultLazyInstanceTraits<std::vector<std::string> >::New( | 270 base::DefaultLazyInstanceTraits<std::vector<std::string> >::New( |
| 277 instance); | 271 instance); |
| 278 int num_locales = uloc_countAvailable(); | 272 int num_locales = uloc_countAvailable(); |
| 279 for (int i = 0; i < num_locales; ++i) { | 273 for (int i = 0; i < num_locales; ++i) { |
| 280 std::string locale_name = uloc_getAvailable(i); | 274 std::string locale_name = uloc_getAvailable(i); |
| 281 // Filter out the names that have aliases. | 275 // Filter out the names that have aliases. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 306 } | 300 } |
| 307 }; | 301 }; |
| 308 | 302 |
| 309 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits> | 303 base::LazyInstance<std::vector<std::string>, AvailableLocalesTraits> |
| 310 g_available_locales = LAZY_INSTANCE_INITIALIZER; | 304 g_available_locales = LAZY_INSTANCE_INITIALIZER; |
| 311 | 305 |
| 312 } // namespace | 306 } // namespace |
| 313 | 307 |
| 314 namespace l10n_util { | 308 namespace l10n_util { |
| 315 | 309 |
| 310 std::string GetCanonicalLocale(const std::string& locale) { |
| 311 return base::i18n::GetCanonicalLocale(locale.c_str()); |
| 312 } |
| 313 |
| 316 bool CheckAndResolveLocale(const std::string& locale, | 314 bool CheckAndResolveLocale(const std::string& locale, |
| 317 std::string* resolved_locale) { | 315 std::string* resolved_locale) { |
| 318 #if defined(OS_MACOSX) | 316 #if defined(OS_MACOSX) |
| 319 NOTIMPLEMENTED(); | 317 NOTIMPLEMENTED(); |
| 320 return false; | 318 return false; |
| 321 #else | 319 #else |
| 322 if (IsLocaleAvailable(locale)) { | 320 if (IsLocaleAvailable(locale)) { |
| 323 *resolved_locale = locale; | 321 *resolved_locale = locale; |
| 324 return true; | 322 return true; |
| 325 } | 323 } |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 } | 880 } |
| 883 | 881 |
| 884 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { | 882 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { |
| 885 int width = 0; | 883 int width = 0; |
| 886 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); | 884 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); |
| 887 DCHECK_GT(width, 0); | 885 DCHECK_GT(width, 0); |
| 888 return width; | 886 return width; |
| 889 } | 887 } |
| 890 | 888 |
| 891 } // namespace l10n_util | 889 } // namespace l10n_util |
| OLD | NEW |