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 // This file contains utility functions for dealing with localized | 5 // This file contains utility functions for dealing with localized |
6 // content. | 6 // content. |
7 | 7 |
8 #ifndef UI_BASE_L10N_L10N_UTIL_H_ | 8 #ifndef UI_BASE_L10N_L10N_UTIL_H_ |
9 #define UI_BASE_L10N_L10N_UTIL_H_ | 9 #define UI_BASE_L10N_L10N_UTIL_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "ui/base/ui_base_export.h" | 15 #include "ui/base/ui_base_export.h" |
16 | 16 |
17 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
18 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
19 #endif // OS_MACOSX | 19 #endif // OS_MACOSX |
20 | 20 |
21 namespace l10n_util { | 21 namespace l10n_util { |
22 | 22 |
23 // The same as base::i18n::GetCanonicalLocale(const char*), but takes | 23 // The same as base::i18n::GetCanonicalLocale(const char*), but takes |
24 // std::string as an argument. | 24 // std::string as an argument. |
25 UI_BASE_EXPORT std::string GetCanonicalLocale(const std::string& locale); | 25 UI_BASE_EXPORT std::string GetCanonicalLocale(const std::string& locale); |
26 | 26 |
| 27 // Takes normalized locale as |locale|. Returns language part (before '-'). |
| 28 UI_BASE_EXPORT std::string GetLanguage(const std::string& locale); |
| 29 |
27 // This method translates a generic locale name to one of the locally defined | 30 // This method translates a generic locale name to one of the locally defined |
28 // ones. This method returns true if it succeeds. | 31 // ones. This method returns true if it succeeds. |
29 UI_BASE_EXPORT bool CheckAndResolveLocale(const std::string& locale, | 32 UI_BASE_EXPORT bool CheckAndResolveLocale(const std::string& locale, |
30 std::string* resolved_locale); | 33 std::string* resolved_locale); |
31 | 34 |
32 // This method is responsible for determining the locale as defined below. In | 35 // This method is responsible for determining the locale as defined below. In |
33 // nearly all cases you shouldn't call this, rather use GetApplicationLocale | 36 // nearly all cases you shouldn't call this, rather use GetApplicationLocale |
34 // defined on browser_process. | 37 // defined on browser_process. |
35 // | 38 // |
36 // Returns the locale used by the Application. First we use the value from the | 39 // Returns the locale used by the Application. First we use the value from the |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 181 |
179 // Returns a vector of locale codes usable for accept-languages. | 182 // Returns a vector of locale codes usable for accept-languages. |
180 UI_BASE_EXPORT void GetAcceptLanguagesForLocale( | 183 UI_BASE_EXPORT void GetAcceptLanguagesForLocale( |
181 const std::string& display_locale, | 184 const std::string& display_locale, |
182 std::vector<std::string>* locale_codes); | 185 std::vector<std::string>* locale_codes); |
183 | 186 |
184 // Returns the preferred size of the contents view of a window based on | 187 // Returns the preferred size of the contents view of a window based on |
185 // designer given constraints which might dependent on the language used. | 188 // designer given constraints which might dependent on the language used. |
186 UI_BASE_EXPORT int GetLocalizedContentsWidthInPixels(int pixel_resource_id); | 189 UI_BASE_EXPORT int GetLocalizedContentsWidthInPixels(int pixel_resource_id); |
187 | 190 |
| 191 UI_BASE_EXPORT const char* const* GetAcceptLanguageListForTesting(); |
| 192 |
| 193 UI_BASE_EXPORT size_t GetAcceptLanguageListSizeForTesting(); |
| 194 |
188 } // namespace l10n_util | 195 } // namespace l10n_util |
189 | 196 |
190 #endif // UI_BASE_L10N_L10N_UTIL_H_ | 197 #endif // UI_BASE_L10N_L10N_UTIL_H_ |
OLD | NEW |