Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: ui/base/l10n/l10n_util.h

Issue 100303003: Move more uses of string16 to specify base:: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/ime/text_input_client.h ('k') | ui/base/l10n/l10n_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // This method returns the display name of the locale code in |display_locale|. 49 // This method returns the display name of the locale code in |display_locale|.
50 50
51 // For example, for |locale| = "fr" and |display_locale| = "en", 51 // For example, for |locale| = "fr" and |display_locale| = "en",
52 // it returns "French". To get the display name of 52 // it returns "French". To get the display name of
53 // |locale| in the UI language of Chrome, |display_locale| can be 53 // |locale| in the UI language of Chrome, |display_locale| can be
54 // set to the return value of g_browser_process->GetApplicationLocale() 54 // set to the return value of g_browser_process->GetApplicationLocale()
55 // in the UI thread. 55 // in the UI thread.
56 // If |is_for_ui| is true, U+200F is appended so that it can be 56 // If |is_for_ui| is true, U+200F is appended so that it can be
57 // rendered properly in a RTL Chrome. 57 // rendered properly in a RTL Chrome.
58 UI_EXPORT string16 GetDisplayNameForLocale(const std::string& locale, 58 UI_EXPORT base::string16 GetDisplayNameForLocale(
59 const std::string& display_locale, 59 const std::string& locale,
60 bool is_for_ui); 60 const std::string& display_locale,
61 bool is_for_ui);
61 62
62 // Returns the display name of the |country_code| in |display_locale|. 63 // Returns the display name of the |country_code| in |display_locale|.
63 UI_EXPORT string16 GetDisplayNameForCountry(const std::string& country_code, 64 UI_EXPORT base::string16 GetDisplayNameForCountry(
64 const std::string& display_locale); 65 const std::string& country_code,
66 const std::string& display_locale);
65 67
66 // Converts all - into _, to be consistent with ICU and file system names. 68 // Converts all - into _, to be consistent with ICU and file system names.
67 UI_EXPORT std::string NormalizeLocale(const std::string& locale); 69 UI_EXPORT std::string NormalizeLocale(const std::string& locale);
68 70
69 // Produce a vector of parent locales for given locale. 71 // Produce a vector of parent locales for given locale.
70 // It includes the current locale in the result. 72 // It includes the current locale in the result.
71 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. 73 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr.
72 UI_EXPORT void GetParentLocales(const std::string& current_locale, 74 UI_EXPORT void GetParentLocales(const std::string& current_locale,
73 std::vector<std::string>* parent_locales); 75 std::vector<std::string>* parent_locales);
74 76
75 // Checks if a string is plausibly a syntactically-valid locale string, 77 // Checks if a string is plausibly a syntactically-valid locale string,
76 // for cases where we want the valid input to be a locale string such as 78 // for cases where we want the valid input to be a locale string such as
77 // 'en', 'pt-BR', 'fil', 'es-419', 'zh-Hans-CN', 'i-klingon' or 79 // 'en', 'pt-BR', 'fil', 'es-419', 'zh-Hans-CN', 'i-klingon' or
78 // 'de_DE@collation=phonebook', but we don't want to limit it to 80 // 'de_DE@collation=phonebook', but we don't want to limit it to
79 // locales that Chrome actually knows about, so 'xx-YY' should be 81 // locales that Chrome actually knows about, so 'xx-YY' should be
80 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not. 82 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not.
81 // Case-insensitive. Based on BCP 47, see: 83 // Case-insensitive. Based on BCP 47, see:
82 // http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers 84 // http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
83 UI_EXPORT bool IsValidLocaleSyntax(const std::string& locale); 85 UI_EXPORT bool IsValidLocaleSyntax(const std::string& locale);
84 86
85 // 87 //
86 // Mac Note: See l10n_util_mac.h for some NSString versions and other support. 88 // Mac Note: See l10n_util_mac.h for some NSString versions and other support.
87 // 89 //
88 90
89 // Pulls resource string from the string bundle and returns it. 91 // Pulls resource string from the string bundle and returns it.
90 UI_EXPORT std::string GetStringUTF8(int message_id); 92 UI_EXPORT std::string GetStringUTF8(int message_id);
91 UI_EXPORT string16 GetStringUTF16(int message_id); 93 UI_EXPORT base::string16 GetStringUTF16(int message_id);
92 94
93 // Get a resource string and replace $i with replacements[i] for all 95 // Get a resource string and replace $i with replacements[i] for all
94 // i < replacements.size(). Additionally, $$ is replaced by $. 96 // i < replacements.size(). Additionally, $$ is replaced by $.
95 // If non-NULL |offsets| will be replaced with the start points of the replaced 97 // If non-NULL |offsets| will be replaced with the start points of the replaced
96 // strings. 98 // strings.
97 UI_EXPORT string16 GetStringFUTF16(int message_id, 99 UI_EXPORT base::string16 GetStringFUTF16(
98 const std::vector<string16>& replacements, 100 int message_id,
99 std::vector<size_t>* offsets); 101 const std::vector<base::string16>& replacements,
102 std::vector<size_t>* offsets);
100 103
101 // Convenience wrappers for the above. 104 // Convenience wrappers for the above.
102 UI_EXPORT string16 GetStringFUTF16(int message_id, 105 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
103 const string16& a); 106 const base::string16& a);
104 UI_EXPORT string16 GetStringFUTF16(int message_id, 107 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
105 const string16& a, 108 const base::string16& a,
106 const string16& b); 109 const base::string16& b);
107 UI_EXPORT string16 GetStringFUTF16(int message_id, 110 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
108 const string16& a, 111 const base::string16& a,
109 const string16& b, 112 const base::string16& b,
110 const string16& c); 113 const base::string16& c);
111 UI_EXPORT string16 GetStringFUTF16(int message_id, 114 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
112 const string16& a, 115 const base::string16& a,
113 const string16& b, 116 const base::string16& b,
114 const string16& c, 117 const base::string16& c,
115 const string16& d); 118 const base::string16& d);
116 UI_EXPORT string16 GetStringFUTF16(int message_id, 119 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
117 const string16& a, 120 const base::string16& a,
118 const string16& b, 121 const base::string16& b,
119 const string16& c, 122 const base::string16& c,
120 const string16& d, 123 const base::string16& d,
121 const string16& e); 124 const base::string16& e);
122 UI_EXPORT std::string GetStringFUTF8(int message_id, 125 UI_EXPORT std::string GetStringFUTF8(int message_id,
123 const string16& a); 126 const base::string16& a);
124 UI_EXPORT std::string GetStringFUTF8(int message_id, 127 UI_EXPORT std::string GetStringFUTF8(int message_id,
125 const string16& a, 128 const base::string16& a,
126 const string16& b); 129 const base::string16& b);
127 UI_EXPORT std::string GetStringFUTF8(int message_id, 130 UI_EXPORT std::string GetStringFUTF8(int message_id,
128 const string16& a, 131 const base::string16& a,
129 const string16& b, 132 const base::string16& b,
130 const string16& c); 133 const base::string16& c);
131 UI_EXPORT std::string GetStringFUTF8(int message_id, 134 UI_EXPORT std::string GetStringFUTF8(int message_id,
132 const string16& a, 135 const base::string16& a,
133 const string16& b, 136 const base::string16& b,
134 const string16& c, 137 const base::string16& c,
135 const string16& d); 138 const base::string16& d);
136 139
137 // Variants that return the offset(s) of the replaced parameters. The 140 // Variants that return the offset(s) of the replaced parameters. The
138 // vector based version returns offsets ordered by parameter. For example if 141 // vector based version returns offsets ordered by parameter. For example if
139 // invoked with a and b offsets[0] gives the offset for a and offsets[1] the 142 // invoked with a and b offsets[0] gives the offset for a and offsets[1] the
140 // offset of b regardless of where the parameters end up in the string. 143 // offset of b regardless of where the parameters end up in the string.
141 UI_EXPORT string16 GetStringFUTF16(int message_id, 144 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
142 const string16& a, 145 const base::string16& a,
143 size_t* offset); 146 size_t* offset);
144 UI_EXPORT string16 GetStringFUTF16(int message_id, 147 UI_EXPORT base::string16 GetStringFUTF16(int message_id,
145 const string16& a, 148 const base::string16& a,
146 const string16& b, 149 const base::string16& b,
147 std::vector<size_t>* offsets); 150 std::vector<size_t>* offsets);
148 151
149 // Convenience functions to get a string with a single number as a parameter. 152 // Convenience functions to get a string with a single number as a parameter.
150 UI_EXPORT string16 GetStringFUTF16Int(int message_id, int a); 153 UI_EXPORT base::string16 GetStringFUTF16Int(int message_id, int a);
151 string16 GetStringFUTF16Int(int message_id, int64 a); 154 base::string16 GetStringFUTF16Int(int message_id, int64 a);
152 155
153 // Get a resource string using |number| to decide which of |message_ids| should 156 // Get a resource string using |number| to decide which of |message_ids| should
154 // be used. |message_ids| must be size 6 and in order: default, singular, zero, 157 // be used. |message_ids| must be size 6 and in order: default, singular, zero,
155 // two, few, many. 158 // two, few, many.
156 UI_EXPORT string16 GetPluralStringFUTF16(const std::vector<int>& message_ids, 159 UI_EXPORT base::string16 GetPluralStringFUTF16(
157 int number); 160 const std::vector<int>& message_ids,
161 int number);
158 UI_EXPORT std::string GetPluralStringFUTF8(const std::vector<int>& message_ids, 162 UI_EXPORT std::string GetPluralStringFUTF8(const std::vector<int>& message_ids,
159 int number); 163 int number);
160 164
161 // In place sorting of string16 strings using collation rules for |locale|. 165 // In place sorting of base::string16 strings using collation rules for |locale| .
162 UI_EXPORT void SortStrings16(const std::string& locale, 166 UI_EXPORT void SortStrings16(const std::string& locale,
163 std::vector<string16>* strings); 167 std::vector<base::string16>* strings);
164 168
165 // Returns a vector of available locale codes. E.g., a vector containing 169 // Returns a vector of available locale codes. E.g., a vector containing
166 // en-US, es, fr, fi, pt-PT, pt-BR, etc. 170 // en-US, es, fr, fi, pt-PT, pt-BR, etc.
167 UI_EXPORT const std::vector<std::string>& GetAvailableLocales(); 171 UI_EXPORT const std::vector<std::string>& GetAvailableLocales();
168 172
169 // Returns a vector of locale codes usable for accept-languages. 173 // Returns a vector of locale codes usable for accept-languages.
170 UI_EXPORT void GetAcceptLanguagesForLocale( 174 UI_EXPORT void GetAcceptLanguagesForLocale(
171 const std::string& display_locale, 175 const std::string& display_locale,
172 std::vector<std::string>* locale_codes); 176 std::vector<std::string>* locale_codes);
173 177
174 // Returns the preferred size of the contents view of a window based on 178 // Returns the preferred size of the contents view of a window based on
175 // designer given constraints which might dependent on the language used. 179 // designer given constraints which might dependent on the language used.
176 UI_EXPORT int GetLocalizedContentsWidthInPixels(int pixel_resource_id); 180 UI_EXPORT int GetLocalizedContentsWidthInPixels(int pixel_resource_id);
177 181
178 } // namespace l10n_util 182 } // namespace l10n_util
179 183
180 #endif // UI_BASE_L10N_L10N_UTIL_H_ 184 #endif // UI_BASE_L10N_L10N_UTIL_H_
OLDNEW
« no previous file with comments | « ui/base/ime/text_input_client.h ('k') | ui/base/l10n/l10n_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698