recategorize many misplaced classes; move lots of classes from miscellaneous [window...
[wxWidgets.git] / interface / wx / intl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: intl.h
3 // Purpose: interface of wxLocale
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 // --- --- --- generated code begins here --- --- ---
11
12 /**
13 The languages supported by wxLocale.
14
15 This enum is generated by misc/languages/genlang.py
16 When making changes, please put them into misc/languages/langtabl.txt
17 */
18 enum wxLanguage
19 {
20 /// User's default/preferred language as got from OS.
21 wxLANGUAGE_DEFAULT,
22
23 /// Unknown language, returned if wxLocale::GetSystemLanguage fails.
24 wxLANGUAGE_UNKNOWN,
25
26 wxLANGUAGE_ABKHAZIAN,
27 wxLANGUAGE_AFAR,
28 wxLANGUAGE_AFRIKAANS,
29 wxLANGUAGE_ALBANIAN,
30 wxLANGUAGE_AMHARIC,
31 wxLANGUAGE_ARABIC,
32 wxLANGUAGE_ARABIC_ALGERIA,
33 wxLANGUAGE_ARABIC_BAHRAIN,
34 wxLANGUAGE_ARABIC_EGYPT,
35 wxLANGUAGE_ARABIC_IRAQ,
36 wxLANGUAGE_ARABIC_JORDAN,
37 wxLANGUAGE_ARABIC_KUWAIT,
38 wxLANGUAGE_ARABIC_LEBANON,
39 wxLANGUAGE_ARABIC_LIBYA,
40 wxLANGUAGE_ARABIC_MOROCCO,
41 wxLANGUAGE_ARABIC_OMAN,
42 wxLANGUAGE_ARABIC_QATAR,
43 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
44 wxLANGUAGE_ARABIC_SUDAN,
45 wxLANGUAGE_ARABIC_SYRIA,
46 wxLANGUAGE_ARABIC_TUNISIA,
47 wxLANGUAGE_ARABIC_UAE,
48 wxLANGUAGE_ARABIC_YEMEN,
49 wxLANGUAGE_ARMENIAN,
50 wxLANGUAGE_ASSAMESE,
51 wxLANGUAGE_AYMARA,
52 wxLANGUAGE_AZERI,
53 wxLANGUAGE_AZERI_CYRILLIC,
54 wxLANGUAGE_AZERI_LATIN,
55 wxLANGUAGE_BASHKIR,
56 wxLANGUAGE_BASQUE,
57 wxLANGUAGE_BELARUSIAN,
58 wxLANGUAGE_BENGALI,
59 wxLANGUAGE_BHUTANI,
60 wxLANGUAGE_BIHARI,
61 wxLANGUAGE_BISLAMA,
62 wxLANGUAGE_BRETON,
63 wxLANGUAGE_BULGARIAN,
64 wxLANGUAGE_BURMESE,
65 wxLANGUAGE_CAMBODIAN,
66 wxLANGUAGE_CATALAN,
67 wxLANGUAGE_CHINESE,
68 wxLANGUAGE_CHINESE_SIMPLIFIED,
69 wxLANGUAGE_CHINESE_TRADITIONAL,
70 wxLANGUAGE_CHINESE_HONGKONG,
71 wxLANGUAGE_CHINESE_MACAU,
72 wxLANGUAGE_CHINESE_SINGAPORE,
73 wxLANGUAGE_CHINESE_TAIWAN,
74 wxLANGUAGE_CORSICAN,
75 wxLANGUAGE_CROATIAN,
76 wxLANGUAGE_CZECH,
77 wxLANGUAGE_DANISH,
78 wxLANGUAGE_DUTCH,
79 wxLANGUAGE_DUTCH_BELGIAN,
80 wxLANGUAGE_ENGLISH,
81 wxLANGUAGE_ENGLISH_UK,
82 wxLANGUAGE_ENGLISH_US,
83 wxLANGUAGE_ENGLISH_AUSTRALIA,
84 wxLANGUAGE_ENGLISH_BELIZE,
85 wxLANGUAGE_ENGLISH_BOTSWANA,
86 wxLANGUAGE_ENGLISH_CANADA,
87 wxLANGUAGE_ENGLISH_CARIBBEAN,
88 wxLANGUAGE_ENGLISH_DENMARK,
89 wxLANGUAGE_ENGLISH_EIRE,
90 wxLANGUAGE_ENGLISH_JAMAICA,
91 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
92 wxLANGUAGE_ENGLISH_PHILIPPINES,
93 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
94 wxLANGUAGE_ENGLISH_TRINIDAD,
95 wxLANGUAGE_ENGLISH_ZIMBABWE,
96 wxLANGUAGE_ESPERANTO,
97 wxLANGUAGE_ESTONIAN,
98 wxLANGUAGE_FAEROESE,
99 wxLANGUAGE_FARSI,
100 wxLANGUAGE_FIJI,
101 wxLANGUAGE_FINNISH,
102 wxLANGUAGE_FRENCH,
103 wxLANGUAGE_FRENCH_BELGIAN,
104 wxLANGUAGE_FRENCH_CANADIAN,
105 wxLANGUAGE_FRENCH_LUXEMBOURG,
106 wxLANGUAGE_FRENCH_MONACO,
107 wxLANGUAGE_FRENCH_SWISS,
108 wxLANGUAGE_FRISIAN,
109 wxLANGUAGE_GALICIAN,
110 wxLANGUAGE_GEORGIAN,
111 wxLANGUAGE_GERMAN,
112 wxLANGUAGE_GERMAN_AUSTRIAN,
113 wxLANGUAGE_GERMAN_BELGIUM,
114 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
115 wxLANGUAGE_GERMAN_LUXEMBOURG,
116 wxLANGUAGE_GERMAN_SWISS,
117 wxLANGUAGE_GREEK,
118 wxLANGUAGE_GREENLANDIC,
119 wxLANGUAGE_GUARANI,
120 wxLANGUAGE_GUJARATI,
121 wxLANGUAGE_HAUSA,
122 wxLANGUAGE_HEBREW,
123 wxLANGUAGE_HINDI,
124 wxLANGUAGE_HUNGARIAN,
125 wxLANGUAGE_ICELANDIC,
126 wxLANGUAGE_INDONESIAN,
127 wxLANGUAGE_INTERLINGUA,
128 wxLANGUAGE_INTERLINGUE,
129 wxLANGUAGE_INUKTITUT,
130 wxLANGUAGE_INUPIAK,
131 wxLANGUAGE_IRISH,
132 wxLANGUAGE_ITALIAN,
133 wxLANGUAGE_ITALIAN_SWISS,
134 wxLANGUAGE_JAPANESE,
135 wxLANGUAGE_JAVANESE,
136 wxLANGUAGE_KANNADA,
137 wxLANGUAGE_KASHMIRI,
138 wxLANGUAGE_KASHMIRI_INDIA,
139 wxLANGUAGE_KAZAKH,
140 wxLANGUAGE_KERNEWEK,
141 wxLANGUAGE_KINYARWANDA,
142 wxLANGUAGE_KIRGHIZ,
143 wxLANGUAGE_KIRUNDI,
144 wxLANGUAGE_KONKANI,
145 wxLANGUAGE_KOREAN,
146 wxLANGUAGE_KURDISH,
147 wxLANGUAGE_LAOTHIAN,
148 wxLANGUAGE_LATIN,
149 wxLANGUAGE_LATVIAN,
150 wxLANGUAGE_LINGALA,
151 wxLANGUAGE_LITHUANIAN,
152 wxLANGUAGE_MACEDONIAN,
153 wxLANGUAGE_MALAGASY,
154 wxLANGUAGE_MALAY,
155 wxLANGUAGE_MALAYALAM,
156 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
157 wxLANGUAGE_MALAY_MALAYSIA,
158 wxLANGUAGE_MALTESE,
159 wxLANGUAGE_MANIPURI,
160 wxLANGUAGE_MAORI,
161 wxLANGUAGE_MARATHI,
162 wxLANGUAGE_MOLDAVIAN,
163 wxLANGUAGE_MONGOLIAN,
164 wxLANGUAGE_NAURU,
165 wxLANGUAGE_NEPALI,
166 wxLANGUAGE_NEPALI_INDIA,
167 wxLANGUAGE_NORWEGIAN_BOKMAL,
168 wxLANGUAGE_NORWEGIAN_NYNORSK,
169 wxLANGUAGE_OCCITAN,
170 wxLANGUAGE_ORIYA,
171 wxLANGUAGE_OROMO,
172 wxLANGUAGE_PASHTO,
173 wxLANGUAGE_POLISH,
174 wxLANGUAGE_PORTUGUESE,
175 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
176 wxLANGUAGE_PUNJABI,
177 wxLANGUAGE_QUECHUA,
178 wxLANGUAGE_RHAETO_ROMANCE,
179 wxLANGUAGE_ROMANIAN,
180 wxLANGUAGE_RUSSIAN,
181 wxLANGUAGE_RUSSIAN_UKRAINE,
182 wxLANGUAGE_SAMI,
183 wxLANGUAGE_SAMOAN,
184 wxLANGUAGE_SANGHO,
185 wxLANGUAGE_SANSKRIT,
186 wxLANGUAGE_SCOTS_GAELIC,
187 wxLANGUAGE_SERBIAN,
188 wxLANGUAGE_SERBIAN_CYRILLIC,
189 wxLANGUAGE_SERBIAN_LATIN,
190 wxLANGUAGE_SERBO_CROATIAN,
191 wxLANGUAGE_SESOTHO,
192 wxLANGUAGE_SETSWANA,
193 wxLANGUAGE_SHONA,
194 wxLANGUAGE_SINDHI,
195 wxLANGUAGE_SINHALESE,
196 wxLANGUAGE_SISWATI,
197 wxLANGUAGE_SLOVAK,
198 wxLANGUAGE_SLOVENIAN,
199 wxLANGUAGE_SOMALI,
200 wxLANGUAGE_SPANISH,
201 wxLANGUAGE_SPANISH_ARGENTINA,
202 wxLANGUAGE_SPANISH_BOLIVIA,
203 wxLANGUAGE_SPANISH_CHILE,
204 wxLANGUAGE_SPANISH_COLOMBIA,
205 wxLANGUAGE_SPANISH_COSTA_RICA,
206 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
207 wxLANGUAGE_SPANISH_ECUADOR,
208 wxLANGUAGE_SPANISH_EL_SALVADOR,
209 wxLANGUAGE_SPANISH_GUATEMALA,
210 wxLANGUAGE_SPANISH_HONDURAS,
211 wxLANGUAGE_SPANISH_MEXICAN,
212 wxLANGUAGE_SPANISH_MODERN,
213 wxLANGUAGE_SPANISH_NICARAGUA,
214 wxLANGUAGE_SPANISH_PANAMA,
215 wxLANGUAGE_SPANISH_PARAGUAY,
216 wxLANGUAGE_SPANISH_PERU,
217 wxLANGUAGE_SPANISH_PUERTO_RICO,
218 wxLANGUAGE_SPANISH_URUGUAY,
219 wxLANGUAGE_SPANISH_US,
220 wxLANGUAGE_SPANISH_VENEZUELA,
221 wxLANGUAGE_SUNDANESE,
222 wxLANGUAGE_SWAHILI,
223 wxLANGUAGE_SWEDISH,
224 wxLANGUAGE_SWEDISH_FINLAND,
225 wxLANGUAGE_TAGALOG,
226 wxLANGUAGE_TAJIK,
227 wxLANGUAGE_TAMIL,
228 wxLANGUAGE_TATAR,
229 wxLANGUAGE_TELUGU,
230 wxLANGUAGE_THAI,
231 wxLANGUAGE_TIBETAN,
232 wxLANGUAGE_TIGRINYA,
233 wxLANGUAGE_TONGA,
234 wxLANGUAGE_TSONGA,
235 wxLANGUAGE_TURKISH,
236 wxLANGUAGE_TURKMEN,
237 wxLANGUAGE_TWI,
238 wxLANGUAGE_UIGHUR,
239 wxLANGUAGE_UKRAINIAN,
240 wxLANGUAGE_URDU,
241 wxLANGUAGE_URDU_INDIA,
242 wxLANGUAGE_URDU_PAKISTAN,
243 wxLANGUAGE_UZBEK,
244 wxLANGUAGE_UZBEK_CYRILLIC,
245 wxLANGUAGE_UZBEK_LATIN,
246 wxLANGUAGE_VALENCIAN,
247 wxLANGUAGE_VIETNAMESE,
248 wxLANGUAGE_VOLAPUK,
249 wxLANGUAGE_WELSH,
250 wxLANGUAGE_WOLOF,
251 wxLANGUAGE_XHOSA,
252 wxLANGUAGE_YIDDISH,
253 wxLANGUAGE_YORUBA,
254 wxLANGUAGE_ZHUANG,
255 wxLANGUAGE_ZULU,
256
257 /// For custom, user-defined languages.
258 wxLANGUAGE_USER_DEFINED
259 };
260
261 // --- --- --- generated code ends here --- --- ---
262
263
264
265 /**
266 This is the layout direction stored in wxLanguageInfo and returned by
267 wxApp::GetLayoutDirection(), wxWindow::GetLayoutDirection(),
268 wxDC::GetLayoutDirection() for RTL (right-to-left) languages support.
269 */
270 enum wxLayoutDirection
271 {
272 wxLayout_Default,
273 wxLayout_LeftToRight,
274 wxLayout_RightToLeft
275 };
276
277 /**
278 Encapsulates ::wxLanguage in a OS native lang.desc.
279 translation information
280 */
281 struct WXDLLIMPEXP_BASE wxLanguageInfo
282 {
283 /// ::wxLanguage id. It should be greater than @c wxLANGUAGE_USER_DEFINED.
284 int Language;
285
286 /// Canonical name of the language, e.g. @c fr_FR.
287 wxString CanonicalName;
288
289 //@{
290 /**
291 Win32 language identifiers (LANG_xxxx, SUBLANG_xxxx).
292
293 @onlyfor{wxmsw}
294 */
295 wxUint32 WinLang, WinSublang;
296 //@}
297
298 /// Human-readable name of the language.
299 wxString Description;
300
301 /// The layout direction used for this language.
302 wxLayoutDirection LayoutDirection;
303
304 /// Return the LCID corresponding to this language.
305 /// @onlyfor{wxmsw}
306 wxUint32 GetLCID() const;
307
308 /// Return the locale name corresponding to this language usable with
309 /// @c setlocale() on the current system.
310 wxString GetLocaleName() const;
311 };
312
313
314 /**
315 @class wxLocale
316
317 wxLocale class encapsulates all language-dependent settings and is a
318 generalization of the C locale concept.
319
320 In wxWidgets this class manages message catalogs which contain the translations
321 of the strings used to the current language.
322
323 For a list of the supported languages, please see ::wxLanguage enum values.
324 These constants may be used to specify the language in wxLocale::Init and
325 are returned by wxLocale::GetSystemLanguage.
326
327 @beginWxPerlOnly
328 In wxPerl you can't use the '_' function name, so
329 the @c Wx::Locale module can export the @c gettext and
330 @c gettext_noop under any given name.
331
332 @code
333 # this imports gettext ( equivalent to Wx::GetTranslation
334 # and gettext_noop ( a noop )
335 # into your module
336 use Wx::Locale qw(:default);
337
338 # ....
339
340 # use the functions
341 print gettext( "Panic!" );
342
343 button = Wx::Button-new( window, -1, gettext( "Label" ) );
344 @endcode
345
346 If you need to translate a lot of strings, then adding gettext( ) around
347 each one is a long task ( that is why _( ) was introduced ), so just choose
348 a shorter name for gettext:
349
350 @code
351 use Wx::Locale 'gettext' = 't',
352 'gettext_noop' = 'gettext_noop';
353
354 # ...
355
356 # use the functions
357 print t( "Panic!!" );
358
359 # ...
360 @endcode
361 @endWxPerlOnly
362
363 @library{wxbase}
364 @category{cfg}
365
366 @see @ref overview_i18n, @ref page_samples_internat, wxXLocale
367 */
368 class wxLocale
369 {
370 public:
371 /**
372 This is the default constructor and it does nothing to initialize the object:
373 Init() must be used to do that.
374 */
375 wxLocale();
376
377 /**
378 See Init() for parameters description.
379 */
380 wxLocale(int language,
381 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
382
383 /**
384 See Init() for parameters description.
385
386 The call of this function has several global side effects which you should
387 understand: first of all, the application locale is changed - note that this
388 will affect many of standard C library functions such as printf() or strftime().
389 Second, this wxLocale object becomes the new current global locale for the
390 application and so all subsequent calls to ::wxGetTranslation() will try to
391 translate the messages using the message catalogs for this locale.
392 */
393 wxLocale(const wxString& name,
394 const wxString& short = wxEmptyString,
395 const wxString& locale = wxEmptyString,
396 bool bLoadDefault = true,
397 bool bConvertEncoding = false);
398
399 /**
400 The destructor, like the constructor, also has global side effects: the
401 previously set locale is restored and so the changes described in
402 Init() documentation are rolled back.
403 */
404 virtual ~wxLocale();
405
406 /**
407 Add a catalog for use with the current locale: it is searched for in standard
408 places (current directory first, then the system one), but you may also prepend
409 additional directories to the search path with AddCatalogLookupPathPrefix().
410
411 All loaded catalogs will be used for message lookup by GetString() for
412 the current locale.
413
414 In this overload, @c msgid strings are assumed
415 to be in English and written only using 7-bit ASCII characters.
416 If you have to deal with non-English strings or 8-bit characters in the
417 source code, see the instructions in @ref overview_nonenglish.
418
419 @return
420 @true if catalog was successfully loaded, @false otherwise (which might
421 mean that the catalog is not found or that it isn't in the correct format).
422 */
423 bool AddCatalog(const wxString& domain);
424
425 /**
426 Add a catalog for use with the current locale: it is searched for in standard
427 places (current directory first, then the system one), but you may also prepend
428 additional directories to the search path with AddCatalogLookupPathPrefix().
429
430 All loaded catalogs will be used for message lookup by GetString() for
431 the current locale.
432
433 This overload takes two additional arguments, @a msgIdLanguage and @a msgIdCharset.
434
435 @param domain
436 The catalog domain to add.
437
438 @param msgIdLanguage
439 Specifies the language of "msgid" strings in source code
440 (i.e. arguments to GetString(), wxGetTranslation() and the _() macro).
441 It is used if AddCatalog() cannot find any catalog for current language:
442 if the language is same as source code language, then strings from source
443 code are used instead.
444
445 @param msgIdCharset
446 Lets you specify the charset used for msgids in sources
447 in case they use 8-bit characters (e.g. German or French strings).
448 This argument has no effect in Unicode build, because literals in sources are
449 Unicode strings; you have to use compiler-specific method of setting the right
450 charset when compiling with Unicode.
451
452 @return
453 @true if catalog was successfully loaded, @false otherwise (which might
454 mean that the catalog is not found or that it isn't in the correct format).
455 */
456 bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage,
457 const wxString& msgIdCharset);
458
459 /**
460 Add a prefix to the catalog lookup path: the message catalog files will
461 be looked up under prefix/lang/LC_MESSAGES, prefix/lang and prefix
462 (in this order).
463
464 This only applies to subsequent invocations of AddCatalog().
465 */
466 static void AddCatalogLookupPathPrefix(const wxString& prefix);
467
468 /**
469 Adds custom, user-defined language to the database of known languages.
470 This database is used in conjunction with the first form of Init().
471 */
472 static void AddLanguage(const wxLanguageInfo& info);
473
474 /**
475 This function may be used to find the language description structure for the
476 given locale, specified either as a two letter ISO language code (for example,
477 "pt"), a language code followed by the country code ("pt_BR") or a full, human
478 readable, language description ("Portuguese-Brazil").
479
480 Returns the information for the given language or @NULL if this language
481 is unknown. Note that even if the returned pointer is valid, the caller
482 should @e not delete it.
483
484 @see GetLanguageInfo()
485 */
486 static const wxLanguageInfo* FindLanguageInfo(const wxString& locale);
487
488 /**
489 Returns the canonical form of current locale name. Canonical form is the
490 one that is used on UNIX systems: it is a two- or five-letter string in xx or
491 xx_YY format, where xx is ISO 639 code of language and YY is ISO 3166 code of
492 the country. Examples are "en", "en_GB", "en_US" or "fr_FR".
493 This form is internally used when looking up message catalogs.
494 Compare GetSysName().
495 */
496 wxString GetCanonicalName() const;
497
498 /**
499 Returns the header value for header @a header.
500 The search for @a header is case sensitive. If an @a domain is passed,
501 this domain is searched. Else all domains will be searched until a
502 header has been found.
503
504 The return value is the value of the header if found. Else this will be empty.
505 */
506 wxString GetHeaderValue(const wxString& header,
507 const wxString& domain = wxEmptyString) const;
508
509 /**
510 Returns the ::wxLanguage constant of current language.
511
512 Note that you can call this function only if you used the form of
513 Init() that takes ::wxLanguage argument.
514 */
515 int GetLanguage() const;
516
517 /**
518 Returns a pointer to wxLanguageInfo structure containing information about
519 the given language or @NULL if this language is unknown. Note that even if
520 the returned pointer is valid, the caller should @e not delete it.
521
522 See AddLanguage() for the wxLanguageInfo description.
523 As with Init(), @c wxLANGUAGE_DEFAULT has the special meaning if passed
524 as an argument to this function and in this case the result of
525 GetSystemLanguage() is used.
526 */
527 static const wxLanguageInfo* GetLanguageInfo(int lang);
528
529 /**
530 Returns English name of the given language or empty string if this
531 language is unknown.
532
533 See GetLanguageInfo() for a remark about special meaning of @c wxLANGUAGE_DEFAULT.
534 */
535 static wxString GetLanguageName(int lang);
536
537 /**
538 Returns the locale name as passed to the constructor or Init().
539
540 This is a full, human-readable name, e.g. "English" or "French".
541 */
542 const wxString& GetLocale() const;
543
544 /**
545 Returns the current short name for the locale (as given to the constructor or
546 the Init() function).
547 */
548 const wxString& GetName() const;
549
550 /**
551 Retrieves the translation for a string in all loaded domains unless the @a domain
552 parameter is specified (and then only this catalog/domain is searched).
553
554 Returns original string if translation is not available (in this case an
555 error message is generated the first time a string is not found; use
556 wxLogNull to suppress it).
557
558 @remarks Domains are searched in the last to first order, i.e. catalogs
559 added later override those added before.
560 */
561 virtual const wxString& GetString(const wxString& origString,
562 const wxString& domain = wxEmptyString) const;
563
564 /**
565 Retrieves the translation for a string in all loaded domains unless the @a domain
566 parameter is specified (and then only this catalog/domain is searched).
567
568 Returns original string if translation is not available (in this case an
569 error message is generated the first time a string is not found; use
570 wxLogNull to suppress it).
571
572 This form is used when retrieving translation of string that has different
573 singular and plural form in English or different plural forms in some
574 other language.
575 It takes two extra arguments: @a origString parameter must contain the
576 singular form of the string to be converted.
577
578 It is also used as the key for the search in the catalog.
579 The @a origString2 parameter is the plural form (in English).
580
581 The parameter @a n is used to determine the plural form.
582 If no message catalog is found @a origString is returned if 'n == 1',
583 otherwise @a origString2.
584
585 See GNU gettext manual for additional information on plural forms handling.
586 This method is called by the wxGetTranslation() function and _() macro.
587
588 @remarks Domains are searched in the last to first order, i.e. catalogs
589 added later override those added before.
590 */
591 virtual const wxString& GetString(const wxString& origString,
592 const wxString& origString2, size_t n,
593 const wxString& domain = wxEmptyString) const;
594
595 /**
596 Returns current platform-specific locale name as passed to setlocale().
597 Compare GetCanonicalName().
598 */
599 wxString GetSysName() const;
600
601 /**
602 Tries to detect the user's default font encoding.
603 Returns wxFontEncoding() value or @c wxFONTENCODING_SYSTEM if it
604 couldn't be determined.
605 */
606 static wxFontEncoding GetSystemEncoding();
607
608 /**
609 Tries to detect the name of the user's default font encoding.
610 This string isn't particularly useful for the application as its form is
611 platform-dependent and so you should probably use GetSystemEncoding() instead.
612
613 Returns a user-readable string value or an empty string if it couldn't be
614 determined.
615 */
616 static wxString GetSystemEncodingName();
617
618 /**
619 Tries to detect the user's default language setting.
620 Returns the ::wxLanguage value or @b wxLANGUAGE_UNKNOWN if the language-guessing
621 algorithm failed.
622 */
623 static int GetSystemLanguage();
624
625 /**
626 Initializes the wxLocale instance.
627
628 The call of this function has several global side effects which you should
629 understand: first of all, the application locale is changed - note that
630 this will affect many of standard C library functions such as printf()
631 or strftime().
632 Second, this wxLocale object becomes the new current global locale for
633 the application and so all subsequent calls to wxGetTranslation() will
634 try to translate the messages using the message catalogs for this locale.
635
636 @param language
637 ::wxLanguage identifier of the locale.
638 @c wxLANGUAGE_DEFAULT has special meaning -- wxLocale will use system's
639 default language (see GetSystemLanguage()).
640 @param flags
641 Combination of the following:
642 - wxLOCALE_LOAD_DEFAULT: Load the message catalog for the given locale
643 containing the translations of standard wxWidgets messages
644 automatically.
645 - wxLOCALE_CONV_ENCODING: Automatically convert message catalogs to
646 platform's default encoding. Note that it will do only basic
647 conversion between well-known pair like iso8859-1 and windows-1252 or
648 iso8859-2 and windows-1250. See @ref overview_nonenglish for
649 detailed description of this behaviour.
650 Note that this flag is meaningless in Unicode build.
651
652 @return @true on success or @false if the given locale couldn't be set.
653 */
654 bool Init(int language = wxLANGUAGE_DEFAULT,
655 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
656
657 /**
658 @deprecated
659 This form is deprecated, use the other one unless you know what you are doing.
660
661 @param name
662 The name of the locale. Only used in diagnostic messages.
663 @param short
664 The standard 2 letter locale abbreviation; it is used as the
665 directory prefix when looking for the message catalog files.
666 @param locale
667 The parameter for the call to setlocale().
668 Note that it is platform-specific.
669 @param bLoadDefault
670 May be set to @false to prevent loading of the message catalog for the
671 given locale containing the translations of standard wxWidgets messages.
672 This parameter would be rarely used in normal circumstances.
673 @param bConvertEncoding
674 May be set to @true to do automatic conversion of message catalogs to
675 platform's native encoding. Note that it will do only basic conversion
676 between well-known pair like iso8859-1 and windows-1252 or iso8859-2
677 and windows-1250.
678 See @ref overview_nonenglish for detailed description of this behaviour.
679 */
680 bool Init(const wxString& name, const wxString& short = wxEmptyString,
681 const wxString& locale = wxEmptyString, bool bLoadDefault = true,
682 bool bConvertEncoding = false);
683
684 /**
685 Check whether the operating system and/or C run time environment supports
686 this locale. For example in Windows 2000 and Windows XP, support for many
687 locales is not installed by default. Returns @true if the locale is
688 supported.
689
690 The argument @a lang is the ::wxLanguage identifier. To obtain this for a
691 given a two letter ISO language code, use FindLanguageInfo() to obtain its
692 wxLanguageInfo structure.
693 See AddLanguage() for the wxLanguageInfo description.
694
695 @since 2.7.1.
696 */
697 static bool IsAvailable(int lang);
698
699 /**
700 Check if the given catalog is loaded, and returns @true if it is.
701
702 According to GNU gettext tradition, each catalog normally corresponds to
703 'domain' which is more or less the application name.
704
705 @see AddCatalog()
706 */
707 bool IsLoaded(const wxString& domain) const;
708
709 /**
710 Returns @true if the locale could be set successfully.
711 */
712 bool IsOk() const;
713 };
714
715
716
717
718 // ============================================================================
719 // Global functions/macros
720 // ============================================================================
721
722 /** @addtogroup group_funcmacro_string */
723 //@{
724
725 /**
726 This macro is identical to _() but for the plural variant of
727 wxGetTranslation().
728
729 @return A const wxString.
730
731 @header{wx/intl.h}
732 */
733 #define wxPLURAL(string, plural, n)
734
735 /**
736 This macro doesn't do anything in the program code -- it simply expands to
737 the value of its argument.
738
739 However it does have a purpose which is to mark the literal strings for the
740 extraction into the message catalog created by @c xgettext program. Usually
741 this is achieved using _() but that macro not only marks the string for
742 extraction but also expands into a wxGetTranslation() call which means that
743 it cannot be used in some situations, notably for static array
744 initialization.
745
746 Here is an example which should make it more clear: suppose that you have a
747 static array of strings containing the weekday names and which have to be
748 translated (note that it is a bad example, really, as wxDateTime already
749 can be used to get the localized week day names already). If you write:
750
751 @code
752 static const char * const weekdays[] = { _("Mon"), ..., _("Sun") };
753 ...
754 // use weekdays[n] as usual
755 @endcode
756
757 The code wouldn't compile because the function calls are forbidden in the
758 array initializer. So instead you should do this:
759
760 @code
761 static const char * const weekdays[] = { wxTRANSLATE("Mon"), ...,
762 wxTRANSLATE("Sun") };
763 ...
764 // use wxGetTranslation(weekdays[n])
765 @endcode
766
767 Note that although the code @b would compile if you simply omit
768 wxTRANSLATE() in the above, it wouldn't work as expected because there
769 would be no translations for the weekday names in the program message
770 catalog and wxGetTranslation() wouldn't find them.
771
772 @return A const wxChar*.
773
774 @header{wx/intl.h}
775 */
776 #define wxTRANSLATE(string)
777
778 /**
779 This function returns the translation of @a string in the current
780 @c locale(). If the string is not found in any of the loaded message
781 catalogs (see @ref overview_i18n), the original string is returned. In
782 debug build, an error message is logged -- this should help to find the
783 strings which were not yet translated. If @a domain is specified then only
784 that domain/catalog is searched for a matching string. As this function is
785 used very often, an alternative (and also common in Unix world) syntax is
786 provided: the _() macro is defined to do the same thing as
787 wxGetTranslation().
788
789 This function calls wxLocale::GetString().
790
791 @note This function is not suitable for literal strings in Unicode builds
792 since the literal strings must be enclosed into _T() or wxT() macro
793 which makes them unrecognised by @c xgettext, and so they are not
794 extracted to the message catalog. Instead, use the _() and wxPLURAL()
795 macro for all literal strings.
796
797 @see wxGetTranslation(const wxString&, const wxString&, size_t, const wxString&)
798
799 @header{wx/intl.h}
800 */
801 const wxString& wxGetTranslation(const wxString& string,
802 const wxString& domain = wxEmptyString);
803
804 /**
805 This is an overloaded version of
806 wxGetTranslation(const wxString&, const wxString&), please see its
807 documentation for general information.
808
809 This version is used when retrieving translation of string that has
810 different singular and plural forms in English or different plural forms in
811 some other language. Like wxGetTranslation(const wxString&,const wxString&),
812 the @a string parameter must contain the singular form of the string to be
813 converted and is used as the key for the search in the catalog. The
814 @a plural parameter is the plural form (in English). The parameter @a n is
815 used to determine the plural form. If no message catalog is found,
816 @a string is returned if "n == 1", otherwise @a plural is returned.
817
818 See GNU gettext Manual for additional information on plural forms handling:
819 <http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms>
820 For a shorter alternative see the wxPLURAL() macro.
821
822 This function calls wxLocale::GetString().
823
824 @header{wx/intl.h}
825 */
826 const wxString& wxGetTranslation(const wxString& string,
827 const wxString& plural, size_t n,
828 const wxString& domain = wxEmptyString);
829
830 /**
831 This macro expands into a call to wxGetTranslation(), so it marks the
832 message for the extraction by @c xgettext just as wxTRANSLATE() does, but
833 also returns the translation of the string for the current locale during
834 execution.
835
836 Don't confuse this with _T()!
837
838 @header{wx/intl.h}
839 */
840 const wxString& _(const wxString& string);
841
842 //@}
843