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