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

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

Issue 7569005: Rename UI_API to UI_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months 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/l10n/l10n_font_util.h ('k') | ui/base/l10n/l10n_util_collator.h » ('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) 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 // 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 #pragma once 10 #pragma once
11 11
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "ui/ui_api.h" 17 #include "ui/base/ui_export.h"
18 18
19 #if defined(OS_MACOSX) 19 #if defined(OS_MACOSX)
20 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
21 #endif // OS_MACOSX 21 #endif // OS_MACOSX
22 22
23 namespace l10n_util { 23 namespace l10n_util {
24 24
25 // This method is responsible for determining the locale as defined below. In 25 // This method is responsible for determining the locale as defined below. In
26 // nearly all cases you shouldn't call this, rather use GetApplicationLocale 26 // nearly all cases you shouldn't call this, rather use GetApplicationLocale
27 // defined on browser_process. 27 // defined on browser_process.
28 // 28 //
29 // Returns the locale used by the Application. First we use the value from the 29 // Returns the locale used by the Application. First we use the value from the
30 // command line (--lang), second we try the value in the prefs file (passed in 30 // command line (--lang), second we try the value in the prefs file (passed in
31 // as |pref_locale|), finally, we fall back on the system locale. We only return 31 // as |pref_locale|), finally, we fall back on the system locale. We only return
32 // a value if there's a corresponding resource DLL for the locale. Otherwise, 32 // a value if there's a corresponding resource DLL for the locale. Otherwise,
33 // we fall back to en-us. 33 // we fall back to en-us.
34 UI_API std::string GetApplicationLocale(const std::string& pref_locale); 34 UI_EXPORT std::string GetApplicationLocale(const std::string& pref_locale);
35 35
36 // Given a locale code, return true if the OS is capable of supporting it. 36 // Given a locale code, return true if the OS is capable of supporting it.
37 // For instance, Oriya is not well supported on Windows XP and we return 37 // For instance, Oriya is not well supported on Windows XP and we return
38 // false for "or". 38 // false for "or".
39 bool IsLocaleSupportedByOS(const std::string& locale); 39 bool IsLocaleSupportedByOS(const std::string& locale);
40 40
41 // This method returns the display name of the locale code in |display_locale|. 41 // This method returns the display name of the locale code in |display_locale|.
42 42
43 // For example, for |locale| = "fr" and |display_locale| = "en", 43 // For example, for |locale| = "fr" and |display_locale| = "en",
44 // it returns "French". To get the display name of 44 // it returns "French". To get the display name of
45 // |locale| in the UI language of Chrome, |display_locale| can be 45 // |locale| in the UI language of Chrome, |display_locale| can be
46 // set to the return value of g_browser_process->GetApplicationLocale() 46 // set to the return value of g_browser_process->GetApplicationLocale()
47 // in the UI thread. 47 // in the UI thread.
48 // If |is_for_ui| is true, U+200F is appended so that it can be 48 // If |is_for_ui| is true, U+200F is appended so that it can be
49 // rendered properly in a RTL Chrome. 49 // rendered properly in a RTL Chrome.
50 UI_API string16 GetDisplayNameForLocale(const std::string& locale, 50 UI_EXPORT string16 GetDisplayNameForLocale(const std::string& locale,
51 const std::string& display_locale, 51 const std::string& display_locale,
52 bool is_for_ui); 52 bool is_for_ui);
53 53
54 // Converts all - into _, to be consistent with ICU and file system names. 54 // Converts all - into _, to be consistent with ICU and file system names.
55 UI_API std::string NormalizeLocale(const std::string& locale); 55 UI_EXPORT std::string NormalizeLocale(const std::string& locale);
56 56
57 // Produce a vector of parent locales for given locale. 57 // Produce a vector of parent locales for given locale.
58 // It includes the current locale in the result. 58 // It includes the current locale in the result.
59 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr. 59 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr.
60 UI_API void GetParentLocales(const std::string& current_locale, 60 UI_EXPORT void GetParentLocales(const std::string& current_locale,
61 std::vector<std::string>* parent_locales); 61 std::vector<std::string>* parent_locales);
62 62
63 // Checks if a string is plausibly a syntactically-valid locale string, 63 // Checks if a string is plausibly a syntactically-valid locale string,
64 // for cases where we want the valid input to be a locale string such as 64 // for cases where we want the valid input to be a locale string such as
65 // 'en', 'pt-BR', 'fil', 'es-419', 'zh-Hans-CN', 'i-klingon' or 65 // 'en', 'pt-BR', 'fil', 'es-419', 'zh-Hans-CN', 'i-klingon' or
66 // 'de_DE@collation=phonebook', but we don't want to limit it to 66 // 'de_DE@collation=phonebook', but we don't want to limit it to
67 // locales that Chrome actually knows about, so 'xx-YY' should be 67 // locales that Chrome actually knows about, so 'xx-YY' should be
68 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not. 68 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not.
69 // Case-insensitive. Based on BCP 47, see: 69 // Case-insensitive. Based on BCP 47, see:
70 // http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers 70 // http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
71 UI_API bool IsValidLocaleSyntax(const std::string& locale); 71 UI_EXPORT bool IsValidLocaleSyntax(const std::string& locale);
72 72
73 // 73 //
74 // Mac Note: See l10n_util_mac.h for some NSString versions and other support. 74 // Mac Note: See l10n_util_mac.h for some NSString versions and other support.
75 // 75 //
76 76
77 // Pulls resource string from the string bundle and returns it. 77 // Pulls resource string from the string bundle and returns it.
78 UI_API std::string GetStringUTF8(int message_id); 78 UI_EXPORT std::string GetStringUTF8(int message_id);
79 UI_API string16 GetStringUTF16(int message_id); 79 UI_EXPORT string16 GetStringUTF16(int message_id);
80 80
81 // Get a resource string and replace $1-$2-$3 with |a| and |b| 81 // Get a resource string and replace $1-$2-$3 with |a| and |b|
82 // respectively. Additionally, $$ is replaced by $. 82 // respectively. Additionally, $$ is replaced by $.
83 UI_API string16 GetStringFUTF16(int message_id, 83 UI_EXPORT string16 GetStringFUTF16(int message_id,
84 const string16& a); 84 const string16& a);
85 UI_API string16 GetStringFUTF16(int message_id, 85 UI_EXPORT string16 GetStringFUTF16(int message_id,
86 const string16& a, 86 const string16& a,
87 const string16& b); 87 const string16& b);
88 UI_API string16 GetStringFUTF16(int message_id, 88 UI_EXPORT string16 GetStringFUTF16(int message_id,
89 const string16& a, 89 const string16& a,
90 const string16& b, 90 const string16& b,
91 const string16& c); 91 const string16& c);
92 UI_API string16 GetStringFUTF16(int message_id, 92 UI_EXPORT string16 GetStringFUTF16(int message_id,
93 const string16& a, 93 const string16& a,
94 const string16& b, 94 const string16& b,
95 const string16& c, 95 const string16& c,
96 const string16& d); 96 const string16& d);
97 UI_API string16 GetStringFUTF16(int message_id, 97 UI_EXPORT string16 GetStringFUTF16(int message_id,
98 const string16& a, 98 const string16& a,
99 const string16& b, 99 const string16& b,
100 const string16& c, 100 const string16& c,
101 const string16& d, 101 const string16& d,
102 const string16& e); 102 const string16& e);
103 UI_API std::string GetStringFUTF8(int message_id, 103 UI_EXPORT std::string GetStringFUTF8(int message_id,
104 const string16& a); 104 const string16& a);
105 UI_API std::string GetStringFUTF8(int message_id, 105 UI_EXPORT std::string GetStringFUTF8(int message_id,
106 const string16& a, 106 const string16& a,
107 const string16& b); 107 const string16& b);
108 UI_API std::string GetStringFUTF8(int message_id, 108 UI_EXPORT std::string GetStringFUTF8(int message_id,
109 const string16& a, 109 const string16& a,
110 const string16& b, 110 const string16& b,
111 const string16& c); 111 const string16& c);
112 UI_API std::string GetStringFUTF8(int message_id, 112 UI_EXPORT std::string GetStringFUTF8(int message_id,
113 const string16& a, 113 const string16& a,
114 const string16& b, 114 const string16& b,
115 const string16& c, 115 const string16& c,
116 const string16& d); 116 const string16& d);
117 117
118 // Variants that return the offset(s) of the replaced parameters. The 118 // Variants that return the offset(s) of the replaced parameters. The
119 // vector based version returns offsets ordered by parameter. For example if 119 // vector based version returns offsets ordered by parameter. For example if
120 // invoked with a and b offsets[0] gives the offset for a and offsets[1] the 120 // invoked with a and b offsets[0] gives the offset for a and offsets[1] the
121 // offset of b regardless of where the parameters end up in the string. 121 // offset of b regardless of where the parameters end up in the string.
122 UI_API string16 GetStringFUTF16(int message_id, 122 UI_EXPORT string16 GetStringFUTF16(int message_id,
123 const string16& a, 123 const string16& a,
124 size_t* offset); 124 size_t* offset);
125 UI_API string16 GetStringFUTF16(int message_id, 125 UI_EXPORT string16 GetStringFUTF16(int message_id,
126 const string16& a, 126 const string16& a,
127 const string16& b, 127 const string16& b,
128 std::vector<size_t>* offsets); 128 std::vector<size_t>* offsets);
129 129
130 // Convenience functions to get a string with a single number as a parameter. 130 // Convenience functions to get a string with a single number as a parameter.
131 UI_API string16 GetStringFUTF16Int(int message_id, int a); 131 UI_EXPORT string16 GetStringFUTF16Int(int message_id, int a);
132 string16 GetStringFUTF16Int(int message_id, int64 a); 132 string16 GetStringFUTF16Int(int message_id, int64 a);
133 133
134 // Truncates the string to length characters. This breaks the string at 134 // Truncates the string to length characters. This breaks the string at
135 // the first word break before length, adding the horizontal ellipsis 135 // the first word break before length, adding the horizontal ellipsis
136 // character (unicode character 0x2026) to render ... 136 // character (unicode character 0x2026) to render ...
137 // The supplied string is returned if the string has length characters or 137 // The supplied string is returned if the string has length characters or
138 // less. 138 // less.
139 UI_API string16 TruncateString(const string16& string, size_t length); 139 UI_EXPORT string16 TruncateString(const string16& string, size_t length);
140 140
141 // In place sorting of string16 strings using collation rules for |locale|. 141 // In place sorting of string16 strings using collation rules for |locale|.
142 UI_API void SortStrings16(const std::string& locale, 142 UI_EXPORT void SortStrings16(const std::string& locale,
143 std::vector<string16>* strings); 143 std::vector<string16>* strings);
144 144
145 // Returns a vector of available locale codes. E.g., a vector containing 145 // Returns a vector of available locale codes. E.g., a vector containing
146 // en-US, es, fr, fi, pt-PT, pt-BR, etc. 146 // en-US, es, fr, fi, pt-PT, pt-BR, etc.
147 UI_API const std::vector<std::string>& GetAvailableLocales(); 147 UI_EXPORT const std::vector<std::string>& GetAvailableLocales();
148 148
149 // Returns a vector of locale codes usable for accept-languages. 149 // Returns a vector of locale codes usable for accept-languages.
150 UI_API void GetAcceptLanguagesForLocale( 150 UI_EXPORT void GetAcceptLanguagesForLocale(
151 const std::string& display_locale, 151 const std::string& display_locale,
152 std::vector<std::string>* locale_codes); 152 std::vector<std::string>* locale_codes);
153 153
154 154
155 } // namespace l10n_util 155 } // namespace l10n_util
156 156
157 #endif // UI_BASE_L10N_L10N_UTIL_H_ 157 #endif // UI_BASE_L10N_L10N_UTIL_H_
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_font_util.h ('k') | ui/base/l10n/l10n_util_collator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698