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