OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(USE_X11) | |
8 #include <glib/gutils.h> | |
9 #endif | |
10 | |
11 #include <algorithm> | 7 #include <algorithm> |
12 #include <cstdlib> | 8 #include <cstdlib> |
13 #include <iterator> | 9 #include <iterator> |
14 | 10 |
15 #include "base/command_line.h" | 11 #include "base/command_line.h" |
16 #include "base/file_util.h" | 12 #include "base/file_util.h" |
17 #include "base/i18n/file_util_icu.h" | 13 #include "base/i18n/file_util_icu.h" |
18 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
19 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
20 #include "base/path_service.h" | 16 #include "base/path_service.h" |
21 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
22 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
23 #include "base/string_split.h" | 19 #include "base/string_split.h" |
24 #include "base/sys_string_conversions.h" | 20 #include "base/sys_string_conversions.h" |
25 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
26 #include "build/build_config.h" | 22 #include "build/build_config.h" |
27 #include "ui/base/l10n/l10n_util_collator.h" | 23 #include "ui/base/l10n/l10n_util_collator.h" |
28 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/base/ui_base_paths.h" | 25 #include "ui/base/ui_base_paths.h" |
30 #include "unicode/rbbi.h" | 26 #include "unicode/rbbi.h" |
31 #include "unicode/uloc.h" | 27 #include "unicode/uloc.h" |
32 | 28 |
| 29 #if defined(TOOLKIT_GTK) |
| 30 #include <glib.h> |
| 31 #endif |
| 32 |
33 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
34 #include "ui/base/l10n/l10n_util_win.h" | 34 #include "ui/base/l10n/l10n_util_win.h" |
35 #endif // OS_WIN | 35 #endif // OS_WIN |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 static const char* const kAcceptLanguageList[] = { | 39 static const char* const kAcceptLanguageList[] = { |
40 "af", // Afrikaans | 40 "af", // Afrikaans |
41 "am", // Amharic | 41 "am", // Amharic |
42 "ar", // Arabic | 42 "ar", // Arabic |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // On ChromeOS, use the application locale preference. | 403 // On ChromeOS, use the application locale preference. |
404 if (!pref_locale.empty()) | 404 if (!pref_locale.empty()) |
405 candidates.push_back(pref_locale); | 405 candidates.push_back(pref_locale); |
406 | 406 |
407 #elif defined(OS_ANDROID) | 407 #elif defined(OS_ANDROID) |
408 | 408 |
409 // TODO(jcivelli): use the application locale preference for now. | 409 // TODO(jcivelli): use the application locale preference for now. |
410 if (!pref_locale.empty()) | 410 if (!pref_locale.empty()) |
411 candidates.push_back(pref_locale); | 411 candidates.push_back(pref_locale); |
412 | 412 |
413 #elif !defined(OS_MACOSX) | 413 #elif defined(TOOLKIT_GTK) |
414 | 414 |
415 // GLib implements correct environment variable parsing with | 415 // GLib implements correct environment variable parsing with |
416 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. | 416 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. |
417 // We used to use our custom parsing code along with ICU for this purpose. | 417 // We used to use our custom parsing code along with ICU for this purpose. |
418 // If we have a port that does not depend on GTK, we have to | 418 // If we have a port that does not depend on GTK, we have to |
419 // restore our custom code for that port. | 419 // restore our custom code for that port. |
420 const char* const* languages = g_get_language_names(); | 420 const char* const* languages = g_get_language_names(); |
421 DCHECK(languages); // A valid pointer is guaranteed. | 421 DCHECK(languages); // A valid pointer is guaranteed. |
422 DCHECK(*languages); // At least one entry, "C", is guaranteed. | 422 DCHECK(*languages); // At least one entry, "C", is guaranteed. |
423 | 423 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { | 818 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { |
819 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) | 819 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) |
820 // TODO(jungshik) : Put them at the of the list with language codes | 820 // TODO(jungshik) : Put them at the of the list with language codes |
821 // enclosed by brackets instead of skipping. | 821 // enclosed by brackets instead of skipping. |
822 continue; | 822 continue; |
823 locale_codes->push_back(kAcceptLanguageList[i]); | 823 locale_codes->push_back(kAcceptLanguageList[i]); |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
827 } // namespace l10n_util | 827 } // namespace l10n_util |
OLD | NEW |