]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/intl.h
extract the important overviews in their own section and order them by importance
[wxWidgets.git] / interface / wx / intl.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: intl.h
e54c96f1 3// Purpose: interface of wxLocale
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
969daeea
FM
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*/
18enum wxLanguage
19{
336aecf1 20 /// User's default/preferred language as got from OS.
969daeea
FM
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
f045c7f5
FM
265/**
266 This is the layout direction stored in wxLanguageInfo and returned by
51c0d02b
FM
267 wxApp::GetLayoutDirection(), wxWindow::GetLayoutDirection(),
268 wxDC::GetLayoutDirection() for RTL (right-to-left) languages support.
f045c7f5
FM
269*/
270enum wxLayoutDirection
271{
272 wxLayout_Default,
273 wxLayout_LeftToRight,
274 wxLayout_RightToLeft
275};
276
969daeea 277/**
d5c8403a 278 wxLanguageInfo: encapsulates ::wxLanguage to OS native lang.desc.
969daeea
FM
279 translation information
280*/
281struct WXDLLIMPEXP_BASE wxLanguageInfo
282{
d5c8403a 283 /// ::wxLanguage id. It should be greater than wxLANGUAGE_USER_DEFINED.
969daeea
FM
284 int Language;
285 wxString CanonicalName; //!< Canonical name, e.g. fr_FR.
286#ifdef __WXMSW__
287 wxUint32 WinLang, //!< Win32 language identifiers (LANG_xxxx, SUBLANG_xxxx).
288 WinSublang;
289#endif // __WXMSW__
290 wxString Description; //!< Human-readable name of the language.
291 wxLayoutDirection LayoutDirection;
292
293#ifdef __WXMSW__
294 /// Return the LCID corresponding to this language.
295 wxUint32 GetLCID() const;
296#endif // __WXMSW__
297
298 /// Return the locale name corresponding to this language usable with
299 /// setlocale() on the current system
300 wxString GetLocaleName() const;
301};
302
303
23324ae1
FM
304/**
305 @class wxLocale
7c913512 306
23324ae1
FM
307 wxLocale class encapsulates all language-dependent settings and is a
308 generalization of the C locale concept.
7c913512 309
23324ae1
FM
310 In wxWidgets this class manages message catalogs which contain the translations
311 of the strings used to the current language.
7c913512 312
969daeea
FM
313 For a list of the supported languages, please see ::wxLanguage enum values.
314 These constants may be used to specify the language in wxLocale::Init and
315 are returned by wxLocale::GetSystemLanguage.
316
317 @beginWxPerlOnly
318 In wxPerl you can't use the '_' function name, so
7c913512
FM
319 the @c Wx::Locale module can export the @c gettext and
320 @c gettext_noop under any given name.
321
23324ae1 322 @code
969daeea 323 # this imports gettext ( equivalent to Wx::GetTranslation
23324ae1
FM
324 # and gettext_noop ( a noop )
325 # into your module
326 use Wx::Locale qw(:default);
7c913512 327
23324ae1 328 # ....
7c913512 329
23324ae1 330 # use the functions
cdbcf4c2 331 print gettext( "Panic!" );
7c913512 332
cdbcf4c2 333 button = Wx::Button-new( window, -1, gettext( "Label" ) );
23324ae1 334 @endcode
7c913512 335
23324ae1
FM
336 If you need to translate a lot of strings, then adding gettext( ) around
337 each one is a long task ( that is why _( ) was introduced ), so just choose
338 a shorter name for gettext:
7c913512 339
23324ae1 340 @code
23324ae1
FM
341 use Wx::Locale 'gettext' = 't',
342 'gettext_noop' = 'gettext_noop';
7c913512 343
23324ae1 344 # ...
7c913512 345
23324ae1 346 # use the functions
cdbcf4c2 347 print t( "Panic!!" );
7c913512 348
23324ae1
FM
349 # ...
350 @endcode
969daeea 351 @endWxPerlOnly
7c913512 352
23324ae1 353 @library{wxbase}
969daeea 354 @category{misc}
7c913512 355
89bb3f02 356 @see @ref overview_i18n, @ref page_samples_internat, wxXLocale
23324ae1 357*/
7c913512 358class wxLocale
23324ae1
FM
359{
360public:
969daeea
FM
361 /**
362 This is the default constructor and it does nothing to initialize the object:
363 Init() must be used to do that.
364 */
365 wxLocale();
366
367 /**
368 See Init() for parameters description.
369 */
370 wxLocale(int language,
371 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
372
23324ae1
FM
373 /**
374 See Init() for parameters description.
969daeea 375
23324ae1
FM
376 The call of this function has several global side effects which you should
377 understand: first of all, the application locale is changed - note that this
378 will affect many of standard C library functions such as printf() or strftime().
379 Second, this wxLocale object becomes the new current global locale for the
969daeea 380 application and so all subsequent calls to ::wxGetTranslation() will try to
23324ae1
FM
381 translate the messages using the message catalogs for this locale.
382 */
7c913512
FM
383 wxLocale(const wxString& name,
384 const wxString& short = wxEmptyString,
385 const wxString& locale = wxEmptyString,
4cc4bfaf
FM
386 bool bLoadDefault = true,
387 bool bConvertEncoding = false);
23324ae1
FM
388
389 /**
390 The destructor, like the constructor, also has global side effects: the
969daeea 391 previously set locale is restored and so the changes described in
23324ae1
FM
392 Init() documentation are rolled back.
393 */
adaaa686 394 virtual ~wxLocale();
23324ae1 395
23324ae1
FM
396 /**
397 Add a catalog for use with the current locale: it is searched for in standard
398 places (current directory first, then the system one), but you may also prepend
969daeea
FM
399 additional directories to the search path with AddCatalogLookupPathPrefix().
400
401 All loaded catalogs will be used for message lookup by GetString() for
402 the current locale.
403
a0a4c5aa 404 In this overload, @c msgid strings are assumed
23324ae1 405 to be in English and written only using 7-bit ASCII characters.
969daeea
FM
406 If you have to deal with non-English strings or 8-bit characters in the
407 source code, see the instructions in @ref overview_nonenglish.
a0a4c5aa
FM
408
409 @return
410 @true if catalog was successfully loaded, @false otherwise (which might
411 mean that the catalog is not found or that it isn't in the correct format).
23324ae1
FM
412 */
413 bool AddCatalog(const wxString& domain);
a0a4c5aa
FM
414
415 /**
416 Add a catalog for use with the current locale: it is searched for in standard
417 places (current directory first, then the system one), but you may also prepend
418 additional directories to the search path with AddCatalogLookupPathPrefix().
419
420 All loaded catalogs will be used for message lookup by GetString() for
421 the current locale.
422
423 This overload takes two additional arguments, @a msgIdLanguage and @a msgIdCharset.
424
e2c4ccaf
FM
425 @param domain
426 The catalog domain to add.
427
a0a4c5aa
FM
428 @param msgIdLanguage
429 Specifies the language of "msgid" strings in source code
430 (i.e. arguments to GetString(), wxGetTranslation() and the _() macro).
431 It is used if AddCatalog() cannot find any catalog for current language:
432 if the language is same as source code language, then strings from source
433 code are used instead.
434
435 @param msgIdCharset
436 Lets you specify the charset used for msgids in sources
437 in case they use 8-bit characters (e.g. German or French strings).
438 This argument has no effect in Unicode build, because literals in sources are
439 Unicode strings; you have to use compiler-specific method of setting the right
440 charset when compiling with Unicode.
441
442 @return
443 @true if catalog was successfully loaded, @false otherwise (which might
444 mean that the catalog is not found or that it isn't in the correct format).
445 */
969daeea 446 bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage,
7c913512 447 const wxString& msgIdCharset);
23324ae1
FM
448
449 /**
969daeea
FM
450 Add a prefix to the catalog lookup path: the message catalog files will
451 be looked up under prefix/lang/LC_MESSAGES, prefix/lang and prefix
23324ae1 452 (in this order).
969daeea 453
23324ae1
FM
454 This only applies to subsequent invocations of AddCatalog().
455 */
adaaa686 456 static void AddCatalogLookupPathPrefix(const wxString& prefix);
23324ae1
FM
457
458 /**
969daeea
FM
459 Adds custom, user-defined language to the database of known languages.
460 This database is used in conjunction with the first form of Init().
23324ae1
FM
461 */
462 static void AddLanguage(const wxLanguageInfo& info);
463
464 /**
465 This function may be used to find the language description structure for the
466 given locale, specified either as a two letter ISO language code (for example,
467 "pt"), a language code followed by the country code ("pt_BR") or a full, human
468 readable, language description ("Portuguese-Brazil").
969daeea 469
23324ae1 470 Returns the information for the given language or @NULL if this language
969daeea
FM
471 is unknown. Note that even if the returned pointer is valid, the caller
472 should @e not delete it.
3c4f71cc 473
4cc4bfaf 474 @see GetLanguageInfo()
23324ae1 475 */
382f12e4 476 static const wxLanguageInfo* FindLanguageInfo(const wxString& locale);
23324ae1
FM
477
478 /**
479 Returns the canonical form of current locale name. Canonical form is the
480 one that is used on UNIX systems: it is a two- or five-letter string in xx or
481 xx_YY format, where xx is ISO 639 code of language and YY is ISO 3166 code of
482 the country. Examples are "en", "en_GB", "en_US" or "fr_FR".
23324ae1 483 This form is internally used when looking up message catalogs.
23324ae1
FM
484 Compare GetSysName().
485 */
328f5751 486 wxString GetCanonicalName() const;
23324ae1
FM
487
488 /**
969daeea
FM
489 Returns the header value for header @a header.
490 The search for @a header is case sensitive. If an @a domain is passed,
491 this domain is searched. Else all domains will be searched until a
23324ae1 492 header has been found.
969daeea 493
23324ae1
FM
494 The return value is the value of the header if found. Else this will be empty.
495 */
496 wxString GetHeaderValue(const wxString& header,
328f5751 497 const wxString& domain = wxEmptyString) const;
23324ae1
FM
498
499 /**
d5c8403a 500 Returns the ::wxLanguage constant of current language.
969daeea 501
23324ae1 502 Note that you can call this function only if you used the form of
d5c8403a 503 Init() that takes ::wxLanguage argument.
23324ae1 504 */
328f5751 505 int GetLanguage() const;
23324ae1
FM
506
507 /**
969daeea
FM
508 Returns a pointer to wxLanguageInfo structure containing information about
509 the given language or @NULL if this language is unknown. Note that even if
510 the returned pointer is valid, the caller should @e not delete it.
511
512 See AddLanguage() for the wxLanguageInfo description.
513 As with Init(), @c wxLANGUAGE_DEFAULT has the special meaning if passed
514 as an argument to this function and in this case the result of
515 GetSystemLanguage() is used.
23324ae1 516 */
57bf907d 517 static const wxLanguageInfo* GetLanguageInfo(int lang);
23324ae1
FM
518
519 /**
520 Returns English name of the given language or empty string if this
521 language is unknown.
969daeea
FM
522
523 See GetLanguageInfo() for a remark about special meaning of @c wxLANGUAGE_DEFAULT.
23324ae1 524 */
57bf907d 525 static wxString GetLanguageName(int lang);
23324ae1
FM
526
527 /**
969daeea
FM
528 Returns the locale name as passed to the constructor or Init().
529
530 This is a full, human-readable name, e.g. "English" or "French".
23324ae1 531 */
969daeea 532 const wxString& GetLocale() const;
23324ae1
FM
533
534 /**
535 Returns the current short name for the locale (as given to the constructor or
536 the Init() function).
537 */
969daeea 538 const wxString& GetName() const;
23324ae1 539
23324ae1 540 /**
969daeea 541 Retrieves the translation for a string in all loaded domains unless the @a domain
23324ae1 542 parameter is specified (and then only this catalog/domain is searched).
969daeea
FM
543
544 Returns original string if translation is not available (in this case an
545 error message is generated the first time a string is not found; use
546 wxLogNull to suppress it).
547
548 @remarks Domains are searched in the last to first order, i.e. catalogs
549 added later override those added before.
550 */
fadc2df6
FM
551 virtual const wxString& GetString(const wxString& origString,
552 const wxString& domain = wxEmptyString) const;
969daeea
FM
553
554 /**
555 Retrieves the translation for a string in all loaded domains unless the @a domain
556 parameter is specified (and then only this catalog/domain is searched).
557
558 Returns original string if translation is not available (in this case an
559 error message is generated the first time a string is not found; use
560 wxLogNull to suppress it).
561
562 This form is used when retrieving translation of string that has different
563 singular and plural form in English or different plural forms in some
564 other language.
565 It takes two extra arguments: @a origString parameter must contain the
566 singular form of the string to be converted.
567
23324ae1 568 It is also used as the key for the search in the catalog.
4cc4bfaf 569 The @a origString2 parameter is the plural form (in English).
969daeea
FM
570
571 The parameter @a n is used to determine the plural form.
572 If no message catalog is found @a origString is returned if 'n == 1',
573 otherwise @a origString2.
574
23324ae1 575 See GNU gettext manual for additional information on plural forms handling.
969daeea 576 This method is called by the wxGetTranslation() function and _() macro.
3c4f71cc 577
23324ae1 578 @remarks Domains are searched in the last to first order, i.e. catalogs
4cc4bfaf 579 added later override those added before.
23324ae1 580 */
7323ff1a
FM
581 virtual const wxString& GetString(const wxString& origString,
582 const wxString& origString2, size_t n,
583 const wxString& domain = wxEmptyString) const;
23324ae1
FM
584
585 /**
586 Returns current platform-specific locale name as passed to setlocale().
23324ae1
FM
587 Compare GetCanonicalName().
588 */
328f5751 589 wxString GetSysName() const;
23324ae1
FM
590
591 /**
592 Tries to detect the user's default font encoding.
969daeea
FM
593 Returns wxFontEncoding() value or @c wxFONTENCODING_SYSTEM if it
594 couldn't be determined.
23324ae1 595 */
57bf907d 596 static wxFontEncoding GetSystemEncoding();
23324ae1
FM
597
598 /**
969daeea
FM
599 Tries to detect the name of the user's default font encoding.
600 This string isn't particularly useful for the application as its form is
601 platform-dependent and so you should probably use GetSystemEncoding() instead.
602
23324ae1
FM
603 Returns a user-readable string value or an empty string if it couldn't be
604 determined.
605 */
57bf907d 606 static wxString GetSystemEncodingName();
23324ae1
FM
607
608 /**
609 Tries to detect the user's default language setting.
d5c8403a 610 Returns the ::wxLanguage value or @b wxLANGUAGE_UNKNOWN if the language-guessing
969daeea 611 algorithm failed.
23324ae1 612 */
57bf907d 613 static int GetSystemLanguage();
23324ae1 614
23324ae1 615 /**
969daeea
FM
616 Initializes the wxLocale instance.
617
618 The call of this function has several global side effects which you should
619 understand: first of all, the application locale is changed - note that
620 this will affect many of standard C library functions such as printf()
621 or strftime().
622 Second, this wxLocale object becomes the new current global locale for
623 the application and so all subsequent calls to wxGetTranslation() will
624 try to translate the messages using the message catalogs for this locale.
3c4f71cc 625
7c913512 626 @param language
d5c8403a 627 ::wxLanguage identifier of the locale.
969daeea
FM
628 @c wxLANGUAGE_DEFAULT has special meaning -- wxLocale will use system's
629 default language (see GetSystemLanguage()).
7c913512 630 @param flags
4cc4bfaf 631 Combination of the following:
969daeea
FM
632 - wxLOCALE_LOAD_DEFAULT: Load the message catalog for the given locale
633 containing the translations of standard wxWidgets messages
634 automatically.
635 - wxLOCALE_CONV_ENCODING: Automatically convert message catalogs to
636 platform's default encoding. Note that it will do only basic
637 conversion between well-known pair like iso8859-1 and windows-1252 or
638 iso8859-2 and windows-1250. See @ref overview_nonenglish for
639 detailed description of this behaviour.
640 Note that this flag is meaningless in Unicode build.
89bb3f02
FM
641
642 @return @true on success or @false if the given locale couldn't be set.
643 */
644 bool Init(int language = wxLANGUAGE_DEFAULT,
645 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
646
647 /**
648 @deprecated
649 This form is deprecated, use the other one unless you know what you are doing.
650
4cc4bfaf
FM
651 @param name
652 The name of the locale. Only used in diagnostic messages.
653 @param short
654 The standard 2 letter locale abbreviation; it is used as the
655 directory prefix when looking for the message catalog files.
656 @param locale
969daeea
FM
657 The parameter for the call to setlocale().
658 Note that it is platform-specific.
4cc4bfaf 659 @param bLoadDefault
969daeea
FM
660 May be set to @false to prevent loading of the message catalog for the
661 given locale containing the translations of standard wxWidgets messages.
4cc4bfaf 662 This parameter would be rarely used in normal circumstances.
7c913512 663 @param bConvertEncoding
969daeea
FM
664 May be set to @true to do automatic conversion of message catalogs to
665 platform's native encoding. Note that it will do only basic conversion
666 between well-known pair like iso8859-1 and windows-1252 or iso8859-2
667 and windows-1250.
668 See @ref overview_nonenglish for detailed description of this behaviour.
969daeea 669 */
7323ff1a
FM
670 bool Init(const wxString& name, const wxString& short = wxEmptyString,
671 const wxString& locale = wxEmptyString, bool bLoadDefault = true,
4cc4bfaf 672 bool bConvertEncoding = false);
23324ae1
FM
673
674 /**
675 Check whether the operating system and/or C run time environment supports
676 this locale. For example in Windows 2000 and Windows XP, support for many
677 locales is not installed by default. Returns @true if the locale is
678 supported.
d5c8403a
FM
679
680 The argument @a lang is the ::wxLanguage identifier. To obtain this for a
681 given a two letter ISO language code, use FindLanguageInfo() to obtain its
682 wxLanguageInfo structure.
683 See AddLanguage() for the wxLanguageInfo description.
3c4f71cc 684
1e24c2af 685 @since 2.7.1.
23324ae1
FM
686 */
687 static bool IsAvailable(int lang);
688
689 /**
690 Check if the given catalog is loaded, and returns @true if it is.
969daeea
FM
691
692 According to GNU gettext tradition, each catalog normally corresponds to
693 'domain' which is more or less the application name.
694
695 @see AddCatalog()
23324ae1 696 */
43c48e1e 697 bool IsLoaded(const wxString& domain) const;
23324ae1
FM
698
699 /**
700 Returns @true if the locale could be set successfully.
701 */
328f5751 702 bool IsOk() const;
23324ae1
FM
703};
704
705
e54c96f1 706
e54c96f1 707
23324ae1
FM
708// ============================================================================
709// Global functions/macros
710// ============================================================================
711
b21126db 712/** @addtogroup group_funcmacro_string */
3950d49c
BP
713//@{
714
23324ae1 715/**
3950d49c
BP
716 This macro is identical to _() but for the plural variant of
717 wxGetTranslation().
718
d29a9a8a 719 @return A const wxString.
3950d49c
BP
720
721 @header{wx/intl.h}
23324ae1 722*/
3950d49c 723#define wxPLURAL(string, plural, n)
23324ae1
FM
724
725/**
3950d49c
BP
726 This macro doesn't do anything in the program code -- it simply expands to
727 the value of its argument.
728
23324ae1
FM
729 However it does have a purpose which is to mark the literal strings for the
730 extraction into the message catalog created by @c xgettext program. Usually
3950d49c
BP
731 this is achieved using _() but that macro not only marks the string for
732 extraction but also expands into a wxGetTranslation() call which means that
733 it cannot be used in some situations, notably for static array
23324ae1 734 initialization.
3950d49c 735
23324ae1
FM
736 Here is an example which should make it more clear: suppose that you have a
737 static array of strings containing the weekday names and which have to be
3950d49c
BP
738 translated (note that it is a bad example, really, as wxDateTime already
739 can be used to get the localized week day names already). If you write:
4cc4bfaf 740
23324ae1
FM
741 @code
742 static const char * const weekdays[] = { _("Mon"), ..., _("Sun") };
743 ...
744 // use weekdays[n] as usual
745 @endcode
7c913512 746
3950d49c
BP
747 The code wouldn't compile because the function calls are forbidden in the
748 array initializer. So instead you should do this:
4cc4bfaf 749
23324ae1
FM
750 @code
751 static const char * const weekdays[] = { wxTRANSLATE("Mon"), ...,
752 wxTRANSLATE("Sun") };
753 ...
754 // use wxGetTranslation(weekdays[n])
755 @endcode
7c913512 756
23324ae1 757 Note that although the code @b would compile if you simply omit
3950d49c
BP
758 wxTRANSLATE() in the above, it wouldn't work as expected because there
759 would be no translations for the weekday names in the program message
760 catalog and wxGetTranslation() wouldn't find them.
761
d29a9a8a 762 @return A const wxChar*.
3950d49c
BP
763
764 @header{wx/intl.h}
23324ae1 765*/
3950d49c 766#define wxTRANSLATE(string)
23324ae1
FM
767
768/**
3950d49c
BP
769 This function returns the translation of @a string in the current
770 @c locale(). If the string is not found in any of the loaded message
771 catalogs (see @ref overview_i18n), the original string is returned. In
772 debug build, an error message is logged -- this should help to find the
773 strings which were not yet translated. If @a domain is specified then only
774 that domain/catalog is searched for a matching string. As this function is
775 used very often, an alternative (and also common in Unix world) syntax is
776 provided: the _() macro is defined to do the same thing as
777 wxGetTranslation().
778
779 This function calls wxLocale::GetString().
780
781 @note This function is not suitable for literal strings in Unicode builds
782 since the literal strings must be enclosed into _T() or wxT() macro
783 which makes them unrecognised by @c xgettext, and so they are not
784 extracted to the message catalog. Instead, use the _() and wxPLURAL()
785 macro for all literal strings.
786
787 @see wxGetTranslation(const wxString&, const wxString&, size_t, const wxString&)
788
789 @header{wx/intl.h}
23324ae1 790*/
969daeea 791const wxString& wxGetTranslation(const wxString& string,
3950d49c 792 const wxString& domain = wxEmptyString);
23324ae1 793
23324ae1 794/**
3950d49c
BP
795 This is an overloaded version of
796 wxGetTranslation(const wxString&, const wxString&), please see its
797 documentation for general information.
798
799 This version is used when retrieving translation of string that has
800 different singular and plural forms in English or different plural forms in
801 some other language. Like wxGetTranslation(const wxString&,const wxString&),
802 the @a string parameter must contain the singular form of the string to be
803 converted and is used as the key for the search in the catalog. The
804 @a plural parameter is the plural form (in English). The parameter @a n is
805 used to determine the plural form. If no message catalog is found,
806 @a string is returned if "n == 1", otherwise @a plural is returned.
807
808 See GNU gettext Manual for additional information on plural forms handling:
809 <http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms>
810 For a shorter alternative see the wxPLURAL() macro.
811
812 This function calls wxLocale::GetString().
813
814 @header{wx/intl.h}
23324ae1 815*/
969daeea 816const wxString& wxGetTranslation(const wxString& string,
3950d49c
BP
817 const wxString& plural, size_t n,
818 const wxString& domain = wxEmptyString);
819
820/**
821 This macro expands into a call to wxGetTranslation(), so it marks the
822 message for the extraction by @c xgettext just as wxTRANSLATE() does, but
823 also returns the translation of the string for the current locale during
824 execution.
825
826 Don't confuse this with _T()!
827
828 @header{wx/intl.h}
829*/
969daeea 830const wxString& _(const wxString& string);
3950d49c 831
23324ae1
FM
832//@}
833