| 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/public/common/unicode/rbbi.h" | 28 #include "third_party/icu/public/common/unicode/rbbi.h" |
| 29 #include "third_party/icu/public/common/unicode/uloc.h" | 29 #include "third_party/icu/public/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_LINUX) || defined(OS_BSD) |
| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 458 |
| 459 // On ChromeOS, use the application locale preference. | 459 // On ChromeOS, use the application locale preference. |
| 460 if (!pref_locale.empty()) | 460 if (!pref_locale.empty()) |
| 461 candidates.push_back(pref_locale); | 461 candidates.push_back(pref_locale); |
| 462 | 462 |
| 463 #elif defined(OS_ANDROID) | 463 #elif defined(OS_ANDROID) |
| 464 | 464 |
| 465 // On Android, query java.util.Locale for the default locale. | 465 // On Android, query java.util.Locale for the default locale. |
| 466 candidates.push_back(GetDefaultLocale()); | 466 candidates.push_back(GetDefaultLocale()); |
| 467 | 467 |
| 468 #elif defined(OS_LINUX) | 468 #elif defined(OS_LINUX) || defined(OS_BSD) |
| 469 // If we're on a different Linux system, we have glib. | 469 // If we're on a different Linux system, we have glib. |
| 470 | 470 |
| 471 // GLib implements correct environment variable parsing with | 471 // GLib implements correct environment variable parsing with |
| 472 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. | 472 // the precedence order: LANGUAGE, LC_ALL, LC_MESSAGES and LANG. |
| 473 // We used to use our custom parsing code along with ICU for this purpose. | 473 // We used to use our custom parsing code along with ICU for this purpose. |
| 474 // If we have a port that does not depend on GTK, we have to | 474 // If we have a port that does not depend on GTK, we have to |
| 475 // restore our custom code for that port. | 475 // restore our custom code for that port. |
| 476 const char* const* languages = g_get_language_names(); | 476 const char* const* languages = g_get_language_names(); |
| 477 DCHECK(languages); // A valid pointer is guaranteed. | 477 DCHECK(languages); // A valid pointer is guaranteed. |
| 478 DCHECK(*languages); // At least one entry, "C", is guaranteed. | 478 DCHECK(*languages); // At least one entry, "C", is guaranteed. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 852 } |
| 853 | 853 |
| 854 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { | 854 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { |
| 855 int width = 0; | 855 int width = 0; |
| 856 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); | 856 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); |
| 857 DCHECK_GT(width, 0); | 857 DCHECK_GT(width, 0); |
| 858 return width; | 858 return width; |
| 859 } | 859 } |
| 860 | 860 |
| 861 } // namespace l10n_util | 861 } // namespace l10n_util |
| OLD | NEW |