]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
58d5dfc1 | 2 | // Name: wx/intl.h |
77ffb593 | 3 | // Purpose: Internationalization and localisation for wxWidgets |
c801d85f | 4 | // Author: Vadim Zeitlin |
849a28d0 VS |
5 | // Modified by: Michael N. Filippov <michael@idisys.iae.nsk.su> |
6 | // (2003/09/30 - plural forms support) | |
c801d85f KB |
7 | // Created: 29/01/98 |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 10 | // Licence: wxWindows licence |
c801d85f KB |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
dccce9ea VZ |
13 | #ifndef _WX_INTL_H_ |
14 | #define _WX_INTL_H_ | |
c801d85f | 15 | |
c801d85f KB |
16 | #include "wx/defs.h" |
17 | #include "wx/string.h" | |
18 | ||
b137e493 WS |
19 | // Make wxLayoutDirection enum available without need for wxUSE_INTL so wxWindow, wxApp |
20 | // and other classes are not distrubed by wxUSE_INTL | |
21 | ||
22 | enum wxLayoutDirection | |
23 | { | |
24 | wxLayout_Default, | |
25 | wxLayout_LeftToRight, | |
26 | wxLayout_RightToLeft | |
27 | }; | |
28 | ||
88ac883a VZ |
29 | #if wxUSE_INTL |
30 | ||
dccce9ea VZ |
31 | #include "wx/fontenc.h" |
32 | ||
c801d85f KB |
33 | // ============================================================================ |
34 | // global decls | |
35 | // ============================================================================ | |
36 | ||
c801d85f KB |
37 | // ---------------------------------------------------------------------------- |
38 | // macros | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
7beb59f3 | 41 | // gettext() style macros (notice that xgettext should be invoked with |
15d06954 | 42 | // --keyword="_" --keyword="wxPLURAL:1,2" options |
849a28d0 | 43 | // to extract the strings from the sources) |
687d7337 | 44 | #ifndef WXINTL_NO_GETTEXT_MACRO |
15d06954 VZ |
45 | #define _(s) wxGetTranslation(_T(s)) |
46 | #define wxPLURAL(sing, plur, n) wxGetTranslation(_T(sing), _T(plur), n) | |
687d7337 | 47 | #endif |
c801d85f | 48 | |
3c1866e8 VZ |
49 | // another one which just marks the strings for extraction, but doesn't |
50 | // perform the translation (use -kwxTRANSLATE with xgettext!) | |
b12915c1 | 51 | #define wxTRANSLATE(str) _T(str) |
3c1866e8 | 52 | |
c801d85f KB |
53 | // ---------------------------------------------------------------------------- |
54 | // forward decls | |
55 | // ---------------------------------------------------------------------------- | |
ec37df57 | 56 | |
bddd7a8d | 57 | class WXDLLIMPEXP_BASE wxLocale; |
bddd7a8d | 58 | class WXDLLIMPEXP_BASE wxLanguageInfoArray; |
64764f50 | 59 | class wxMsgCatalog; |
c801d85f KB |
60 | |
61 | // ============================================================================ | |
62 | // locale support | |
63 | // ============================================================================ | |
64 | ||
fda91381 VS |
65 | // ---------------------------------------------------------------------------- |
66 | // wxLanguage: defines all supported languages | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
41780009 | 69 | // --- --- --- generated code begins here --- --- --- |
fda91381 VS |
70 | |
71 | // This enum is generated by misc/languages/genlang.py | |
72 | // When making changes, please put them into misc/languages/langtabl.txt | |
73 | enum wxLanguage | |
74 | { | |
75 | // user's default/preffered language as got from OS: | |
58d5dfc1 | 76 | wxLANGUAGE_DEFAULT, |
fda91381 | 77 | // unknown language, if wxLocale::GetSystemLanguage fails: |
58d5dfc1 VZ |
78 | wxLANGUAGE_UNKNOWN, |
79 | ||
fda91381 VS |
80 | wxLANGUAGE_ABKHAZIAN, |
81 | wxLANGUAGE_AFAR, | |
82 | wxLANGUAGE_AFRIKAANS, | |
83 | wxLANGUAGE_ALBANIAN, | |
84 | wxLANGUAGE_AMHARIC, | |
85 | wxLANGUAGE_ARABIC, | |
86 | wxLANGUAGE_ARABIC_ALGERIA, | |
87 | wxLANGUAGE_ARABIC_BAHRAIN, | |
88 | wxLANGUAGE_ARABIC_EGYPT, | |
89 | wxLANGUAGE_ARABIC_IRAQ, | |
90 | wxLANGUAGE_ARABIC_JORDAN, | |
91 | wxLANGUAGE_ARABIC_KUWAIT, | |
92 | wxLANGUAGE_ARABIC_LEBANON, | |
93 | wxLANGUAGE_ARABIC_LIBYA, | |
94 | wxLANGUAGE_ARABIC_MOROCCO, | |
95 | wxLANGUAGE_ARABIC_OMAN, | |
96 | wxLANGUAGE_ARABIC_QATAR, | |
97 | wxLANGUAGE_ARABIC_SAUDI_ARABIA, | |
98 | wxLANGUAGE_ARABIC_SUDAN, | |
99 | wxLANGUAGE_ARABIC_SYRIA, | |
100 | wxLANGUAGE_ARABIC_TUNISIA, | |
101 | wxLANGUAGE_ARABIC_UAE, | |
102 | wxLANGUAGE_ARABIC_YEMEN, | |
103 | wxLANGUAGE_ARMENIAN, | |
104 | wxLANGUAGE_ASSAMESE, | |
105 | wxLANGUAGE_AYMARA, | |
106 | wxLANGUAGE_AZERI, | |
107 | wxLANGUAGE_AZERI_CYRILLIC, | |
108 | wxLANGUAGE_AZERI_LATIN, | |
109 | wxLANGUAGE_BASHKIR, | |
110 | wxLANGUAGE_BASQUE, | |
111 | wxLANGUAGE_BELARUSIAN, | |
112 | wxLANGUAGE_BENGALI, | |
113 | wxLANGUAGE_BHUTANI, | |
114 | wxLANGUAGE_BIHARI, | |
115 | wxLANGUAGE_BISLAMA, | |
116 | wxLANGUAGE_BRETON, | |
117 | wxLANGUAGE_BULGARIAN, | |
118 | wxLANGUAGE_BURMESE, | |
119 | wxLANGUAGE_CAMBODIAN, | |
120 | wxLANGUAGE_CATALAN, | |
121 | wxLANGUAGE_CHINESE, | |
122 | wxLANGUAGE_CHINESE_SIMPLIFIED, | |
123 | wxLANGUAGE_CHINESE_TRADITIONAL, | |
124 | wxLANGUAGE_CHINESE_HONGKONG, | |
125 | wxLANGUAGE_CHINESE_MACAU, | |
126 | wxLANGUAGE_CHINESE_SINGAPORE, | |
127 | wxLANGUAGE_CHINESE_TAIWAN, | |
128 | wxLANGUAGE_CORSICAN, | |
129 | wxLANGUAGE_CROATIAN, | |
130 | wxLANGUAGE_CZECH, | |
131 | wxLANGUAGE_DANISH, | |
132 | wxLANGUAGE_DUTCH, | |
133 | wxLANGUAGE_DUTCH_BELGIAN, | |
134 | wxLANGUAGE_ENGLISH, | |
135 | wxLANGUAGE_ENGLISH_UK, | |
136 | wxLANGUAGE_ENGLISH_US, | |
137 | wxLANGUAGE_ENGLISH_AUSTRALIA, | |
138 | wxLANGUAGE_ENGLISH_BELIZE, | |
139 | wxLANGUAGE_ENGLISH_BOTSWANA, | |
140 | wxLANGUAGE_ENGLISH_CANADA, | |
141 | wxLANGUAGE_ENGLISH_CARIBBEAN, | |
142 | wxLANGUAGE_ENGLISH_DENMARK, | |
143 | wxLANGUAGE_ENGLISH_EIRE, | |
144 | wxLANGUAGE_ENGLISH_JAMAICA, | |
145 | wxLANGUAGE_ENGLISH_NEW_ZEALAND, | |
146 | wxLANGUAGE_ENGLISH_PHILIPPINES, | |
147 | wxLANGUAGE_ENGLISH_SOUTH_AFRICA, | |
148 | wxLANGUAGE_ENGLISH_TRINIDAD, | |
149 | wxLANGUAGE_ENGLISH_ZIMBABWE, | |
150 | wxLANGUAGE_ESPERANTO, | |
151 | wxLANGUAGE_ESTONIAN, | |
152 | wxLANGUAGE_FAEROESE, | |
153 | wxLANGUAGE_FARSI, | |
154 | wxLANGUAGE_FIJI, | |
155 | wxLANGUAGE_FINNISH, | |
156 | wxLANGUAGE_FRENCH, | |
157 | wxLANGUAGE_FRENCH_BELGIAN, | |
158 | wxLANGUAGE_FRENCH_CANADIAN, | |
159 | wxLANGUAGE_FRENCH_LUXEMBOURG, | |
160 | wxLANGUAGE_FRENCH_MONACO, | |
161 | wxLANGUAGE_FRENCH_SWISS, | |
162 | wxLANGUAGE_FRISIAN, | |
163 | wxLANGUAGE_GALICIAN, | |
164 | wxLANGUAGE_GEORGIAN, | |
165 | wxLANGUAGE_GERMAN, | |
166 | wxLANGUAGE_GERMAN_AUSTRIAN, | |
167 | wxLANGUAGE_GERMAN_BELGIUM, | |
168 | wxLANGUAGE_GERMAN_LIECHTENSTEIN, | |
169 | wxLANGUAGE_GERMAN_LUXEMBOURG, | |
170 | wxLANGUAGE_GERMAN_SWISS, | |
171 | wxLANGUAGE_GREEK, | |
172 | wxLANGUAGE_GREENLANDIC, | |
173 | wxLANGUAGE_GUARANI, | |
174 | wxLANGUAGE_GUJARATI, | |
175 | wxLANGUAGE_HAUSA, | |
176 | wxLANGUAGE_HEBREW, | |
177 | wxLANGUAGE_HINDI, | |
178 | wxLANGUAGE_HUNGARIAN, | |
179 | wxLANGUAGE_ICELANDIC, | |
180 | wxLANGUAGE_INDONESIAN, | |
181 | wxLANGUAGE_INTERLINGUA, | |
182 | wxLANGUAGE_INTERLINGUE, | |
183 | wxLANGUAGE_INUKTITUT, | |
184 | wxLANGUAGE_INUPIAK, | |
185 | wxLANGUAGE_IRISH, | |
186 | wxLANGUAGE_ITALIAN, | |
187 | wxLANGUAGE_ITALIAN_SWISS, | |
188 | wxLANGUAGE_JAPANESE, | |
189 | wxLANGUAGE_JAVANESE, | |
190 | wxLANGUAGE_KANNADA, | |
191 | wxLANGUAGE_KASHMIRI, | |
192 | wxLANGUAGE_KASHMIRI_INDIA, | |
193 | wxLANGUAGE_KAZAKH, | |
194 | wxLANGUAGE_KERNEWEK, | |
195 | wxLANGUAGE_KINYARWANDA, | |
196 | wxLANGUAGE_KIRGHIZ, | |
197 | wxLANGUAGE_KIRUNDI, | |
198 | wxLANGUAGE_KONKANI, | |
199 | wxLANGUAGE_KOREAN, | |
200 | wxLANGUAGE_KURDISH, | |
201 | wxLANGUAGE_LAOTHIAN, | |
202 | wxLANGUAGE_LATIN, | |
203 | wxLANGUAGE_LATVIAN, | |
204 | wxLANGUAGE_LINGALA, | |
205 | wxLANGUAGE_LITHUANIAN, | |
206 | wxLANGUAGE_MACEDONIAN, | |
207 | wxLANGUAGE_MALAGASY, | |
208 | wxLANGUAGE_MALAY, | |
209 | wxLANGUAGE_MALAYALAM, | |
210 | wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, | |
211 | wxLANGUAGE_MALAY_MALAYSIA, | |
212 | wxLANGUAGE_MALTESE, | |
213 | wxLANGUAGE_MANIPURI, | |
214 | wxLANGUAGE_MAORI, | |
215 | wxLANGUAGE_MARATHI, | |
216 | wxLANGUAGE_MOLDAVIAN, | |
217 | wxLANGUAGE_MONGOLIAN, | |
218 | wxLANGUAGE_NAURU, | |
219 | wxLANGUAGE_NEPALI, | |
220 | wxLANGUAGE_NEPALI_INDIA, | |
221 | wxLANGUAGE_NORWEGIAN_BOKMAL, | |
222 | wxLANGUAGE_NORWEGIAN_NYNORSK, | |
223 | wxLANGUAGE_OCCITAN, | |
224 | wxLANGUAGE_ORIYA, | |
225 | wxLANGUAGE_OROMO, | |
226 | wxLANGUAGE_PASHTO, | |
227 | wxLANGUAGE_POLISH, | |
228 | wxLANGUAGE_PORTUGUESE, | |
229 | wxLANGUAGE_PORTUGUESE_BRAZILIAN, | |
230 | wxLANGUAGE_PUNJABI, | |
231 | wxLANGUAGE_QUECHUA, | |
232 | wxLANGUAGE_RHAETO_ROMANCE, | |
233 | wxLANGUAGE_ROMANIAN, | |
234 | wxLANGUAGE_RUSSIAN, | |
235 | wxLANGUAGE_RUSSIAN_UKRAINE, | |
236 | wxLANGUAGE_SAMOAN, | |
237 | wxLANGUAGE_SANGHO, | |
238 | wxLANGUAGE_SANSKRIT, | |
239 | wxLANGUAGE_SCOTS_GAELIC, | |
240 | wxLANGUAGE_SERBIAN, | |
241 | wxLANGUAGE_SERBIAN_CYRILLIC, | |
242 | wxLANGUAGE_SERBIAN_LATIN, | |
243 | wxLANGUAGE_SERBO_CROATIAN, | |
244 | wxLANGUAGE_SESOTHO, | |
245 | wxLANGUAGE_SETSWANA, | |
246 | wxLANGUAGE_SHONA, | |
247 | wxLANGUAGE_SINDHI, | |
248 | wxLANGUAGE_SINHALESE, | |
249 | wxLANGUAGE_SISWATI, | |
250 | wxLANGUAGE_SLOVAK, | |
251 | wxLANGUAGE_SLOVENIAN, | |
252 | wxLANGUAGE_SOMALI, | |
253 | wxLANGUAGE_SPANISH, | |
254 | wxLANGUAGE_SPANISH_ARGENTINA, | |
255 | wxLANGUAGE_SPANISH_BOLIVIA, | |
256 | wxLANGUAGE_SPANISH_CHILE, | |
257 | wxLANGUAGE_SPANISH_COLOMBIA, | |
258 | wxLANGUAGE_SPANISH_COSTA_RICA, | |
259 | wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, | |
260 | wxLANGUAGE_SPANISH_ECUADOR, | |
261 | wxLANGUAGE_SPANISH_EL_SALVADOR, | |
262 | wxLANGUAGE_SPANISH_GUATEMALA, | |
263 | wxLANGUAGE_SPANISH_HONDURAS, | |
264 | wxLANGUAGE_SPANISH_MEXICAN, | |
265 | wxLANGUAGE_SPANISH_MODERN, | |
266 | wxLANGUAGE_SPANISH_NICARAGUA, | |
267 | wxLANGUAGE_SPANISH_PANAMA, | |
268 | wxLANGUAGE_SPANISH_PARAGUAY, | |
269 | wxLANGUAGE_SPANISH_PERU, | |
270 | wxLANGUAGE_SPANISH_PUERTO_RICO, | |
271 | wxLANGUAGE_SPANISH_URUGUAY, | |
272 | wxLANGUAGE_SPANISH_US, | |
273 | wxLANGUAGE_SPANISH_VENEZUELA, | |
274 | wxLANGUAGE_SUNDANESE, | |
275 | wxLANGUAGE_SWAHILI, | |
276 | wxLANGUAGE_SWEDISH, | |
277 | wxLANGUAGE_SWEDISH_FINLAND, | |
278 | wxLANGUAGE_TAGALOG, | |
279 | wxLANGUAGE_TAJIK, | |
280 | wxLANGUAGE_TAMIL, | |
281 | wxLANGUAGE_TATAR, | |
282 | wxLANGUAGE_TELUGU, | |
283 | wxLANGUAGE_THAI, | |
284 | wxLANGUAGE_TIBETAN, | |
285 | wxLANGUAGE_TIGRINYA, | |
286 | wxLANGUAGE_TONGA, | |
287 | wxLANGUAGE_TSONGA, | |
288 | wxLANGUAGE_TURKISH, | |
289 | wxLANGUAGE_TURKMEN, | |
290 | wxLANGUAGE_TWI, | |
291 | wxLANGUAGE_UIGHUR, | |
292 | wxLANGUAGE_UKRAINIAN, | |
293 | wxLANGUAGE_URDU, | |
294 | wxLANGUAGE_URDU_INDIA, | |
295 | wxLANGUAGE_URDU_PAKISTAN, | |
296 | wxLANGUAGE_UZBEK, | |
297 | wxLANGUAGE_UZBEK_CYRILLIC, | |
298 | wxLANGUAGE_UZBEK_LATIN, | |
299 | wxLANGUAGE_VIETNAMESE, | |
300 | wxLANGUAGE_VOLAPUK, | |
301 | wxLANGUAGE_WELSH, | |
302 | wxLANGUAGE_WOLOF, | |
303 | wxLANGUAGE_XHOSA, | |
304 | wxLANGUAGE_YIDDISH, | |
305 | wxLANGUAGE_YORUBA, | |
306 | wxLANGUAGE_ZHUANG, | |
307 | wxLANGUAGE_ZULU, | |
308 | ||
309 | // for custom, user-defined languages: | |
310 | wxLANGUAGE_USER_DEFINED | |
311 | }; | |
312 | ||
41780009 VS |
313 | // --- --- --- generated code ends here --- --- --- |
314 | ||
fda91381 VS |
315 | // ---------------------------------------------------------------------------- |
316 | // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc. | |
317 | // translation information | |
318 | // ---------------------------------------------------------------------------- | |
319 | ||
bddd7a8d | 320 | struct WXDLLIMPEXP_BASE wxLanguageInfo |
fda91381 VS |
321 | { |
322 | int Language; // wxLanguage id | |
323 | wxString CanonicalName; // Canonical name, e.g. fr_FR | |
324 | #ifdef __WIN32__ | |
dccce9ea VZ |
325 | wxUint32 WinLang, // Win32 language identifiers |
326 | WinSublang; | |
327 | #endif // __WIN32__ | |
fda91381 | 328 | wxString Description; // human-readable name of the language |
978af864 | 329 | wxLayoutDirection LayoutDirection; |
fda91381 VS |
330 | }; |
331 | ||
f2a139ad VZ |
332 | // ---------------------------------------------------------------------------- |
333 | // wxLocaleCategory: the category of locale settings | |
334 | // ---------------------------------------------------------------------------- | |
335 | ||
336 | enum wxLocaleCategory | |
337 | { | |
338 | // (any) numbers | |
339 | wxLOCALE_CAT_NUMBER, | |
340 | ||
341 | // date/time | |
342 | wxLOCALE_CAT_DATE, | |
343 | ||
344 | // monetary value | |
345 | wxLOCALE_CAT_MONEY, | |
346 | ||
347 | wxLOCALE_CAT_MAX | |
348 | }; | |
349 | ||
350 | // ---------------------------------------------------------------------------- | |
351 | // wxLocaleInfo: the items understood by wxLocale::GetInfo() | |
352 | // ---------------------------------------------------------------------------- | |
353 | ||
354 | enum wxLocaleInfo | |
355 | { | |
356 | // the thounsands separator | |
357 | wxLOCALE_THOUSANDS_SEP, | |
358 | ||
359 | // the character used as decimal point | |
7d08179a | 360 | wxLOCALE_DECIMAL_POINT |
f2a139ad VZ |
361 | |
362 | }; | |
363 | ||
c801d85f KB |
364 | // ---------------------------------------------------------------------------- |
365 | // wxLocale: encapsulates all language dependent settings, including current | |
84c18814 | 366 | // message catalogs, date, time and currency formats (TODO) &c |
c801d85f | 367 | // ---------------------------------------------------------------------------- |
fda91381 VS |
368 | |
369 | enum wxLocaleInitFlags | |
370 | { | |
371 | wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo? | |
372 | wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly? | |
373 | }; | |
374 | ||
bddd7a8d | 375 | class WXDLLIMPEXP_BASE wxLocale |
c801d85f KB |
376 | { |
377 | public: | |
84c18814 VZ |
378 | // ctor & dtor |
379 | // ----------- | |
380 | ||
381 | // call Init() if you use this ctor | |
ea8f6fc7 VZ |
382 | wxLocale() { DoCommonInit(); } |
383 | ||
84c18814 | 384 | // the ctor has a side effect of changing current locale |
31b7522e VS |
385 | wxLocale(const wxString& name, // name (for messages) |
386 | const wxString& shortName = wxEmptyString, // dir prefix (for msg files) | |
387 | const wxString& locale = wxEmptyString, // locale (for setlocale) | |
ea8f6fc7 | 388 | bool bLoadDefault = true, // preload wxstd.mo? |
3103e8a9 | 389 | bool bConvertEncoding = false) // convert Win<->Unix if necessary? |
58d5dfc1 | 390 | { |
ea8f6fc7 VZ |
391 | DoCommonInit(); |
392 | ||
31b7522e | 393 | Init(name, shortName, locale, bLoadDefault, bConvertEncoding); |
fda91381 VS |
394 | } |
395 | ||
ec37df57 | 396 | wxLocale(int language, // wxLanguage id or custom language |
fda91381 | 397 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) |
ea8f6fc7 VZ |
398 | { |
399 | DoCommonInit(); | |
fda91381 | 400 | |
ea8f6fc7 VZ |
401 | Init(language, flags); |
402 | } | |
403 | ||
404 | // the same as a function (returns true on success) | |
31b7522e VS |
405 | bool Init(const wxString& name, |
406 | const wxString& shortName = wxEmptyString, | |
407 | const wxString& locale = wxEmptyString, | |
ea8f6fc7 VZ |
408 | bool bLoadDefault = true, |
409 | bool bConvertEncoding = false); | |
fda91381 | 410 | |
ea8f6fc7 | 411 | // same as second ctor (returns true on success) |
fda91381 VS |
412 | bool Init(int language = wxLANGUAGE_DEFAULT, |
413 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); | |
ec37df57 | 414 | |
84c18814 | 415 | // restores old locale |
d4a724d4 | 416 | virtual ~wxLocale(); |
58d5dfc1 | 417 | |
3103e8a9 | 418 | // Try to get user's (or OS's) preferred language setting. |
ec37df57 | 419 | // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed |
41780009 | 420 | static int GetSystemLanguage(); |
84c18814 | 421 | |
dccce9ea VZ |
422 | // get the encoding used by default for text on this system, returns |
423 | // wxFONTENCODING_SYSTEM if it couldn't be determined | |
424 | static wxFontEncoding GetSystemEncoding(); | |
425 | ||
426 | // get the string describing the system encoding, return empty string if | |
427 | // couldn't be determined | |
428 | static wxString GetSystemEncodingName(); | |
429 | ||
f2a139ad VZ |
430 | // get the values of the given locale-dependent datum: the current locale |
431 | // is used, the US default value is returned if everything else fails | |
432 | static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat); | |
433 | ||
ea8f6fc7 | 434 | // return true if the locale was set successfully |
3ca6a5f0 BP |
435 | bool IsOk() const { return m_pszOldLocale != NULL; } |
436 | ||
84c18814 | 437 | // returns locale name |
31b7522e | 438 | const wxString& GetLocale() const { return m_strLocale; } |
58d5dfc1 | 439 | |
fda91381 VS |
440 | // return current locale wxLanguage value |
441 | int GetLanguage() const { return m_language; } | |
84c18814 | 442 | |
58d5dfc1 | 443 | // return locale name to be passed to setlocale() |
fda91381 VS |
444 | wxString GetSysName() const; |
445 | ||
58d5dfc1 | 446 | // return 'canonical' name, i.e. in the form of xx[_YY], where xx is |
fda91381 VS |
447 | // language code according to ISO 639 and YY is country name |
448 | // as specified by ISO 3166. | |
449 | wxString GetCanonicalName() const { return m_strShort; } | |
58d5dfc1 | 450 | |
84c18814 VZ |
451 | // add a prefix to the catalog lookup path: the message catalog files will be |
452 | // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix | |
453 | // (in this order). | |
454 | // | |
455 | // This only applies to subsequent invocations of AddCatalog()! | |
456 | static void AddCatalogLookupPathPrefix(const wxString& prefix); | |
457 | ||
458 | // add a catalog: it's searched for in standard places (current directory | |
459 | // first, system one after), but the you may prepend additional directories to | |
460 | // the search path with AddCatalogLookupPathPrefix(). | |
461 | // | |
462 | // The loaded catalog will be used for message lookup by GetString(). | |
463 | // | |
464 | // Returns 'true' if it was successfully loaded | |
31b7522e VS |
465 | bool AddCatalog(const wxString& domain); |
466 | bool AddCatalog(const wxString& domain, | |
467 | wxLanguage msgIdLanguage, const wxString& msgIdCharset); | |
84c18814 | 468 | |
cec5ffc4 VZ |
469 | // check if the given locale is provided by OS and C run time |
470 | static bool IsAvailable(int lang); | |
471 | ||
84c18814 | 472 | // check if the given catalog is loaded |
31b7522e | 473 | bool IsLoaded(const wxString& domain) const; |
58d5dfc1 | 474 | |
14f8fa9d VZ |
475 | // Retrieve the language info struct for the given language |
476 | // | |
477 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
478 | static const wxLanguageInfo *GetLanguageInfo(int lang); | |
479 | ||
4a6e4a46 VS |
480 | // Returns language name in English or empty string if the language |
481 | // is not in database | |
482 | static wxString GetLanguageName(int lang); | |
483 | ||
9d1e1be4 VZ |
484 | // Find the language for the given locale string which may be either a |
485 | // canonical ISO 2 letter language code ("xx"), a language code followed by | |
486 | // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") | |
487 | // | |
488 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
489 | static const wxLanguageInfo *FindLanguageInfo(const wxString& locale); | |
490 | ||
fda91381 VS |
491 | // Add custom language to the list of known languages. |
492 | // Notes: 1) wxLanguageInfo contains platform-specific data | |
493 | // 2) must be called before Init to have effect | |
41780009 | 494 | static void AddLanguage(const wxLanguageInfo& info); |
84c18814 VZ |
495 | |
496 | // retrieve the translation for a string in all loaded domains unless | |
497 | // the szDomain parameter is specified (and then only this domain is | |
498 | // searched) | |
849a28d0 | 499 | // n - additional parameter for PluralFormsParser |
84c18814 VZ |
500 | // |
501 | // return original string if translation is not available | |
502 | // (in this case an error message is generated the first time | |
503 | // a string is not found; use wxLogNull to suppress it) | |
504 | // | |
505 | // domains are searched in the last to first order, i.e. catalogs | |
506 | // added later override those added before. | |
31b7522e VS |
507 | virtual const wxString& GetString(const wxString& origString, |
508 | const wxString& domain = wxEmptyString) const; | |
849a28d0 | 509 | // plural form version of the same: |
31b7522e VS |
510 | virtual const wxString& GetString(const wxString& origString, |
511 | const wxString& origString2, | |
512 | size_t n, | |
513 | const wxString& domain = wxEmptyString) const; | |
84c18814 VZ |
514 | |
515 | // Returns the current short name for the locale | |
516 | const wxString& GetName() const { return m_strShort; } | |
517 | ||
c48908df | 518 | // return the contents of .po file header |
31b7522e VS |
519 | wxString GetHeaderValue(const wxString& header, |
520 | const wxString& domain = wxEmptyString) const; | |
c48908df | 521 | |
41780009 VS |
522 | // These two methods are for internal use only. First one creates |
523 | // ms_languagesDB if it doesn't already exist, second one destroys | |
524 | // it. | |
525 | static void CreateLanguagesDB(); | |
526 | static void DestroyLanguagesDB(); | |
527 | ||
84c18814 VZ |
528 | private: |
529 | // find catalog by name in a linked list, return NULL if !found | |
31b7522e | 530 | wxMsgCatalog *FindCatalog(const wxString& domain) const; |
58d5dfc1 | 531 | |
fda91381 | 532 | // copy default table of languages from global static array to |
41780009 VS |
533 | // m_langugagesInfo, called by InitLanguagesDB |
534 | static void InitLanguagesDB(); | |
84c18814 | 535 | |
ea8f6fc7 VZ |
536 | // initialize the member fields to default values |
537 | void DoCommonInit(); | |
538 | ||
afc94fa6 VS |
539 | wxString m_strLocale, // this locale name |
540 | m_strShort; // short name for the locale | |
fda91381 | 541 | int m_language; // this locale wxLanguage value |
84c18814 | 542 | |
afc94fa6 VS |
543 | const wxChar *m_pszOldLocale; // previous locale from setlocale() |
544 | wxLocale *m_pOldLocale; // previous wxLocale | |
84c18814 | 545 | |
afc94fa6 | 546 | wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs |
58d5dfc1 | 547 | |
afc94fa6 | 548 | bool m_bConvertEncoding; |
fda91381 | 549 | |
3202d00d VS |
550 | bool m_initialized; |
551 | ||
41780009 | 552 | static wxLanguageInfoArray *ms_languagesDB; |
22f3361e VZ |
553 | |
554 | DECLARE_NO_COPY_CLASS(wxLocale) | |
c801d85f KB |
555 | }; |
556 | ||
9d8046f6 | 557 | // ---------------------------------------------------------------------------- |
a1530845 | 558 | // global functions |
9d8046f6 VZ |
559 | // ---------------------------------------------------------------------------- |
560 | ||
84c18814 | 561 | // get the current locale object (note that it may be NULL!) |
bddd7a8d | 562 | extern WXDLLIMPEXP_BASE wxLocale* wxGetLocale(); |
84c18814 VZ |
563 | |
564 | // get the translation of the string in the current locale | |
31b7522e VS |
565 | inline const wxString& wxGetTranslation(const wxString& str, |
566 | const wxString& domain = wxEmptyString) | |
9d8046f6 | 567 | { |
84c18814 | 568 | wxLocale *pLoc = wxGetLocale(); |
06c545a7 | 569 | if (pLoc) |
31b7522e | 570 | return pLoc->GetString(str, domain); |
06c545a7 | 571 | else |
31b7522e | 572 | return str; |
9d8046f6 | 573 | } |
31b7522e VS |
574 | inline const wxString& wxGetTranslation(const wxString& str1, |
575 | const wxString& str2, | |
576 | size_t n, | |
577 | const wxString& domain = wxEmptyString) | |
849a28d0 VS |
578 | { |
579 | wxLocale *pLoc = wxGetLocale(); | |
580 | if (pLoc) | |
31b7522e | 581 | return pLoc->GetString(str1, str2, n, domain); |
849a28d0 | 582 | else |
31b7522e | 583 | return n == 1 ? str1 : str2; |
849a28d0 | 584 | } |
9d8046f6 | 585 | |
88ac883a VZ |
586 | #else // !wxUSE_INTL |
587 | ||
b12915c1 VZ |
588 | // the macros should still be defined - otherwise compilation would fail |
589 | ||
ba9d03fa VS |
590 | #if !defined(WXINTL_NO_GETTEXT_MACRO) |
591 | #if !defined(_) | |
592 | #define _(s) (_T(s)) | |
593 | #endif | |
88ac883a VZ |
594 | #endif |
595 | ||
b12915c1 VZ |
596 | #define wxTRANSLATE(str) _T(str) |
597 | ||
31b7522e VS |
598 | inline const wxString& wxGetTranslation(const wxString& str, |
599 | const wxString& WXUNUSED(domain) = wxEmptyString) | |
33046a82 | 600 | { |
31b7522e | 601 | return str; |
33046a82 | 602 | } |
88ac883a VZ |
603 | |
604 | #endif // wxUSE_INTL/!wxUSE_INTL | |
605 | ||
b12915c1 VZ |
606 | // define this one just in case it occurs somewhere (instead of preferred |
607 | // wxTRANSLATE) too | |
ba9d03fa VS |
608 | #if !defined(WXINTL_NO_GETTEXT_MACRO) |
609 | #if !defined(gettext_noop) | |
610 | #define gettext_noop(str) _T(str) | |
611 | #endif | |
612 | #if !defined(N_) | |
613 | #define N_(s) _T(s) | |
614 | #endif | |
b12915c1 VZ |
615 | #endif |
616 | ||
dccce9ea | 617 | #endif // _WX_INTL_H_ |