OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 APP_L10N_UTIL_H_ | 8 #ifndef APP_L10N_UTIL_H_ |
9 #define APP_L10N_UTIL_H_ | 9 #define APP_L10N_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 // it returns "French". To get the display name of | 49 // it returns "French". To get the display name of |
50 // |locale| in the UI language of Chrome, |display_locale| can be | 50 // |locale| in the UI language of Chrome, |display_locale| can be |
51 // set to the return value of g_browser_process->GetApplicationLocale() | 51 // set to the return value of g_browser_process->GetApplicationLocale() |
52 // in the UI thread. | 52 // in the UI thread. |
53 // If |is_for_ui| is true, U+200F is appended so that it can be | 53 // If |is_for_ui| is true, U+200F is appended so that it can be |
54 // rendered properly in a RTL Chrome. | 54 // rendered properly in a RTL Chrome. |
55 string16 GetDisplayNameForLocale(const std::string& locale, | 55 string16 GetDisplayNameForLocale(const std::string& locale, |
56 const std::string& display_locale, | 56 const std::string& display_locale, |
57 bool is_for_ui); | 57 bool is_for_ui); |
58 | 58 |
59 // Converts all - into _, to be consistent with ICU and file system names. | |
60 std::string NormalizeLocale(const std::string& locale); | |
61 | |
62 // Produce a vector of parent locales for given locale. | |
63 // It includes the current locale in the result. | |
64 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. | |
65 void GetParentLocales(const std::string& current_locale, | |
66 std::vector<std::string>* parent_locales); | |
67 | |
68 // Checks if a string is plausibly a syntactically-valid locale string, | |
69 // for cases where we want the valid input to be a locale string such as | |
70 // 'en', 'pt-BR', 'fil', and 'zh-Hans-CN', but we don't want to limit it | |
jungshik at Google
2010/12/10 22:21:28
examples like 'es-419' and 'de_DE@collation=phoneb
| |
71 // to locales that Chrome actually knows about, so 'xx-YY' should be | |
72 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not. | |
73 // Case-insensitive. Based on BCP 47. | |
74 bool IsValidLocaleSyntax(const std::string& locale); | |
75 | |
59 // | 76 // |
60 // Mac Note: See l10n_util_mac.h for some NSString versions and other support. | 77 // Mac Note: See l10n_util_mac.h for some NSString versions and other support. |
61 // | 78 // |
62 | 79 |
63 // Pulls resource string from the string bundle and returns it. | 80 // Pulls resource string from the string bundle and returns it. |
64 std::wstring GetString(int message_id); | 81 std::wstring GetString(int message_id); |
65 std::string GetStringUTF8(int message_id); | 82 std::string GetStringUTF8(int message_id); |
66 string16 GetStringUTF16(int message_id); | 83 string16 GetStringUTF16(int message_id); |
67 | 84 |
68 // Get a resource string and replace $1-$2-$3 with |a| and |b| | 85 // Get a resource string and replace $1-$2-$3 with |a| and |b| |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 const std::vector<std::string>& GetAvailableLocales(); | 201 const std::vector<std::string>& GetAvailableLocales(); |
185 | 202 |
186 // Returns a vector of locale codes usable for accept-languages. | 203 // Returns a vector of locale codes usable for accept-languages. |
187 void GetAcceptLanguagesForLocale(const std::string& display_locale, | 204 void GetAcceptLanguagesForLocale(const std::string& display_locale, |
188 std::vector<std::string>* locale_codes); | 205 std::vector<std::string>* locale_codes); |
189 | 206 |
190 | 207 |
191 } // namespace l10n_util | 208 } // namespace l10n_util |
192 | 209 |
193 #endif // APP_L10N_UTIL_H_ | 210 #endif // APP_L10N_UTIL_H_ |
OLD | NEW |