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