]>
Commit | Line | Data |
---|---|---|
68bc8549 | 1 | ///////////////////////////////////////////////////////////////////////////// |
d14a1e28 RD |
2 | // Name: _intl.i |
3 | // Purpose: SWIG interface file for wxLocale and related classes | |
68bc8549 RD |
4 | // |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 1-Apr-2002 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2002 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
d14a1e28 | 13 | // Not a %module |
68bc8549 RD |
14 | |
15 | ||
16 | //--------------------------------------------------------------------------- | |
68bc8549 | 17 | |
1e4a197e | 18 | %{ |
ab897a69 | 19 | #include <locale.h> |
1e4a197e RD |
20 | %} |
21 | ||
68bc8549 | 22 | //--------------------------------------------------------------------------- |
d14a1e28 | 23 | %newgroup |
68bc8549 RD |
24 | |
25 | ||
26 | enum wxLanguage | |
27 | { | |
1e4a197e | 28 | // user's default/preffered language as got from OS: |
68bc8549 | 29 | wxLANGUAGE_DEFAULT, |
1e4a197e | 30 | // unknown language, if wxLocale::GetSystemLanguage fails: |
68bc8549 RD |
31 | wxLANGUAGE_UNKNOWN, |
32 | ||
33 | wxLANGUAGE_ABKHAZIAN, | |
34 | wxLANGUAGE_AFAR, | |
35 | wxLANGUAGE_AFRIKAANS, | |
36 | wxLANGUAGE_ALBANIAN, | |
37 | wxLANGUAGE_AMHARIC, | |
38 | wxLANGUAGE_ARABIC, | |
39 | wxLANGUAGE_ARABIC_ALGERIA, | |
40 | wxLANGUAGE_ARABIC_BAHRAIN, | |
41 | wxLANGUAGE_ARABIC_EGYPT, | |
42 | wxLANGUAGE_ARABIC_IRAQ, | |
43 | wxLANGUAGE_ARABIC_JORDAN, | |
44 | wxLANGUAGE_ARABIC_KUWAIT, | |
45 | wxLANGUAGE_ARABIC_LEBANON, | |
46 | wxLANGUAGE_ARABIC_LIBYA, | |
47 | wxLANGUAGE_ARABIC_MOROCCO, | |
48 | wxLANGUAGE_ARABIC_OMAN, | |
49 | wxLANGUAGE_ARABIC_QATAR, | |
50 | wxLANGUAGE_ARABIC_SAUDI_ARABIA, | |
51 | wxLANGUAGE_ARABIC_SUDAN, | |
52 | wxLANGUAGE_ARABIC_SYRIA, | |
53 | wxLANGUAGE_ARABIC_TUNISIA, | |
54 | wxLANGUAGE_ARABIC_UAE, | |
55 | wxLANGUAGE_ARABIC_YEMEN, | |
56 | wxLANGUAGE_ARMENIAN, | |
57 | wxLANGUAGE_ASSAMESE, | |
58 | wxLANGUAGE_AYMARA, | |
59 | wxLANGUAGE_AZERI, | |
60 | wxLANGUAGE_AZERI_CYRILLIC, | |
61 | wxLANGUAGE_AZERI_LATIN, | |
62 | wxLANGUAGE_BASHKIR, | |
63 | wxLANGUAGE_BASQUE, | |
64 | wxLANGUAGE_BELARUSIAN, | |
65 | wxLANGUAGE_BENGALI, | |
66 | wxLANGUAGE_BHUTANI, | |
67 | wxLANGUAGE_BIHARI, | |
68 | wxLANGUAGE_BISLAMA, | |
69 | wxLANGUAGE_BRETON, | |
70 | wxLANGUAGE_BULGARIAN, | |
71 | wxLANGUAGE_BURMESE, | |
72 | wxLANGUAGE_CAMBODIAN, | |
73 | wxLANGUAGE_CATALAN, | |
74 | wxLANGUAGE_CHINESE, | |
75 | wxLANGUAGE_CHINESE_SIMPLIFIED, | |
76 | wxLANGUAGE_CHINESE_TRADITIONAL, | |
77 | wxLANGUAGE_CHINESE_HONGKONG, | |
78 | wxLANGUAGE_CHINESE_MACAU, | |
79 | wxLANGUAGE_CHINESE_SINGAPORE, | |
80 | wxLANGUAGE_CHINESE_TAIWAN, | |
81 | wxLANGUAGE_CORSICAN, | |
82 | wxLANGUAGE_CROATIAN, | |
83 | wxLANGUAGE_CZECH, | |
84 | wxLANGUAGE_DANISH, | |
85 | wxLANGUAGE_DUTCH, | |
86 | wxLANGUAGE_DUTCH_BELGIAN, | |
87 | wxLANGUAGE_ENGLISH, | |
88 | wxLANGUAGE_ENGLISH_UK, | |
89 | wxLANGUAGE_ENGLISH_US, | |
90 | wxLANGUAGE_ENGLISH_AUSTRALIA, | |
91 | wxLANGUAGE_ENGLISH_BELIZE, | |
92 | wxLANGUAGE_ENGLISH_BOTSWANA, | |
93 | wxLANGUAGE_ENGLISH_CANADA, | |
94 | wxLANGUAGE_ENGLISH_CARIBBEAN, | |
95 | wxLANGUAGE_ENGLISH_DENMARK, | |
96 | wxLANGUAGE_ENGLISH_EIRE, | |
97 | wxLANGUAGE_ENGLISH_JAMAICA, | |
98 | wxLANGUAGE_ENGLISH_NEW_ZEALAND, | |
99 | wxLANGUAGE_ENGLISH_PHILIPPINES, | |
100 | wxLANGUAGE_ENGLISH_SOUTH_AFRICA, | |
101 | wxLANGUAGE_ENGLISH_TRINIDAD, | |
102 | wxLANGUAGE_ENGLISH_ZIMBABWE, | |
103 | wxLANGUAGE_ESPERANTO, | |
104 | wxLANGUAGE_ESTONIAN, | |
105 | wxLANGUAGE_FAEROESE, | |
106 | wxLANGUAGE_FARSI, | |
107 | wxLANGUAGE_FIJI, | |
108 | wxLANGUAGE_FINNISH, | |
109 | wxLANGUAGE_FRENCH, | |
110 | wxLANGUAGE_FRENCH_BELGIAN, | |
111 | wxLANGUAGE_FRENCH_CANADIAN, | |
112 | wxLANGUAGE_FRENCH_LUXEMBOURG, | |
113 | wxLANGUAGE_FRENCH_MONACO, | |
114 | wxLANGUAGE_FRENCH_SWISS, | |
115 | wxLANGUAGE_FRISIAN, | |
116 | wxLANGUAGE_GALICIAN, | |
117 | wxLANGUAGE_GEORGIAN, | |
118 | wxLANGUAGE_GERMAN, | |
119 | wxLANGUAGE_GERMAN_AUSTRIAN, | |
120 | wxLANGUAGE_GERMAN_BELGIUM, | |
121 | wxLANGUAGE_GERMAN_LIECHTENSTEIN, | |
122 | wxLANGUAGE_GERMAN_LUXEMBOURG, | |
123 | wxLANGUAGE_GERMAN_SWISS, | |
124 | wxLANGUAGE_GREEK, | |
125 | wxLANGUAGE_GREENLANDIC, | |
126 | wxLANGUAGE_GUARANI, | |
127 | wxLANGUAGE_GUJARATI, | |
128 | wxLANGUAGE_HAUSA, | |
129 | wxLANGUAGE_HEBREW, | |
130 | wxLANGUAGE_HINDI, | |
131 | wxLANGUAGE_HUNGARIAN, | |
132 | wxLANGUAGE_ICELANDIC, | |
133 | wxLANGUAGE_INDONESIAN, | |
134 | wxLANGUAGE_INTERLINGUA, | |
135 | wxLANGUAGE_INTERLINGUE, | |
136 | wxLANGUAGE_INUKTITUT, | |
137 | wxLANGUAGE_INUPIAK, | |
138 | wxLANGUAGE_IRISH, | |
139 | wxLANGUAGE_ITALIAN, | |
140 | wxLANGUAGE_ITALIAN_SWISS, | |
141 | wxLANGUAGE_JAPANESE, | |
142 | wxLANGUAGE_JAVANESE, | |
143 | wxLANGUAGE_KANNADA, | |
144 | wxLANGUAGE_KASHMIRI, | |
145 | wxLANGUAGE_KASHMIRI_INDIA, | |
146 | wxLANGUAGE_KAZAKH, | |
147 | wxLANGUAGE_KERNEWEK, | |
148 | wxLANGUAGE_KINYARWANDA, | |
149 | wxLANGUAGE_KIRGHIZ, | |
150 | wxLANGUAGE_KIRUNDI, | |
151 | wxLANGUAGE_KONKANI, | |
152 | wxLANGUAGE_KOREAN, | |
153 | wxLANGUAGE_KURDISH, | |
154 | wxLANGUAGE_LAOTHIAN, | |
155 | wxLANGUAGE_LATIN, | |
156 | wxLANGUAGE_LATVIAN, | |
157 | wxLANGUAGE_LINGALA, | |
158 | wxLANGUAGE_LITHUANIAN, | |
159 | wxLANGUAGE_MACEDONIAN, | |
160 | wxLANGUAGE_MALAGASY, | |
161 | wxLANGUAGE_MALAY, | |
162 | wxLANGUAGE_MALAYALAM, | |
163 | wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, | |
164 | wxLANGUAGE_MALAY_MALAYSIA, | |
165 | wxLANGUAGE_MALTESE, | |
166 | wxLANGUAGE_MANIPURI, | |
167 | wxLANGUAGE_MAORI, | |
168 | wxLANGUAGE_MARATHI, | |
169 | wxLANGUAGE_MOLDAVIAN, | |
170 | wxLANGUAGE_MONGOLIAN, | |
171 | wxLANGUAGE_NAURU, | |
172 | wxLANGUAGE_NEPALI, | |
173 | wxLANGUAGE_NEPALI_INDIA, | |
174 | wxLANGUAGE_NORWEGIAN_BOKMAL, | |
175 | wxLANGUAGE_NORWEGIAN_NYNORSK, | |
176 | wxLANGUAGE_OCCITAN, | |
177 | wxLANGUAGE_ORIYA, | |
178 | wxLANGUAGE_OROMO, | |
179 | wxLANGUAGE_PASHTO, | |
180 | wxLANGUAGE_POLISH, | |
181 | wxLANGUAGE_PORTUGUESE, | |
182 | wxLANGUAGE_PORTUGUESE_BRAZILIAN, | |
183 | wxLANGUAGE_PUNJABI, | |
184 | wxLANGUAGE_QUECHUA, | |
185 | wxLANGUAGE_RHAETO_ROMANCE, | |
186 | wxLANGUAGE_ROMANIAN, | |
187 | wxLANGUAGE_RUSSIAN, | |
188 | wxLANGUAGE_RUSSIAN_UKRAINE, | |
189 | wxLANGUAGE_SAMOAN, | |
190 | wxLANGUAGE_SANGHO, | |
191 | wxLANGUAGE_SANSKRIT, | |
192 | wxLANGUAGE_SCOTS_GAELIC, | |
193 | wxLANGUAGE_SERBIAN, | |
194 | wxLANGUAGE_SERBIAN_CYRILLIC, | |
195 | wxLANGUAGE_SERBIAN_LATIN, | |
196 | wxLANGUAGE_SERBO_CROATIAN, | |
197 | wxLANGUAGE_SESOTHO, | |
198 | wxLANGUAGE_SETSWANA, | |
199 | wxLANGUAGE_SHONA, | |
200 | wxLANGUAGE_SINDHI, | |
201 | wxLANGUAGE_SINHALESE, | |
202 | wxLANGUAGE_SISWATI, | |
203 | wxLANGUAGE_SLOVAK, | |
204 | wxLANGUAGE_SLOVENIAN, | |
205 | wxLANGUAGE_SOMALI, | |
206 | wxLANGUAGE_SPANISH, | |
207 | wxLANGUAGE_SPANISH_ARGENTINA, | |
208 | wxLANGUAGE_SPANISH_BOLIVIA, | |
209 | wxLANGUAGE_SPANISH_CHILE, | |
210 | wxLANGUAGE_SPANISH_COLOMBIA, | |
211 | wxLANGUAGE_SPANISH_COSTA_RICA, | |
212 | wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, | |
213 | wxLANGUAGE_SPANISH_ECUADOR, | |
214 | wxLANGUAGE_SPANISH_EL_SALVADOR, | |
215 | wxLANGUAGE_SPANISH_GUATEMALA, | |
216 | wxLANGUAGE_SPANISH_HONDURAS, | |
217 | wxLANGUAGE_SPANISH_MEXICAN, | |
218 | wxLANGUAGE_SPANISH_MODERN, | |
219 | wxLANGUAGE_SPANISH_NICARAGUA, | |
220 | wxLANGUAGE_SPANISH_PANAMA, | |
221 | wxLANGUAGE_SPANISH_PARAGUAY, | |
222 | wxLANGUAGE_SPANISH_PERU, | |
223 | wxLANGUAGE_SPANISH_PUERTO_RICO, | |
224 | wxLANGUAGE_SPANISH_URUGUAY, | |
225 | wxLANGUAGE_SPANISH_US, | |
226 | wxLANGUAGE_SPANISH_VENEZUELA, | |
227 | wxLANGUAGE_SUNDANESE, | |
228 | wxLANGUAGE_SWAHILI, | |
229 | wxLANGUAGE_SWEDISH, | |
230 | wxLANGUAGE_SWEDISH_FINLAND, | |
231 | wxLANGUAGE_TAGALOG, | |
232 | wxLANGUAGE_TAJIK, | |
233 | wxLANGUAGE_TAMIL, | |
234 | wxLANGUAGE_TATAR, | |
235 | wxLANGUAGE_TELUGU, | |
236 | wxLANGUAGE_THAI, | |
237 | wxLANGUAGE_TIBETAN, | |
238 | wxLANGUAGE_TIGRINYA, | |
239 | wxLANGUAGE_TONGA, | |
240 | wxLANGUAGE_TSONGA, | |
241 | wxLANGUAGE_TURKISH, | |
242 | wxLANGUAGE_TURKMEN, | |
243 | wxLANGUAGE_TWI, | |
244 | wxLANGUAGE_UIGHUR, | |
245 | wxLANGUAGE_UKRAINIAN, | |
246 | wxLANGUAGE_URDU, | |
247 | wxLANGUAGE_URDU_INDIA, | |
248 | wxLANGUAGE_URDU_PAKISTAN, | |
249 | wxLANGUAGE_UZBEK, | |
250 | wxLANGUAGE_UZBEK_CYRILLIC, | |
251 | wxLANGUAGE_UZBEK_LATIN, | |
252 | wxLANGUAGE_VIETNAMESE, | |
253 | wxLANGUAGE_VOLAPUK, | |
254 | wxLANGUAGE_WELSH, | |
255 | wxLANGUAGE_WOLOF, | |
256 | wxLANGUAGE_XHOSA, | |
257 | wxLANGUAGE_YIDDISH, | |
258 | wxLANGUAGE_YORUBA, | |
259 | wxLANGUAGE_ZHUANG, | |
260 | wxLANGUAGE_ZULU, | |
261 | ||
262 | // for custom, user-defined languages: | |
263 | wxLANGUAGE_USER_DEFINED | |
264 | }; | |
265 | ||
d14a1e28 RD |
266 | |
267 | //--------------------------------------------------------------------------- | |
268 | ||
269 | ||
68bc8549 RD |
270 | // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc. |
271 | // translation information | |
d14a1e28 | 272 | struct wxLanguageInfo |
68bc8549 | 273 | { |
68bc8549 RD |
274 | int Language; // wxLanguage id |
275 | wxString CanonicalName; // Canonical name, e.g. fr_FR | |
276 | wxString Description; // human-readable name of the language | |
277 | }; | |
278 | ||
279 | // wxLocaleCategory: the category of locale settings | |
280 | enum wxLocaleCategory | |
281 | { | |
282 | wxLOCALE_CAT_NUMBER, | |
283 | wxLOCALE_CAT_DATE, | |
284 | wxLOCALE_CAT_MONEY, | |
285 | wxLOCALE_CAT_MAX | |
286 | }; | |
287 | ||
288 | // wxLocaleInfo: the items understood by wxLocale::GetInfo() | |
289 | enum wxLocaleInfo | |
290 | { | |
291 | wxLOCALE_THOUSANDS_SEP, | |
292 | wxLOCALE_DECIMAL_POINT | |
293 | ||
294 | }; | |
295 | ||
296 | // wxLocale: encapsulates all language dependent settings, including current | |
297 | // message catalogs, date, time and currency formats (TODO) &c | |
298 | enum wxLocaleInitFlags | |
299 | { | |
300 | wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo? | |
301 | wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly? | |
302 | }; | |
303 | ||
d14a1e28 RD |
304 | |
305 | //--------------------------------------------------------------------------- | |
306 | ||
68bc8549 RD |
307 | class wxLocale |
308 | { | |
309 | public: | |
310 | // ctor & dtor | |
311 | // ----------- | |
2693507f RD |
312 | %extend { |
313 | wxLocale(int language = -1, | |
314 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) { | |
ab897a69 | 315 | wxLocale* loc; |
2693507f | 316 | if (language == -1) |
ab897a69 | 317 | loc = new wxLocale(); |
2693507f | 318 | else |
ab897a69 RD |
319 | loc = new wxLocale(language, flags); |
320 | // Python before 2.4 needs to have LC_NUMERIC set to "C" in order | |
321 | // for the floating point conversions and such to work right. | |
322 | %#if PY_VERSION_HEX < 0x02040000 | |
323 | setlocale(LC_NUMERIC, "C"); | |
324 | %#endif | |
325 | return loc; | |
2693507f RD |
326 | } |
327 | } | |
68bc8549 | 328 | |
68bc8549 RD |
329 | // restores old locale |
330 | ~wxLocale(); | |
331 | ||
ab897a69 RD |
332 | %extend { |
333 | bool Init1(const wxString& szName, | |
334 | const wxString& szShort = wxPyEmptyString, | |
335 | const wxString& szLocale = wxPyEmptyString, | |
336 | bool bLoadDefault = true, | |
337 | bool bConvertEncoding = false) { | |
338 | bool rc = self->Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding); | |
339 | // Python before 2.4 needs to have LC_NUMERIC set to "C" in order | |
340 | // for the floating point conversions and such to work right. | |
341 | %#if PY_VERSION_HEX < 0x02040000 | |
342 | setlocale(LC_NUMERIC, "C"); | |
343 | %#endif | |
344 | return rc; | |
345 | } | |
346 | ||
347 | bool Init2(int language = wxLANGUAGE_DEFAULT, | |
348 | int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) { | |
349 | bool rc = self->Init(language, flags); | |
350 | // Python before 2.4 needs to have LC_NUMERIC set to "C" in order | |
351 | // for the floating point conversions and such to work right. | |
352 | %#if PY_VERSION_HEX < 0x02040000 | |
353 | setlocale(LC_NUMERIC, "C"); | |
354 | %#endif | |
355 | return rc; | |
356 | } | |
357 | } | |
1e4a197e | 358 | |
ab897a69 | 359 | |
1e4a197e | 360 | |
d14a1e28 | 361 | %pythoncode { |
1e4a197e RD |
362 | def Init(self, *_args, **_kwargs): |
363 | if type(_args[0]) in [type(''), type(u'')]: | |
1fded56b | 364 | val = self.Init1(*_args, **_kwargs) |
1e4a197e | 365 | else: |
1fded56b | 366 | val = self.Init2(*_args, **_kwargs) |
1e4a197e | 367 | return val |
d14a1e28 | 368 | } |
1e4a197e | 369 | |
68bc8549 RD |
370 | // Try to get user's (or OS's) prefered language setting. |
371 | // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed | |
372 | static int GetSystemLanguage(); | |
373 | ||
374 | // get the encoding used by default for text on this system, returns | |
375 | // wxFONTENCODING_SYSTEM if it couldn't be determined | |
376 | static wxFontEncoding GetSystemEncoding(); | |
377 | ||
378 | // get the string describing the system encoding, return empty string if | |
379 | // couldn't be determined | |
380 | static wxString GetSystemEncodingName(); | |
381 | ||
382 | ||
383 | // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp | |
384 | // get the values of the given locale-dependent datum: the current locale | |
385 | // is used, the US default value is returned if everything else fails | |
386 | // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat); | |
387 | ||
dd9f7fea | 388 | // return True if the locale was set successfully |
68bc8549 | 389 | bool IsOk() const; |
d14a1e28 | 390 | %pythoncode { def __nonzero__(self): return self.IsOk() }; |
68bc8549 RD |
391 | |
392 | // returns locale name | |
393 | wxString GetLocale() const; | |
394 | ||
395 | // return current locale wxLanguage value | |
396 | int GetLanguage() const; | |
397 | ||
398 | // return locale name to be passed to setlocale() | |
399 | wxString GetSysName() const; | |
400 | ||
401 | // return 'canonical' name, i.e. in the form of xx[_YY], where xx is | |
402 | // language code according to ISO 639 and YY is country name | |
403 | // as specified by ISO 3166. | |
404 | wxString GetCanonicalName() const; | |
405 | ||
406 | // add a prefix to the catalog lookup path: the message catalog files will be | |
407 | // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix | |
408 | // (in this order). | |
409 | // | |
410 | // This only applies to subsequent invocations of AddCatalog()! | |
411 | static void AddCatalogLookupPathPrefix(const wxString& prefix); | |
412 | ||
413 | // add a catalog: it's searched for in standard places (current directory | |
414 | // first, system one after), but the you may prepend additional directories to | |
415 | // the search path with AddCatalogLookupPathPrefix(). | |
416 | // | |
417 | // The loaded catalog will be used for message lookup by GetString(). | |
418 | // | |
dd9f7fea | 419 | // Returns 'True' if it was successfully loaded |
68bc8549 RD |
420 | bool AddCatalog(const wxString& szDomain); |
421 | ||
422 | // check if the given catalog is loaded | |
423 | bool IsLoaded(const wxString& szDomain) const; | |
424 | ||
923e5f56 RD |
425 | // Retrieve the language info struct for the given language |
426 | // | |
427 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
428 | static const wxLanguageInfo *GetLanguageInfo(int lang); | |
429 | ||
3ef86e32 RD |
430 | // Returns language name in English or empty string if the language |
431 | // is not in database | |
432 | static wxString GetLanguageName(int lang); | |
433 | ||
9cbf6f6e RD |
434 | // Find the language for the given locale string which may be either a |
435 | // canonical ISO 2 letter language code ("xx"), a language code followed by | |
436 | // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") | |
437 | // | |
438 | // Returns NULL if no info found, pointer must *not* be deleted by caller | |
439 | static const wxLanguageInfo *FindLanguageInfo(const wxString& locale); | |
440 | ||
6789bce9 | 441 | // Add custom language to the list of known languages. |
68bc8549 RD |
442 | // Notes: 1) wxLanguageInfo contains platform-specific data |
443 | // 2) must be called before Init to have effect | |
444 | static void AddLanguage(const wxLanguageInfo& info); | |
445 | ||
446 | // retrieve the translation for a string in all loaded domains unless | |
447 | // the szDomain parameter is specified (and then only this domain is | |
448 | // searched) | |
449 | // | |
450 | // return original string if translation is not available | |
451 | // (in this case an error message is generated the first time | |
452 | // a string is not found; use wxLogNull to suppress it) | |
453 | // | |
454 | // domains are searched in the last to first order, i.e. catalogs | |
455 | // added later override those added before. | |
456 | wxString GetString(const wxString& szOrigString, | |
457 | const wxString& szDomain = wxPyEmptyString) const; | |
458 | ||
459 | // Returns the current short name for the locale | |
460 | const wxString& GetName() const; | |
461 | ||
462 | }; | |
463 | ||
464 | ||
465 | ||
466 | // get the current locale object (note that it may be NULL!) | |
467 | wxLocale* wxGetLocale(); | |
468 | ||
469 | // get the translation of the string in the current locale | |
d14a1e28 | 470 | %nokwargs wxGetTranslation; |
83486d3b RD |
471 | wxString wxGetTranslation(const wxString& str); |
472 | wxString wxGetTranslation(const wxString& str, const wxString& strPlural, size_t n); | |
d14a1e28 RD |
473 | |
474 | //--------------------------------------------------------------------------- | |
475 | %newgroup | |
68bc8549 RD |
476 | |
477 | ||
68bc8549 RD |
478 | // wxEncodingConverter |
479 | // This class is capable of converting strings between any two | |
480 | // 8bit encodings/charsets. It can also convert from/to Unicode | |
481 | ||
482 | ||
d14a1e28 RD |
483 | %typemap(out) wxFontEncodingArray { |
484 | $result = PyList_New(0); | |
485 | for (size_t i=0; i < $1.GetCount(); i++) { | |
486 | PyObject* number = PyInt_FromLong($1.Item(i)); | |
487 | PyList_Append($result, number); | |
68bc8549 RD |
488 | Py_DECREF(number); |
489 | } | |
490 | } | |
491 | ||
492 | ||
493 | enum | |
494 | { | |
495 | wxCONVERT_STRICT, | |
496 | wxCONVERT_SUBSTITUTE | |
497 | }; | |
498 | ||
499 | ||
500 | enum | |
501 | { | |
502 | wxPLATFORM_CURRENT = -1, | |
503 | ||
504 | wxPLATFORM_UNIX = 0, | |
505 | wxPLATFORM_WINDOWS, | |
506 | wxPLATFORM_OS2, | |
507 | wxPLATFORM_MAC | |
508 | }; | |
509 | ||
510 | ||
511 | class wxEncodingConverter : public wxObject | |
512 | { | |
513 | public: | |
514 | ||
515 | wxEncodingConverter(); | |
516 | ~wxEncodingConverter(); | |
517 | ||
518 | ||
519 | // Initialize convertion. Both output or input encoding may | |
520 | // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. | |
521 | // | |
522 | // All subsequent calls to Convert() will interpret it's argument | |
523 | // as a string in input_enc encoding and will output string in | |
524 | // output_enc encoding. | |
525 | // | |
526 | // You must call this method before calling Convert. You may call | |
527 | // it more than once in order to switch to another conversion | |
528 | // | |
529 | // Method affects behaviour of Convert() in case input character | |
530 | // cannot be converted because it does not exist in output encoding: | |
531 | // wxCONVERT_STRICT -- | |
532 | // follow behaviour of GNU Recode - just copy unconvertable | |
533 | // characters to output and don't change them (it's integer | |
534 | // value will stay the same) | |
535 | // wxCONVERT_SUBSTITUTE -- | |
536 | // try some (lossy) substitutions - e.g. replace | |
537 | // unconvertable latin capitals with acute by ordinary | |
538 | // capitals, replace en-dash or em-dash by '-' etc. | |
539 | // both modes gurantee that output string will have same length | |
540 | // as input string | |
541 | // | |
dd9f7fea | 542 | // Returns False if given conversion is impossible, True otherwise |
68bc8549 RD |
543 | // (conversion may be impossible either if you try to convert |
544 | // to Unicode with non-Unicode build of wxWindows or if input | |
545 | // or output encoding is not supported.) | |
546 | bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT); | |
547 | ||
f60765b0 RD |
548 | |
549 | // TODO: Need to do something about unicode mode... | |
550 | ||
68bc8549 RD |
551 | // Convert input string according to settings passed to Init. |
552 | // Note that you must call Init before using Convert! | |
553 | wxString Convert(const wxString& input); | |
554 | ||
555 | // void Convert(const char* input, char* output); | |
556 | ||
557 | // #if wxUSE_WCHAR_T | |
558 | // void Convert(const char* input, wchar_t* output); | |
559 | // void Convert(const wchar_t* input, char* output); | |
560 | // void Convert(const wchar_t* input, wchar_t* output); | |
561 | // void Convert(wchar_t* str) { Convert(str, str); } | |
562 | // #endif | |
563 | ||
564 | ||
f60765b0 | 565 | |
68bc8549 RD |
566 | // Return equivalent(s) for given font that are used |
567 | // under given platform. wxPLATFORM_CURRENT means the plaform | |
568 | // this binary was compiled for | |
569 | // | |
570 | // Examples: | |
571 | // current platform enc returned value | |
572 | // ----------------------------------------------------- | |
573 | // unix CP1250 {ISO8859_2} | |
574 | // unix ISO8859_2 {} | |
575 | // windows ISO8859_2 {CP1250} | |
576 | // | |
577 | // Equivalence is defined in terms of convertibility: | |
578 | // 2 encodings are equivalent if you can convert text between | |
579 | // then without loosing information (it may - and will - happen | |
580 | // that you loose special chars like quotation marks or em-dashes | |
581 | // but you shouldn't loose any diacritics and language-specific | |
582 | // characters when converting between equivalent encodings). | |
583 | // | |
584 | // Convert() method is not limited to converting between | |
585 | // equivalent encodings, it can convert between arbitrary | |
586 | // two encodings! | |
587 | // | |
588 | // Remember that this function does _NOT_ check for presence of | |
589 | // fonts in system. It only tells you what are most suitable | |
590 | // encodings. (It usually returns only one encoding) | |
591 | // | |
592 | // Note that argument enc itself may be present in returned array! | |
593 | // (so that you can -- as a side effect -- detect whether the | |
594 | // encoding is native for this platform or not) | |
595 | static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc, | |
596 | int platform = wxPLATFORM_CURRENT); | |
597 | ||
598 | // Similar to GetPlatformEquivalent, but this one will return ALL | |
599 | // equivalent encodings, regardless the platform, including itself. | |
600 | static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc); | |
601 | ||
dd9f7fea | 602 | // Return True if [any text in] one multibyte encoding can be |
d14a1e28 RD |
603 | // converted to another one losslessly. |
604 | // | |
605 | // Do not call this with wxFONTENCODING_UNICODE, it doesn't make | |
606 | // sense (always works in one sense and always depends on the text | |
607 | // to convert in the other) | |
608 | static bool CanConvert(wxFontEncoding encIn, wxFontEncoding encOut); | |
609 | ||
610 | %pythoncode { def __nonzero__(self): return self.IsOk() } | |
68bc8549 RD |
611 | }; |
612 | ||
613 | ||
68bc8549 | 614 | |
68bc8549 | 615 | |
d14a1e28 RD |
616 | //--------------------------------------------------------------------------- |
617 | ||
618 | %pythoncode "_intl_ex.py" | |
68bc8549 | 619 | |
d14a1e28 | 620 | //--------------------------------------------------------------------------- |