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 17 matching lines...) Expand all Loading... |
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/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/base/ui_base_paths.h" | 32 #include "ui/base/ui_base_paths.h" |
33 | 33 |
34 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
35 #include "ui/base/l10n/l10n_util_android.h" | 35 #include "ui/base/l10n/l10n_util_android.h" |
36 #endif | 36 #endif |
37 | 37 |
38 #if defined(OS_LINUX) | 38 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
39 #include <glib.h> | 39 #include <glib.h> |
40 #endif | 40 #endif |
41 | 41 |
42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
43 #include "ui/base/l10n/l10n_util_win.h" | 43 #include "ui/base/l10n/l10n_util_win.h" |
44 #endif // OS_WIN | 44 #endif // OS_WIN |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 static const char* const kAcceptLanguageList[] = { | 48 static const char* const kAcceptLanguageList[] = { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 // On ChromeOS, use the application locale preference. | 446 // On ChromeOS, use the application locale preference. |
447 if (!pref_locale.empty()) | 447 if (!pref_locale.empty()) |
448 candidates.push_back(pref_locale); | 448 candidates.push_back(pref_locale); |
449 | 449 |
450 #elif defined(OS_ANDROID) | 450 #elif defined(OS_ANDROID) |
451 | 451 |
452 // On Android, query java.util.Locale for the default locale. | 452 // On Android, query java.util.Locale for the default locale. |
453 candidates.push_back(GetDefaultLocale()); | 453 candidates.push_back(GetDefaultLocale()); |
454 | 454 |
455 #elif defined(OS_LINUX) | 455 #elif defined(OS_POSIX) |
456 // If we're on a different Linux system, we have glib. | 456 // If we're on a different Linux system, we have glib. |
457 | 457 |
458 // GLib implements correct environment variable parsing with | 458 // GLib implements correct environment variable parsing with |
459 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. | 459 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. |
460 // We used to use our custom parsing code along with ICU for this purpose. | 460 // We used to use our custom parsing code along with ICU for this purpose. |
461 // If we have a port that does not depend on GTK, we have to | 461 // If we have a port that does not depend on GTK, we have to |
462 // restore our custom code for that port. | 462 // restore our custom code for that port. |
463 const char* const* languages = g_get_language_names(); | 463 const char* const* languages = g_get_language_names(); |
464 DCHECK(languages); // A valid pointer is guaranteed. | 464 DCHECK(languages); // A valid pointer is guaranteed. |
465 DCHECK(*languages); // At least one entry, "C", is guaranteed. | 465 DCHECK(*languages); // At least one entry, "C", is guaranteed. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 853 } |
854 | 854 |
855 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { | 855 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { |
856 int width = 0; | 856 int width = 0; |
857 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); | 857 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); |
858 DCHECK_GT(width, 0); | 858 DCHECK_GT(width, 0); |
859 return width; | 859 return width; |
860 } | 860 } |
861 | 861 |
862 } // namespace l10n_util | 862 } // namespace l10n_util |
OLD | NEW |