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