]> git.saurik.com Git - wxWidgets.git/blame - include/wx/intl.h
Don't rely on __GXX_RTTI being defined with g++ < 4.3.
[wxWidgets.git] / include / wx / intl.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
58d5dfc1 2// Name: wx/intl.h
77ffb593 3// Purpose: Internationalization and localisation for wxWidgets
c801d85f 4// Author: Vadim Zeitlin
849a28d0
VS
5// Modified by: Michael N. Filippov <michael@idisys.iae.nsk.su>
6// (2003/09/30 - plural forms support)
c801d85f
KB
7// Created: 29/01/98
8// RCS-ID: $Id$
9// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
b5e2a450
VZ
13// WARNING: Parts of this file are generated. See misc/languages/README for
14// details.
15
dccce9ea
VZ
16#ifndef _WX_INTL_H_
17#define _WX_INTL_H_
c801d85f 18
c801d85f
KB
19#include "wx/defs.h"
20#include "wx/string.h"
21
b137e493
WS
22// Make wxLayoutDirection enum available without need for wxUSE_INTL so wxWindow, wxApp
23// and other classes are not distrubed by wxUSE_INTL
24
25enum wxLayoutDirection
26{
27 wxLayout_Default,
28 wxLayout_LeftToRight,
29 wxLayout_RightToLeft
30};
31
88ac883a
VZ
32#if wxUSE_INTL
33
dccce9ea
VZ
34#include "wx/fontenc.h"
35
c801d85f
KB
36// ============================================================================
37// global decls
38// ============================================================================
39
c801d85f
KB
40// ----------------------------------------------------------------------------
41// macros
42// ----------------------------------------------------------------------------
43
7beb59f3 44// gettext() style macros (notice that xgettext should be invoked with
15d06954 45// --keyword="_" --keyword="wxPLURAL:1,2" options
849a28d0 46// to extract the strings from the sources)
687d7337 47#ifndef WXINTL_NO_GETTEXT_MACRO
066f3611
VZ
48 #define _(s) wxGetTranslation((s))
49 #define wxPLURAL(sing, plur, n) wxGetTranslation((sing), (plur), n)
687d7337 50#endif
c801d85f 51
3c1866e8
VZ
52// another one which just marks the strings for extraction, but doesn't
53// perform the translation (use -kwxTRANSLATE with xgettext!)
e0749635 54#define wxTRANSLATE(str) str
3c1866e8 55
c801d85f
KB
56// ----------------------------------------------------------------------------
57// forward decls
58// ----------------------------------------------------------------------------
ec37df57 59
b5dbe15d
VS
60class WXDLLIMPEXP_FWD_BASE wxLocale;
61class WXDLLIMPEXP_FWD_BASE wxLanguageInfoArray;
64764f50 62class wxMsgCatalog;
c801d85f
KB
63
64// ============================================================================
65// locale support
66// ============================================================================
67
fda91381
VS
68// ----------------------------------------------------------------------------
69// wxLanguage: defines all supported languages
70// ----------------------------------------------------------------------------
71
41780009 72// --- --- --- generated code begins here --- --- ---
fda91381 73
86c30bc5
VZ
74/**
75 The languages supported by wxLocale.
76
77 This enum is generated by misc/languages/genlang.py
78 When making changes, please put them into misc/languages/langtabl.txt
79*/
fda91381
VS
80enum wxLanguage
81{
86c30bc5 82 /// User's default/preffered language as got from OS.
58d5dfc1 83 wxLANGUAGE_DEFAULT,
86c30bc5
VZ
84
85 /// Unknown language, returned if wxLocale::GetSystemLanguage fails.
58d5dfc1
VZ
86 wxLANGUAGE_UNKNOWN,
87
fda91381
VS
88 wxLANGUAGE_ABKHAZIAN,
89 wxLANGUAGE_AFAR,
90 wxLANGUAGE_AFRIKAANS,
91 wxLANGUAGE_ALBANIAN,
92 wxLANGUAGE_AMHARIC,
93 wxLANGUAGE_ARABIC,
94 wxLANGUAGE_ARABIC_ALGERIA,
95 wxLANGUAGE_ARABIC_BAHRAIN,
96 wxLANGUAGE_ARABIC_EGYPT,
97 wxLANGUAGE_ARABIC_IRAQ,
98 wxLANGUAGE_ARABIC_JORDAN,
99 wxLANGUAGE_ARABIC_KUWAIT,
100 wxLANGUAGE_ARABIC_LEBANON,
101 wxLANGUAGE_ARABIC_LIBYA,
102 wxLANGUAGE_ARABIC_MOROCCO,
103 wxLANGUAGE_ARABIC_OMAN,
104 wxLANGUAGE_ARABIC_QATAR,
105 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
106 wxLANGUAGE_ARABIC_SUDAN,
107 wxLANGUAGE_ARABIC_SYRIA,
108 wxLANGUAGE_ARABIC_TUNISIA,
109 wxLANGUAGE_ARABIC_UAE,
110 wxLANGUAGE_ARABIC_YEMEN,
111 wxLANGUAGE_ARMENIAN,
112 wxLANGUAGE_ASSAMESE,
86c30bc5 113 wxLANGUAGE_ASTURIAN,
fda91381
VS
114 wxLANGUAGE_AYMARA,
115 wxLANGUAGE_AZERI,
116 wxLANGUAGE_AZERI_CYRILLIC,
117 wxLANGUAGE_AZERI_LATIN,
118 wxLANGUAGE_BASHKIR,
119 wxLANGUAGE_BASQUE,
120 wxLANGUAGE_BELARUSIAN,
121 wxLANGUAGE_BENGALI,
122 wxLANGUAGE_BHUTANI,
123 wxLANGUAGE_BIHARI,
124 wxLANGUAGE_BISLAMA,
125 wxLANGUAGE_BRETON,
126 wxLANGUAGE_BULGARIAN,
127 wxLANGUAGE_BURMESE,
128 wxLANGUAGE_CAMBODIAN,
129 wxLANGUAGE_CATALAN,
130 wxLANGUAGE_CHINESE,
131 wxLANGUAGE_CHINESE_SIMPLIFIED,
132 wxLANGUAGE_CHINESE_TRADITIONAL,
133 wxLANGUAGE_CHINESE_HONGKONG,
134 wxLANGUAGE_CHINESE_MACAU,
135 wxLANGUAGE_CHINESE_SINGAPORE,
136 wxLANGUAGE_CHINESE_TAIWAN,
137 wxLANGUAGE_CORSICAN,
138 wxLANGUAGE_CROATIAN,
139 wxLANGUAGE_CZECH,
140 wxLANGUAGE_DANISH,
141 wxLANGUAGE_DUTCH,
142 wxLANGUAGE_DUTCH_BELGIAN,
143 wxLANGUAGE_ENGLISH,
144 wxLANGUAGE_ENGLISH_UK,
145 wxLANGUAGE_ENGLISH_US,
146 wxLANGUAGE_ENGLISH_AUSTRALIA,
147 wxLANGUAGE_ENGLISH_BELIZE,
148 wxLANGUAGE_ENGLISH_BOTSWANA,
149 wxLANGUAGE_ENGLISH_CANADA,
150 wxLANGUAGE_ENGLISH_CARIBBEAN,
151 wxLANGUAGE_ENGLISH_DENMARK,
152 wxLANGUAGE_ENGLISH_EIRE,
153 wxLANGUAGE_ENGLISH_JAMAICA,
154 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
155 wxLANGUAGE_ENGLISH_PHILIPPINES,
156 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
157 wxLANGUAGE_ENGLISH_TRINIDAD,
158 wxLANGUAGE_ENGLISH_ZIMBABWE,
159 wxLANGUAGE_ESPERANTO,
160 wxLANGUAGE_ESTONIAN,
161 wxLANGUAGE_FAEROESE,
162 wxLANGUAGE_FARSI,
163 wxLANGUAGE_FIJI,
164 wxLANGUAGE_FINNISH,
165 wxLANGUAGE_FRENCH,
166 wxLANGUAGE_FRENCH_BELGIAN,
167 wxLANGUAGE_FRENCH_CANADIAN,
168 wxLANGUAGE_FRENCH_LUXEMBOURG,
169 wxLANGUAGE_FRENCH_MONACO,
170 wxLANGUAGE_FRENCH_SWISS,
171 wxLANGUAGE_FRISIAN,
172 wxLANGUAGE_GALICIAN,
173 wxLANGUAGE_GEORGIAN,
174 wxLANGUAGE_GERMAN,
175 wxLANGUAGE_GERMAN_AUSTRIAN,
176 wxLANGUAGE_GERMAN_BELGIUM,
177 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
178 wxLANGUAGE_GERMAN_LUXEMBOURG,
179 wxLANGUAGE_GERMAN_SWISS,
180 wxLANGUAGE_GREEK,
181 wxLANGUAGE_GREENLANDIC,
182 wxLANGUAGE_GUARANI,
183 wxLANGUAGE_GUJARATI,
184 wxLANGUAGE_HAUSA,
185 wxLANGUAGE_HEBREW,
186 wxLANGUAGE_HINDI,
187 wxLANGUAGE_HUNGARIAN,
188 wxLANGUAGE_ICELANDIC,
189 wxLANGUAGE_INDONESIAN,
190 wxLANGUAGE_INTERLINGUA,
191 wxLANGUAGE_INTERLINGUE,
192 wxLANGUAGE_INUKTITUT,
193 wxLANGUAGE_INUPIAK,
194 wxLANGUAGE_IRISH,
195 wxLANGUAGE_ITALIAN,
196 wxLANGUAGE_ITALIAN_SWISS,
197 wxLANGUAGE_JAPANESE,
198 wxLANGUAGE_JAVANESE,
199 wxLANGUAGE_KANNADA,
200 wxLANGUAGE_KASHMIRI,
201 wxLANGUAGE_KASHMIRI_INDIA,
202 wxLANGUAGE_KAZAKH,
203 wxLANGUAGE_KERNEWEK,
204 wxLANGUAGE_KINYARWANDA,
205 wxLANGUAGE_KIRGHIZ,
206 wxLANGUAGE_KIRUNDI,
207 wxLANGUAGE_KONKANI,
208 wxLANGUAGE_KOREAN,
209 wxLANGUAGE_KURDISH,
210 wxLANGUAGE_LAOTHIAN,
211 wxLANGUAGE_LATIN,
212 wxLANGUAGE_LATVIAN,
213 wxLANGUAGE_LINGALA,
214 wxLANGUAGE_LITHUANIAN,
215 wxLANGUAGE_MACEDONIAN,
216 wxLANGUAGE_MALAGASY,
217 wxLANGUAGE_MALAY,
218 wxLANGUAGE_MALAYALAM,
219 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
220 wxLANGUAGE_MALAY_MALAYSIA,
221 wxLANGUAGE_MALTESE,
222 wxLANGUAGE_MANIPURI,
223 wxLANGUAGE_MAORI,
224 wxLANGUAGE_MARATHI,
225 wxLANGUAGE_MOLDAVIAN,
226 wxLANGUAGE_MONGOLIAN,
227 wxLANGUAGE_NAURU,
228 wxLANGUAGE_NEPALI,
229 wxLANGUAGE_NEPALI_INDIA,
230 wxLANGUAGE_NORWEGIAN_BOKMAL,
231 wxLANGUAGE_NORWEGIAN_NYNORSK,
232 wxLANGUAGE_OCCITAN,
233 wxLANGUAGE_ORIYA,
234 wxLANGUAGE_OROMO,
235 wxLANGUAGE_PASHTO,
236 wxLANGUAGE_POLISH,
237 wxLANGUAGE_PORTUGUESE,
238 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
239 wxLANGUAGE_PUNJABI,
240 wxLANGUAGE_QUECHUA,
241 wxLANGUAGE_RHAETO_ROMANCE,
242 wxLANGUAGE_ROMANIAN,
243 wxLANGUAGE_RUSSIAN,
244 wxLANGUAGE_RUSSIAN_UKRAINE,
7bf2b088 245 wxLANGUAGE_SAMI,
fda91381
VS
246 wxLANGUAGE_SAMOAN,
247 wxLANGUAGE_SANGHO,
248 wxLANGUAGE_SANSKRIT,
249 wxLANGUAGE_SCOTS_GAELIC,
250 wxLANGUAGE_SERBIAN,
251 wxLANGUAGE_SERBIAN_CYRILLIC,
252 wxLANGUAGE_SERBIAN_LATIN,
253 wxLANGUAGE_SERBO_CROATIAN,
254 wxLANGUAGE_SESOTHO,
255 wxLANGUAGE_SETSWANA,
256 wxLANGUAGE_SHONA,
257 wxLANGUAGE_SINDHI,
258 wxLANGUAGE_SINHALESE,
259 wxLANGUAGE_SISWATI,
260 wxLANGUAGE_SLOVAK,
261 wxLANGUAGE_SLOVENIAN,
262 wxLANGUAGE_SOMALI,
263 wxLANGUAGE_SPANISH,
264 wxLANGUAGE_SPANISH_ARGENTINA,
265 wxLANGUAGE_SPANISH_BOLIVIA,
266 wxLANGUAGE_SPANISH_CHILE,
267 wxLANGUAGE_SPANISH_COLOMBIA,
268 wxLANGUAGE_SPANISH_COSTA_RICA,
269 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
270 wxLANGUAGE_SPANISH_ECUADOR,
271 wxLANGUAGE_SPANISH_EL_SALVADOR,
272 wxLANGUAGE_SPANISH_GUATEMALA,
273 wxLANGUAGE_SPANISH_HONDURAS,
274 wxLANGUAGE_SPANISH_MEXICAN,
275 wxLANGUAGE_SPANISH_MODERN,
276 wxLANGUAGE_SPANISH_NICARAGUA,
277 wxLANGUAGE_SPANISH_PANAMA,
278 wxLANGUAGE_SPANISH_PARAGUAY,
279 wxLANGUAGE_SPANISH_PERU,
280 wxLANGUAGE_SPANISH_PUERTO_RICO,
281 wxLANGUAGE_SPANISH_URUGUAY,
282 wxLANGUAGE_SPANISH_US,
283 wxLANGUAGE_SPANISH_VENEZUELA,
284 wxLANGUAGE_SUNDANESE,
285 wxLANGUAGE_SWAHILI,
286 wxLANGUAGE_SWEDISH,
287 wxLANGUAGE_SWEDISH_FINLAND,
288 wxLANGUAGE_TAGALOG,
289 wxLANGUAGE_TAJIK,
290 wxLANGUAGE_TAMIL,
291 wxLANGUAGE_TATAR,
292 wxLANGUAGE_TELUGU,
293 wxLANGUAGE_THAI,
294 wxLANGUAGE_TIBETAN,
295 wxLANGUAGE_TIGRINYA,
296 wxLANGUAGE_TONGA,
297 wxLANGUAGE_TSONGA,
298 wxLANGUAGE_TURKISH,
299 wxLANGUAGE_TURKMEN,
300 wxLANGUAGE_TWI,
301 wxLANGUAGE_UIGHUR,
302 wxLANGUAGE_UKRAINIAN,
303 wxLANGUAGE_URDU,
304 wxLANGUAGE_URDU_INDIA,
305 wxLANGUAGE_URDU_PAKISTAN,
306 wxLANGUAGE_UZBEK,
307 wxLANGUAGE_UZBEK_CYRILLIC,
308 wxLANGUAGE_UZBEK_LATIN,
b5e2a450 309 wxLANGUAGE_VALENCIAN,
fda91381
VS
310 wxLANGUAGE_VIETNAMESE,
311 wxLANGUAGE_VOLAPUK,
312 wxLANGUAGE_WELSH,
313 wxLANGUAGE_WOLOF,
314 wxLANGUAGE_XHOSA,
315 wxLANGUAGE_YIDDISH,
316 wxLANGUAGE_YORUBA,
317 wxLANGUAGE_ZHUANG,
318 wxLANGUAGE_ZULU,
319
86c30bc5 320 /// For custom, user-defined languages.
fda91381
VS
321 wxLANGUAGE_USER_DEFINED
322};
323
41780009
VS
324// --- --- --- generated code ends here --- --- ---
325
fda91381
VS
326// ----------------------------------------------------------------------------
327// wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
328// translation information
329// ----------------------------------------------------------------------------
330
bddd7a8d 331struct WXDLLIMPEXP_BASE wxLanguageInfo
fda91381
VS
332{
333 int Language; // wxLanguage id
334 wxString CanonicalName; // Canonical name, e.g. fr_FR
ea65760d 335#ifdef __WXMSW__
dccce9ea
VZ
336 wxUint32 WinLang, // Win32 language identifiers
337 WinSublang;
ea65760d 338#endif // __WXMSW__
fda91381 339 wxString Description; // human-readable name of the language
978af864 340 wxLayoutDirection LayoutDirection;
ea65760d
VZ
341
342#ifdef __WXMSW__
343 // return the LCID corresponding to this language
344 wxUint32 GetLCID() const;
345#endif // __WXMSW__
86d62b51
VZ
346
347 // return the locale name corresponding to this language usable with
348 // setlocale() on the current system
349 wxString GetLocaleName() const;
fda91381
VS
350};
351
86d62b51
VZ
352// for Unix systems GetLocaleName() is trivial so implement it inline here, for
353// MSW it's implemented in intl.cpp
354#ifndef __WXMSW__
355inline wxString wxLanguageInfo::GetLocaleName() const { return CanonicalName; }
356#endif // !__WXMSW__
357
f2a139ad
VZ
358// ----------------------------------------------------------------------------
359// wxLocaleCategory: the category of locale settings
360// ----------------------------------------------------------------------------
361
362enum wxLocaleCategory
363{
364 // (any) numbers
365 wxLOCALE_CAT_NUMBER,
366
367 // date/time
368 wxLOCALE_CAT_DATE,
369
370 // monetary value
371 wxLOCALE_CAT_MONEY,
372
89a7e1ff
VZ
373 // default category for wxLocaleInfo values which only apply to a single
374 // category (e.g. wxLOCALE_SHORT_DATE_FMT)
375 wxLOCALE_CAT_DEFAULT,
376
f2a139ad
VZ
377 wxLOCALE_CAT_MAX
378};
379
380// ----------------------------------------------------------------------------
381// wxLocaleInfo: the items understood by wxLocale::GetInfo()
382// ----------------------------------------------------------------------------
383
384enum wxLocaleInfo
385{
89a7e1ff 386 // the thousands separator (for wxLOCALE_CAT_NUMBER or MONEY)
f2a139ad
VZ
387 wxLOCALE_THOUSANDS_SEP,
388
89a7e1ff
VZ
389 // the character used as decimal point (for wxLOCALE_CAT_NUMBER or MONEY)
390 wxLOCALE_DECIMAL_POINT,
391
392 // the stftime()-formats used for short/long date and time representations
393 // (under some platforms short and long date formats are the same)
394 //
395 // NB: these elements should appear in this order, code in GetInfo() relies
396 // on it
397 wxLOCALE_SHORT_DATE_FMT,
398 wxLOCALE_LONG_DATE_FMT,
399 wxLOCALE_DATE_TIME_FMT,
400 wxLOCALE_TIME_FMT
f2a139ad
VZ
401
402};
403
c801d85f
KB
404// ----------------------------------------------------------------------------
405// wxLocale: encapsulates all language dependent settings, including current
84c18814 406// message catalogs, date, time and currency formats (TODO) &c
c801d85f 407// ----------------------------------------------------------------------------
fda91381
VS
408
409enum wxLocaleInitFlags
410{
f30bd8f2 411 wxLOCALE_DONT_LOAD_DEFAULT = 0x0000, // don't load wxwin.mo
3acf8a8d
VS
412 wxLOCALE_LOAD_DEFAULT = 0x0001 // load wxwin.mo?
413#if WXWIN_COMPATIBILITY_2_8
414 ,wxLOCALE_CONV_ENCODING = 0x0002 // no longer used, simply remove
415 // it from the existing code
416#endif
fda91381
VS
417};
418
bddd7a8d 419class WXDLLIMPEXP_BASE wxLocale
c801d85f
KB
420{
421public:
84c18814
VZ
422 // ctor & dtor
423 // -----------
424
425 // call Init() if you use this ctor
ea8f6fc7
VZ
426 wxLocale() { DoCommonInit(); }
427
84c18814 428 // the ctor has a side effect of changing current locale
31b7522e
VS
429 wxLocale(const wxString& name, // name (for messages)
430 const wxString& shortName = wxEmptyString, // dir prefix (for msg files)
431 const wxString& locale = wxEmptyString, // locale (for setlocale)
3acf8a8d
VS
432 bool bLoadDefault = true // preload wxstd.mo?
433#if WXWIN_COMPATIBILITY_2_8
434 ,bool bConvertEncoding = true // convert Win<->Unix if necessary?
435#endif
436 )
58d5dfc1 437 {
ea8f6fc7
VZ
438 DoCommonInit();
439
31b7522e 440 Init(name, shortName, locale, bLoadDefault, bConvertEncoding);
fda91381
VS
441 }
442
ec37df57 443 wxLocale(int language, // wxLanguage id or custom language
3acf8a8d 444 int flags = wxLOCALE_LOAD_DEFAULT)
ea8f6fc7
VZ
445 {
446 DoCommonInit();
fda91381 447
ea8f6fc7
VZ
448 Init(language, flags);
449 }
450
451 // the same as a function (returns true on success)
31b7522e
VS
452 bool Init(const wxString& name,
453 const wxString& shortName = wxEmptyString,
454 const wxString& locale = wxEmptyString,
3acf8a8d
VS
455 bool bLoadDefault = true
456#if WXWIN_COMPATIBILITY_2_8
457 ,bool bConvertEncoding = true
458#endif
459 );
fda91381 460
ea8f6fc7 461 // same as second ctor (returns true on success)
fda91381 462 bool Init(int language = wxLANGUAGE_DEFAULT,
3acf8a8d 463 int flags = wxLOCALE_LOAD_DEFAULT);
ec37df57 464
84c18814 465 // restores old locale
d4a724d4 466 virtual ~wxLocale();
58d5dfc1 467
3103e8a9 468 // Try to get user's (or OS's) preferred language setting.
ec37df57 469 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
41780009 470 static int GetSystemLanguage();
84c18814 471
dccce9ea
VZ
472 // get the encoding used by default for text on this system, returns
473 // wxFONTENCODING_SYSTEM if it couldn't be determined
474 static wxFontEncoding GetSystemEncoding();
475
476 // get the string describing the system encoding, return empty string if
477 // couldn't be determined
478 static wxString GetSystemEncodingName();
479
f2a139ad
VZ
480 // get the values of the given locale-dependent datum: the current locale
481 // is used, the US default value is returned if everything else fails
89a7e1ff
VZ
482 static wxString GetInfo(wxLocaleInfo index,
483 wxLocaleCategory cat = wxLOCALE_CAT_DEFAULT);
f2a139ad 484
ea8f6fc7 485 // return true if the locale was set successfully
3ca6a5f0
BP
486 bool IsOk() const { return m_pszOldLocale != NULL; }
487
84c18814 488 // returns locale name
31b7522e 489 const wxString& GetLocale() const { return m_strLocale; }
58d5dfc1 490
fda91381
VS
491 // return current locale wxLanguage value
492 int GetLanguage() const { return m_language; }
84c18814 493
58d5dfc1 494 // return locale name to be passed to setlocale()
fda91381
VS
495 wxString GetSysName() const;
496
58d5dfc1 497 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
fda91381
VS
498 // language code according to ISO 639 and YY is country name
499 // as specified by ISO 3166.
500 wxString GetCanonicalName() const { return m_strShort; }
58d5dfc1 501
84c18814
VZ
502 // add a prefix to the catalog lookup path: the message catalog files will be
503 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
504 // (in this order).
505 //
506 // This only applies to subsequent invocations of AddCatalog()!
507 static void AddCatalogLookupPathPrefix(const wxString& prefix);
508
509 // add a catalog: it's searched for in standard places (current directory
510 // first, system one after), but the you may prepend additional directories to
511 // the search path with AddCatalogLookupPathPrefix().
512 //
513 // The loaded catalog will be used for message lookup by GetString().
514 //
515 // Returns 'true' if it was successfully loaded
31b7522e
VS
516 bool AddCatalog(const wxString& domain);
517 bool AddCatalog(const wxString& domain,
518 wxLanguage msgIdLanguage, const wxString& msgIdCharset);
84c18814 519
cec5ffc4
VZ
520 // check if the given locale is provided by OS and C run time
521 static bool IsAvailable(int lang);
522
84c18814 523 // check if the given catalog is loaded
31b7522e 524 bool IsLoaded(const wxString& domain) const;
58d5dfc1 525
14f8fa9d
VZ
526 // Retrieve the language info struct for the given language
527 //
528 // Returns NULL if no info found, pointer must *not* be deleted by caller
529 static const wxLanguageInfo *GetLanguageInfo(int lang);
530
4a6e4a46
VS
531 // Returns language name in English or empty string if the language
532 // is not in database
533 static wxString GetLanguageName(int lang);
534
9d1e1be4
VZ
535 // Find the language for the given locale string which may be either a
536 // canonical ISO 2 letter language code ("xx"), a language code followed by
537 // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
538 //
539 // Returns NULL if no info found, pointer must *not* be deleted by caller
540 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
541
fda91381
VS
542 // Add custom language to the list of known languages.
543 // Notes: 1) wxLanguageInfo contains platform-specific data
544 // 2) must be called before Init to have effect
41780009 545 static void AddLanguage(const wxLanguageInfo& info);
84c18814
VZ
546
547 // retrieve the translation for a string in all loaded domains unless
548 // the szDomain parameter is specified (and then only this domain is
549 // searched)
849a28d0 550 // n - additional parameter for PluralFormsParser
84c18814
VZ
551 //
552 // return original string if translation is not available
553 // (in this case an error message is generated the first time
554 // a string is not found; use wxLogNull to suppress it)
555 //
556 // domains are searched in the last to first order, i.e. catalogs
557 // added later override those added before.
31b7522e
VS
558 virtual const wxString& GetString(const wxString& origString,
559 const wxString& domain = wxEmptyString) const;
849a28d0 560 // plural form version of the same:
31b7522e
VS
561 virtual const wxString& GetString(const wxString& origString,
562 const wxString& origString2,
563 size_t n,
564 const wxString& domain = wxEmptyString) const;
84c18814 565
a64be16e
VS
566 // this is hack to work around a problem with wxGetTranslation() which
567 // returns const wxString& and not wxString, so when it returns untranslated
568 // string, it needs to have a copy of it somewhere
569 static const wxString& GetUntranslatedString(const wxString& str);
570
84c18814
VZ
571 // Returns the current short name for the locale
572 const wxString& GetName() const { return m_strShort; }
573
c48908df 574 // return the contents of .po file header
31b7522e
VS
575 wxString GetHeaderValue(const wxString& header,
576 const wxString& domain = wxEmptyString) const;
c48908df 577
41780009
VS
578 // These two methods are for internal use only. First one creates
579 // ms_languagesDB if it doesn't already exist, second one destroys
580 // it.
581 static void CreateLanguagesDB();
582 static void DestroyLanguagesDB();
583
84c18814
VZ
584private:
585 // find catalog by name in a linked list, return NULL if !found
31b7522e 586 wxMsgCatalog *FindCatalog(const wxString& domain) const;
58d5dfc1 587
fda91381 588 // copy default table of languages from global static array to
41780009
VS
589 // m_langugagesInfo, called by InitLanguagesDB
590 static void InitLanguagesDB();
84c18814 591
ea8f6fc7
VZ
592 // initialize the member fields to default values
593 void DoCommonInit();
594
afc94fa6
VS
595 wxString m_strLocale, // this locale name
596 m_strShort; // short name for the locale
fda91381 597 int m_language; // this locale wxLanguage value
84c18814 598
52de37c7 599 const char *m_pszOldLocale; // previous locale from setlocale()
afc94fa6 600 wxLocale *m_pOldLocale; // previous wxLocale
84c18814 601
afc94fa6 602 wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs
58d5dfc1 603
3202d00d
VS
604 bool m_initialized;
605
41780009 606 static wxLanguageInfoArray *ms_languagesDB;
22f3361e 607
c0c133e1 608 wxDECLARE_NO_COPY_CLASS(wxLocale);
c801d85f
KB
609};
610
9d8046f6 611// ----------------------------------------------------------------------------
a1530845 612// global functions
9d8046f6
VZ
613// ----------------------------------------------------------------------------
614
84c18814 615// get the current locale object (note that it may be NULL!)
bddd7a8d 616extern WXDLLIMPEXP_BASE wxLocale* wxGetLocale();
84c18814
VZ
617
618// get the translation of the string in the current locale
31b7522e
VS
619inline const wxString& wxGetTranslation(const wxString& str,
620 const wxString& domain = wxEmptyString)
9d8046f6 621{
84c18814 622 wxLocale *pLoc = wxGetLocale();
06c545a7 623 if (pLoc)
31b7522e 624 return pLoc->GetString(str, domain);
06c545a7 625 else
a64be16e
VS
626 // NB: this function returns reference to a string, so we have to keep
627 // a copy of it somewhere
628 return wxLocale::GetUntranslatedString(str);
9d8046f6 629}
31b7522e
VS
630inline const wxString& wxGetTranslation(const wxString& str1,
631 const wxString& str2,
632 size_t n,
633 const wxString& domain = wxEmptyString)
849a28d0
VS
634{
635 wxLocale *pLoc = wxGetLocale();
636 if (pLoc)
31b7522e 637 return pLoc->GetString(str1, str2, n, domain);
849a28d0 638 else
a64be16e
VS
639 // NB: this function returns reference to a string, so we have to keep
640 // a copy of it somewhere
641 return n == 1
642 ? wxLocale::GetUntranslatedString(str1)
643 : wxLocale::GetUntranslatedString(str2);
849a28d0 644}
9d8046f6 645
88ac883a
VZ
646#else // !wxUSE_INTL
647
b12915c1
VZ
648// the macros should still be defined - otherwise compilation would fail
649
ba9d03fa
VS
650#if !defined(WXINTL_NO_GETTEXT_MACRO)
651 #if !defined(_)
066f3611 652 #define _(s) (s)
ba9d03fa 653 #endif
066f3611 654 #define wxPLURAL(sing, plur, n) ((n) == 1 ? (sing) : (plur))
88ac883a
VZ
655#endif
656
e0749635 657#define wxTRANSLATE(str) str
b12915c1 658
a64be16e
VS
659// NB: we use a template here in order to avoid using
660// wxLocale::GetUntranslatedString() above, which would be required if
661// we returned const wxString&; this way, the compiler should be able to
662// optimize wxGetTranslation() away
88ac883a 663
a64be16e
VS
664template<typename TString>
665inline TString wxGetTranslation(TString str)
666 { return str; }
667
668template<typename TString, typename TDomain>
669inline TString wxGetTranslation(TString str, TDomain WXUNUSED(domain))
670 { return str; }
671
672template<typename TString, typename TDomain>
673inline TString wxGetTranslation(TString str1, TString str2, size_t n)
674 { return n == 1 ? str1 : str2; }
675
676template<typename TString, typename TDomain>
677inline TString wxGetTranslation(TString str1, TString str2, size_t n,
678 TDomain WXUNUSED(domain))
679 { return n == 1 ? str1 : str2; }
df08bf5a 680
88ac883a
VZ
681#endif // wxUSE_INTL/!wxUSE_INTL
682
b12915c1
VZ
683// define this one just in case it occurs somewhere (instead of preferred
684// wxTRANSLATE) too
ba9d03fa
VS
685#if !defined(WXINTL_NO_GETTEXT_MACRO)
686 #if !defined(gettext_noop)
066f3611 687 #define gettext_noop(str) (str)
ba9d03fa
VS
688 #endif
689 #if !defined(N_)
066f3611 690 #define N_(s) (s)
ba9d03fa 691 #endif
b12915c1
VZ
692#endif
693
dccce9ea 694#endif // _WX_INTL_H_