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