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 //---------------------------------------------------------------------------
22 //---------------------------------------------------------------------------
28 // user's default/preffered language as got from OS:
30 // unknown language, if wxLocale::GetSystemLanguage fails:
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,
60 wxLANGUAGE_AZERI_CYRILLIC,
61 wxLANGUAGE_AZERI_LATIN,
64 wxLANGUAGE_BELARUSIAN,
75 wxLANGUAGE_CHINESE_SIMPLIFIED,
76 wxLANGUAGE_CHINESE_TRADITIONAL,
77 wxLANGUAGE_CHINESE_HONGKONG,
78 wxLANGUAGE_CHINESE_MACAU,
79 wxLANGUAGE_CHINESE_SINGAPORE,
80 wxLANGUAGE_CHINESE_TAIWAN,
86 wxLANGUAGE_DUTCH_BELGIAN,
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,
110 wxLANGUAGE_FRENCH_BELGIAN,
111 wxLANGUAGE_FRENCH_CANADIAN,
112 wxLANGUAGE_FRENCH_LUXEMBOURG,
113 wxLANGUAGE_FRENCH_MONACO,
114 wxLANGUAGE_FRENCH_SWISS,
119 wxLANGUAGE_GERMAN_AUSTRIAN,
120 wxLANGUAGE_GERMAN_BELGIUM,
121 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
122 wxLANGUAGE_GERMAN_LUXEMBOURG,
123 wxLANGUAGE_GERMAN_SWISS,
125 wxLANGUAGE_GREENLANDIC,
131 wxLANGUAGE_HUNGARIAN,
132 wxLANGUAGE_ICELANDIC,
133 wxLANGUAGE_INDONESIAN,
134 wxLANGUAGE_INTERLINGUA,
135 wxLANGUAGE_INTERLINGUE,
136 wxLANGUAGE_INUKTITUT,
140 wxLANGUAGE_ITALIAN_SWISS,
145 wxLANGUAGE_KASHMIRI_INDIA,
148 wxLANGUAGE_KINYARWANDA,
158 wxLANGUAGE_LITHUANIAN,
159 wxLANGUAGE_MACEDONIAN,
162 wxLANGUAGE_MALAYALAM,
163 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
164 wxLANGUAGE_MALAY_MALAYSIA,
169 wxLANGUAGE_MOLDAVIAN,
170 wxLANGUAGE_MONGOLIAN,
173 wxLANGUAGE_NEPALI_INDIA,
174 wxLANGUAGE_NORWEGIAN_BOKMAL,
175 wxLANGUAGE_NORWEGIAN_NYNORSK,
181 wxLANGUAGE_PORTUGUESE,
182 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
185 wxLANGUAGE_RHAETO_ROMANCE,
188 wxLANGUAGE_RUSSIAN_UKRAINE,
192 wxLANGUAGE_SCOTS_GAELIC,
194 wxLANGUAGE_SERBIAN_CYRILLIC,
195 wxLANGUAGE_SERBIAN_LATIN,
196 wxLANGUAGE_SERBO_CROATIAN,
201 wxLANGUAGE_SINHALESE,
204 wxLANGUAGE_SLOVENIAN,
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,
230 wxLANGUAGE_SWEDISH_FINLAND,
245 wxLANGUAGE_UKRAINIAN,
247 wxLANGUAGE_URDU_INDIA,
248 wxLANGUAGE_URDU_PAKISTAN,
250 wxLANGUAGE_UZBEK_CYRILLIC,
251 wxLANGUAGE_UZBEK_LATIN,
252 wxLANGUAGE_VIETNAMESE,
262 // for custom, user-defined languages:
263 wxLANGUAGE_USER_DEFINED
267 //---------------------------------------------------------------------------
270 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
271 // translation information
272 struct wxLanguageInfo
274 int Language; // wxLanguage id
275 wxString CanonicalName; // Canonical name, e.g. fr_FR
276 wxString Description; // human-readable name of the language
279 // wxLocaleCategory: the category of locale settings
280 enum wxLocaleCategory
288 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
291 wxLOCALE_THOUSANDS_SEP,
292 wxLOCALE_DECIMAL_POINT
296 // wxLocale: encapsulates all language dependent settings, including current
297 // message catalogs, date, time and currency formats (TODO) &c
298 enum wxLocaleInitFlags
300 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
301 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
305 //---------------------------------------------------------------------------
313 wxLocale(int language = -1,
314 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) {
317 loc = new wxLocale();
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");
329 // restores old locale
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");
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");
362 def Init(self, *_args, **_kwargs):
363 if type(_args[0]) in [type(''), type(u'')]:
364 val = self.Init1(*_args, **_kwargs)
366 val = self.Init2(*_args, **_kwargs)
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();
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();
378 // get the string describing the system encoding, return empty string if
379 // couldn't be determined
380 static wxString GetSystemEncodingName();
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);
388 // return True if the locale was set successfully
390 %pythoncode { def __nonzero__(self): return self.IsOk() };
392 // returns locale name
393 wxString GetLocale() const;
395 // return current locale wxLanguage value
396 int GetLanguage() const;
398 // return locale name to be passed to setlocale()
399 wxString GetSysName() const;
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;
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
410 // This only applies to subsequent invocations of AddCatalog()!
411 static void AddCatalogLookupPathPrefix(const wxString& prefix);
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().
417 // The loaded catalog will be used for message lookup by GetString().
419 // Returns 'True' if it was successfully loaded
420 bool AddCatalog(const wxString& szDomain);
422 // check if the given catalog is loaded
423 bool IsLoaded(const wxString& szDomain) const;
425 // Retrieve the language info struct for the given language
427 // Returns NULL if no info found, pointer must *not* be deleted by caller
428 static const wxLanguageInfo *GetLanguageInfo(int lang);
430 // Returns language name in English or empty string if the language
431 // is not in database
432 static wxString GetLanguageName(int lang);
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...")
438 // Returns NULL if no info found, pointer must *not* be deleted by caller
439 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
441 // Add custom language to the list of known languages.
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);
446 // retrieve the translation for a string in all loaded domains unless
447 // the szDomain parameter is specified (and then only this domain is
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)
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;
459 // Returns the current short name for the locale
460 const wxString& GetName() const;
466 // get the current locale object (note that it may be NULL!)
467 wxLocale* wxGetLocale();
469 // get the translation of the string in the current locale
470 %nokwargs wxGetTranslation;
471 wxString wxGetTranslation(const wxString& str);
472 wxString wxGetTranslation(const wxString& str, const wxString& strPlural, size_t n);
474 //---------------------------------------------------------------------------
478 // wxEncodingConverter
479 // This class is capable of converting strings between any two
480 // 8bit encodings/charsets. It can also convert from/to Unicode
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);
502 wxPLATFORM_CURRENT = -1,
511 class wxEncodingConverter : public wxObject
515 wxEncodingConverter();
516 ~wxEncodingConverter();
519 // Initialize convertion. Both output or input encoding may
520 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
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.
526 // You must call this method before calling Convert. You may call
527 // it more than once in order to switch to another conversion
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
542 // Returns False if given conversion is impossible, True otherwise
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);
549 // TODO: Need to do something about unicode mode...
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);
555 // void Convert(const char* input, char* output);
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); }
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
571 // current platform enc returned value
572 // -----------------------------------------------------
573 // unix CP1250 {ISO8859_2}
575 // windows ISO8859_2 {CP1250}
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).
584 // Convert() method is not limited to converting between
585 // equivalent encodings, it can convert between arbitrary
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)
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);
598 // Similar to GetPlatformEquivalent, but this one will return ALL
599 // equivalent encodings, regardless the platform, including itself.
600 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
602 // Return True if [any text in] one multibyte encoding can be
603 // converted to another one losslessly.
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);
610 %pythoncode { def __nonzero__(self): return self.IsOk() }
616 //---------------------------------------------------------------------------
618 %pythoncode "_intl_ex.py"
620 //---------------------------------------------------------------------------