1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxLocale and related classes
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
27 // user's default/preffered language as got from OS:
29 // unknown language, if wxLocale::GetSystemLanguage fails:
38 wxLANGUAGE_ARABIC_ALGERIA,
39 wxLANGUAGE_ARABIC_BAHRAIN,
40 wxLANGUAGE_ARABIC_EGYPT,
41 wxLANGUAGE_ARABIC_IRAQ,
42 wxLANGUAGE_ARABIC_JORDAN,
43 wxLANGUAGE_ARABIC_KUWAIT,
44 wxLANGUAGE_ARABIC_LEBANON,
45 wxLANGUAGE_ARABIC_LIBYA,
46 wxLANGUAGE_ARABIC_MOROCCO,
47 wxLANGUAGE_ARABIC_OMAN,
48 wxLANGUAGE_ARABIC_QATAR,
49 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
50 wxLANGUAGE_ARABIC_SUDAN,
51 wxLANGUAGE_ARABIC_SYRIA,
52 wxLANGUAGE_ARABIC_TUNISIA,
53 wxLANGUAGE_ARABIC_UAE,
54 wxLANGUAGE_ARABIC_YEMEN,
59 wxLANGUAGE_AZERI_CYRILLIC,
60 wxLANGUAGE_AZERI_LATIN,
63 wxLANGUAGE_BELARUSIAN,
74 wxLANGUAGE_CHINESE_SIMPLIFIED,
75 wxLANGUAGE_CHINESE_TRADITIONAL,
76 wxLANGUAGE_CHINESE_HONGKONG,
77 wxLANGUAGE_CHINESE_MACAU,
78 wxLANGUAGE_CHINESE_SINGAPORE,
79 wxLANGUAGE_CHINESE_TAIWAN,
85 wxLANGUAGE_DUTCH_BELGIAN,
87 wxLANGUAGE_ENGLISH_UK,
88 wxLANGUAGE_ENGLISH_US,
89 wxLANGUAGE_ENGLISH_AUSTRALIA,
90 wxLANGUAGE_ENGLISH_BELIZE,
91 wxLANGUAGE_ENGLISH_BOTSWANA,
92 wxLANGUAGE_ENGLISH_CANADA,
93 wxLANGUAGE_ENGLISH_CARIBBEAN,
94 wxLANGUAGE_ENGLISH_DENMARK,
95 wxLANGUAGE_ENGLISH_EIRE,
96 wxLANGUAGE_ENGLISH_JAMAICA,
97 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
98 wxLANGUAGE_ENGLISH_PHILIPPINES,
99 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
100 wxLANGUAGE_ENGLISH_TRINIDAD,
101 wxLANGUAGE_ENGLISH_ZIMBABWE,
102 wxLANGUAGE_ESPERANTO,
109 wxLANGUAGE_FRENCH_BELGIAN,
110 wxLANGUAGE_FRENCH_CANADIAN,
111 wxLANGUAGE_FRENCH_LUXEMBOURG,
112 wxLANGUAGE_FRENCH_MONACO,
113 wxLANGUAGE_FRENCH_SWISS,
118 wxLANGUAGE_GERMAN_AUSTRIAN,
119 wxLANGUAGE_GERMAN_BELGIUM,
120 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
121 wxLANGUAGE_GERMAN_LUXEMBOURG,
122 wxLANGUAGE_GERMAN_SWISS,
124 wxLANGUAGE_GREENLANDIC,
130 wxLANGUAGE_HUNGARIAN,
131 wxLANGUAGE_ICELANDIC,
132 wxLANGUAGE_INDONESIAN,
133 wxLANGUAGE_INTERLINGUA,
134 wxLANGUAGE_INTERLINGUE,
135 wxLANGUAGE_INUKTITUT,
139 wxLANGUAGE_ITALIAN_SWISS,
144 wxLANGUAGE_KASHMIRI_INDIA,
147 wxLANGUAGE_KINYARWANDA,
157 wxLANGUAGE_LITHUANIAN,
158 wxLANGUAGE_MACEDONIAN,
161 wxLANGUAGE_MALAYALAM,
162 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
163 wxLANGUAGE_MALAY_MALAYSIA,
168 wxLANGUAGE_MOLDAVIAN,
169 wxLANGUAGE_MONGOLIAN,
172 wxLANGUAGE_NEPALI_INDIA,
173 wxLANGUAGE_NORWEGIAN_BOKMAL,
174 wxLANGUAGE_NORWEGIAN_NYNORSK,
180 wxLANGUAGE_PORTUGUESE,
181 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
184 wxLANGUAGE_RHAETO_ROMANCE,
187 wxLANGUAGE_RUSSIAN_UKRAINE,
191 wxLANGUAGE_SCOTS_GAELIC,
193 wxLANGUAGE_SERBIAN_CYRILLIC,
194 wxLANGUAGE_SERBIAN_LATIN,
195 wxLANGUAGE_SERBO_CROATIAN,
200 wxLANGUAGE_SINHALESE,
203 wxLANGUAGE_SLOVENIAN,
206 wxLANGUAGE_SPANISH_ARGENTINA,
207 wxLANGUAGE_SPANISH_BOLIVIA,
208 wxLANGUAGE_SPANISH_CHILE,
209 wxLANGUAGE_SPANISH_COLOMBIA,
210 wxLANGUAGE_SPANISH_COSTA_RICA,
211 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
212 wxLANGUAGE_SPANISH_ECUADOR,
213 wxLANGUAGE_SPANISH_EL_SALVADOR,
214 wxLANGUAGE_SPANISH_GUATEMALA,
215 wxLANGUAGE_SPANISH_HONDURAS,
216 wxLANGUAGE_SPANISH_MEXICAN,
217 wxLANGUAGE_SPANISH_MODERN,
218 wxLANGUAGE_SPANISH_NICARAGUA,
219 wxLANGUAGE_SPANISH_PANAMA,
220 wxLANGUAGE_SPANISH_PARAGUAY,
221 wxLANGUAGE_SPANISH_PERU,
222 wxLANGUAGE_SPANISH_PUERTO_RICO,
223 wxLANGUAGE_SPANISH_URUGUAY,
224 wxLANGUAGE_SPANISH_US,
225 wxLANGUAGE_SPANISH_VENEZUELA,
226 wxLANGUAGE_SUNDANESE,
229 wxLANGUAGE_SWEDISH_FINLAND,
244 wxLANGUAGE_UKRAINIAN,
246 wxLANGUAGE_URDU_INDIA,
247 wxLANGUAGE_URDU_PAKISTAN,
249 wxLANGUAGE_UZBEK_CYRILLIC,
250 wxLANGUAGE_UZBEK_LATIN,
251 wxLANGUAGE_VIETNAMESE,
261 // for custom, user-defined languages:
262 wxLANGUAGE_USER_DEFINED
266 //---------------------------------------------------------------------------
269 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
270 // translation information
271 struct wxLanguageInfo
273 int Language; // wxLanguage id
274 wxString CanonicalName; // Canonical name, e.g. fr_FR
275 wxString Description; // human-readable name of the language
278 // wxLocaleCategory: the category of locale settings
279 enum wxLocaleCategory
287 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
290 wxLOCALE_THOUSANDS_SEP,
291 wxLOCALE_DECIMAL_POINT
295 // wxLocale: encapsulates all language dependent settings, including current
296 // message catalogs, date, time and currency formats (TODO) &c
297 enum wxLocaleInitFlags
299 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
300 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
304 //---------------------------------------------------------------------------
312 wxLocale(int language = -1,
313 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) {
315 return new wxLocale();
317 return new wxLocale(language, flags);
321 // restores old locale
324 %name(Init1)bool Init(const wxString& szName,
325 const wxString& szShort = wxPyEmptyString,
326 const wxString& szLocale = wxPyEmptyString,
327 bool bLoadDefault = true,
328 bool bConvertEncoding = false);
330 %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
331 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
334 def Init(self, *_args, **_kwargs):
335 if type(_args[0]) in [type(''), type(u'')]:
336 val = self.Init1(*_args, **_kwargs)
338 val = self.Init2(*_args, **_kwargs)
342 // Try to get user's (or OS's) prefered language setting.
343 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
344 static int GetSystemLanguage();
346 // get the encoding used by default for text on this system, returns
347 // wxFONTENCODING_SYSTEM if it couldn't be determined
348 static wxFontEncoding GetSystemEncoding();
350 // get the string describing the system encoding, return empty string if
351 // couldn't be determined
352 static wxString GetSystemEncodingName();
355 // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp
356 // get the values of the given locale-dependent datum: the current locale
357 // is used, the US default value is returned if everything else fails
358 // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat);
360 // return True if the locale was set successfully
362 %pythoncode { def __nonzero__(self): return self.IsOk() };
364 // returns locale name
365 wxString GetLocale() const;
367 // return current locale wxLanguage value
368 int GetLanguage() const;
370 // return locale name to be passed to setlocale()
371 wxString GetSysName() const;
373 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
374 // language code according to ISO 639 and YY is country name
375 // as specified by ISO 3166.
376 wxString GetCanonicalName() const;
378 // add a prefix to the catalog lookup path: the message catalog files will be
379 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
382 // This only applies to subsequent invocations of AddCatalog()!
383 static void AddCatalogLookupPathPrefix(const wxString& prefix);
385 // add a catalog: it's searched for in standard places (current directory
386 // first, system one after), but the you may prepend additional directories to
387 // the search path with AddCatalogLookupPathPrefix().
389 // The loaded catalog will be used for message lookup by GetString().
391 // Returns 'True' if it was successfully loaded
392 bool AddCatalog(const wxString& szDomain);
394 // check if the given catalog is loaded
395 bool IsLoaded(const wxString& szDomain) const;
397 // Retrieve the language info struct for the given language
399 // Returns NULL if no info found, pointer must *not* be deleted by caller
400 static const wxLanguageInfo *GetLanguageInfo(int lang);
402 // Returns language name in English or empty string if the language
403 // is not in database
404 static wxString GetLanguageName(int lang);
406 // Find the language for the given locale string which may be either a
407 // canonical ISO 2 letter language code ("xx"), a language code followed by
408 // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
410 // Returns NULL if no info found, pointer must *not* be deleted by caller
411 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
413 // Add custom language to the list of known languages.
414 // Notes: 1) wxLanguageInfo contains platform-specific data
415 // 2) must be called before Init to have effect
416 static void AddLanguage(const wxLanguageInfo& info);
418 // retrieve the translation for a string in all loaded domains unless
419 // the szDomain parameter is specified (and then only this domain is
422 // return original string if translation is not available
423 // (in this case an error message is generated the first time
424 // a string is not found; use wxLogNull to suppress it)
426 // domains are searched in the last to first order, i.e. catalogs
427 // added later override those added before.
428 wxString GetString(const wxString& szOrigString,
429 const wxString& szDomain = wxPyEmptyString) const;
431 // Returns the current short name for the locale
432 const wxString& GetName() const;
438 // get the current locale object (note that it may be NULL!)
439 wxLocale* wxGetLocale();
441 // get the translation of the string in the current locale
442 %nokwargs wxGetTranslation;
443 wxString wxGetTranslation(const wxString& str);
444 wxString wxGetTranslation(const wxString& str, const wxString& strPlural, size_t n);
446 //---------------------------------------------------------------------------
450 // wxEncodingConverter
451 // This class is capable of converting strings between any two
452 // 8bit encodings/charsets. It can also convert from/to Unicode
455 %typemap(out) wxFontEncodingArray {
456 $result = PyList_New(0);
457 for (size_t i=0; i < $1.GetCount(); i++) {
458 PyObject* number = PyInt_FromLong($1.Item(i));
459 PyList_Append($result, number);
474 wxPLATFORM_CURRENT = -1,
483 class wxEncodingConverter : public wxObject
487 wxEncodingConverter();
488 ~wxEncodingConverter();
491 // Initialize convertion. Both output or input encoding may
492 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
494 // All subsequent calls to Convert() will interpret it's argument
495 // as a string in input_enc encoding and will output string in
496 // output_enc encoding.
498 // You must call this method before calling Convert. You may call
499 // it more than once in order to switch to another conversion
501 // Method affects behaviour of Convert() in case input character
502 // cannot be converted because it does not exist in output encoding:
503 // wxCONVERT_STRICT --
504 // follow behaviour of GNU Recode - just copy unconvertable
505 // characters to output and don't change them (it's integer
506 // value will stay the same)
507 // wxCONVERT_SUBSTITUTE --
508 // try some (lossy) substitutions - e.g. replace
509 // unconvertable latin capitals with acute by ordinary
510 // capitals, replace en-dash or em-dash by '-' etc.
511 // both modes gurantee that output string will have same length
514 // Returns False if given conversion is impossible, True otherwise
515 // (conversion may be impossible either if you try to convert
516 // to Unicode with non-Unicode build of wxWindows or if input
517 // or output encoding is not supported.)
518 bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
521 // TODO: Need to do something about unicode mode...
523 // Convert input string according to settings passed to Init.
524 // Note that you must call Init before using Convert!
525 wxString Convert(const wxString& input);
527 // void Convert(const char* input, char* output);
530 // void Convert(const char* input, wchar_t* output);
531 // void Convert(const wchar_t* input, char* output);
532 // void Convert(const wchar_t* input, wchar_t* output);
533 // void Convert(wchar_t* str) { Convert(str, str); }
538 // Return equivalent(s) for given font that are used
539 // under given platform. wxPLATFORM_CURRENT means the plaform
540 // this binary was compiled for
543 // current platform enc returned value
544 // -----------------------------------------------------
545 // unix CP1250 {ISO8859_2}
547 // windows ISO8859_2 {CP1250}
549 // Equivalence is defined in terms of convertibility:
550 // 2 encodings are equivalent if you can convert text between
551 // then without loosing information (it may - and will - happen
552 // that you loose special chars like quotation marks or em-dashes
553 // but you shouldn't loose any diacritics and language-specific
554 // characters when converting between equivalent encodings).
556 // Convert() method is not limited to converting between
557 // equivalent encodings, it can convert between arbitrary
560 // Remember that this function does _NOT_ check for presence of
561 // fonts in system. It only tells you what are most suitable
562 // encodings. (It usually returns only one encoding)
564 // Note that argument enc itself may be present in returned array!
565 // (so that you can -- as a side effect -- detect whether the
566 // encoding is native for this platform or not)
567 static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc,
568 int platform = wxPLATFORM_CURRENT);
570 // Similar to GetPlatformEquivalent, but this one will return ALL
571 // equivalent encodings, regardless the platform, including itself.
572 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
574 // Return True if [any text in] one multibyte encoding can be
575 // converted to another one losslessly.
577 // Do not call this with wxFONTENCODING_UNICODE, it doesn't make
578 // sense (always works in one sense and always depends on the text
579 // to convert in the other)
580 static bool CanConvert(wxFontEncoding encIn, wxFontEncoding encOut);
582 %pythoncode { def __nonzero__(self): return self.IsOk() }
588 //---------------------------------------------------------------------------
590 %pythoncode "_intl_ex.py"
592 //---------------------------------------------------------------------------