| 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 15 matching lines...) Expand all Loading... |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "third_party/icu/source/common/unicode/rbbi.h" | 28 #include "third_party/icu/source/common/unicode/rbbi.h" |
| 29 #include "third_party/icu/source/common/unicode/uloc.h" | 29 #include "third_party/icu/source/common/unicode/uloc.h" |
| 30 #include "ui/base/l10n/l10n_util_collator.h" | 30 #include "ui/base/l10n/l10n_util_collator.h" |
| 31 #include "ui/base/l10n/l10n_util_plurals.h" | 31 #include "ui/base/l10n/l10n_util_plurals.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 33 #include "ui/base/ui_base_paths.h" | 33 #include "ui/base/ui_base_paths.h" |
| 34 | 34 |
| 35 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
| 36 #include "base/android/locale_utils.h" |
| 36 #include "ui/base/l10n/l10n_util_android.h" | 37 #include "ui/base/l10n/l10n_util_android.h" |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 #if defined(USE_GLIB) | 40 #if defined(USE_GLIB) |
| 40 #include <glib.h> | 41 #include <glib.h> |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 44 #include "ui/base/l10n/l10n_util_win.h" | 45 #include "ui/base/l10n/l10n_util_win.h" |
| 45 #endif // OS_WIN | 46 #endif // OS_WIN |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 std::transform(languages.begin(), languages.end(), | 441 std::transform(languages.begin(), languages.end(), |
| 441 std::back_inserter(candidates), &GetCanonicalLocale); | 442 std::back_inserter(candidates), &GetCanonicalLocale); |
| 442 } else { | 443 } else { |
| 443 // If no override was set, defer to ICU | 444 // If no override was set, defer to ICU |
| 444 candidates.push_back(base::i18n::GetConfiguredLocale()); | 445 candidates.push_back(base::i18n::GetConfiguredLocale()); |
| 445 } | 446 } |
| 446 | 447 |
| 447 #elif defined(OS_ANDROID) | 448 #elif defined(OS_ANDROID) |
| 448 | 449 |
| 449 // On Android, query java.util.Locale for the default locale. | 450 // On Android, query java.util.Locale for the default locale. |
| 450 candidates.push_back(GetDefaultLocale()); | 451 candidates.push_back(base::android::GetDefaultLocale()); |
| 451 | 452 |
| 452 #elif defined(USE_GLIB) && !defined(OS_CHROMEOS) | 453 #elif defined(USE_GLIB) && !defined(OS_CHROMEOS) |
| 453 | 454 |
| 454 // GLib implements correct environment variable parsing with | 455 // GLib implements correct environment variable parsing with |
| 455 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. | 456 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. |
| 456 // We used to use our custom parsing code along with ICU for this purpose. | 457 // We used to use our custom parsing code along with ICU for this purpose. |
| 457 // If we have a port that does not depend on GTK, we have to | 458 // If we have a port that does not depend on GTK, we have to |
| 458 // restore our custom code for that port. | 459 // restore our custom code for that port. |
| 459 const char* const* languages = g_get_language_names(); | 460 const char* const* languages = g_get_language_names(); |
| 460 DCHECK(languages); // A valid pointer is guaranteed. | 461 DCHECK(languages); // A valid pointer is guaranteed. |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 876 |
| 876 const char* const* GetAcceptLanguageListForTesting() { | 877 const char* const* GetAcceptLanguageListForTesting() { |
| 877 return kAcceptLanguageList; | 878 return kAcceptLanguageList; |
| 878 } | 879 } |
| 879 | 880 |
| 880 size_t GetAcceptLanguageListSizeForTesting() { | 881 size_t GetAcceptLanguageListSizeForTesting() { |
| 881 return arraysize(kAcceptLanguageList); | 882 return arraysize(kAcceptLanguageList); |
| 882 } | 883 } |
| 883 | 884 |
| 884 } // namespace l10n_util | 885 } // namespace l10n_util |
| OLD | NEW |