]> git.saurik.com Git - wxWidgets.git/blob - include/wx/intl.h
disable a test failing under wxGTK because of what appears to be a Pango limitation
[wxWidgets.git] / include / wx / intl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/intl.h
3 // Purpose: Internationalization and localisation for wxWidgets
4 // Author: Vadim Zeitlin
5 // Modified by: Michael N. Filippov <michael@idisys.iae.nsk.su>
6 // (2003/09/30 - plural forms support)
7 // Created: 29/01/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 // WARNING: Parts of this file are generated. See misc/languages/README for
14 // details.
15
16 #ifndef _WX_INTL_H_
17 #define _WX_INTL_H_
18
19 #include "wx/defs.h"
20 #include "wx/string.h"
21
22 // Make wxLayoutDirection enum available without need for wxUSE_INTL so wxWindow, wxApp
23 // and other classes are not distrubed by wxUSE_INTL
24
25 enum wxLayoutDirection
26 {
27 wxLayout_Default,
28 wxLayout_LeftToRight,
29 wxLayout_RightToLeft
30 };
31
32 #if wxUSE_INTL
33
34 #include "wx/fontenc.h"
35
36 // ============================================================================
37 // global decls
38 // ============================================================================
39
40 // ----------------------------------------------------------------------------
41 // macros
42 // ----------------------------------------------------------------------------
43
44 // gettext() style macros (notice that xgettext should be invoked with
45 // --keyword="_" --keyword="wxPLURAL:1,2" options
46 // to extract the strings from the sources)
47 #ifndef WXINTL_NO_GETTEXT_MACRO
48 #define _(s) wxGetTranslation((s))
49 #define wxPLURAL(sing, plur, n) wxGetTranslation((sing), (plur), n)
50 #endif
51
52 // another one which just marks the strings for extraction, but doesn't
53 // perform the translation (use -kwxTRANSLATE with xgettext!)
54 #define wxTRANSLATE(str) str
55
56 // ----------------------------------------------------------------------------
57 // forward decls
58 // ----------------------------------------------------------------------------
59
60 class WXDLLIMPEXP_FWD_BASE wxLocale;
61 class WXDLLIMPEXP_FWD_BASE wxLanguageInfoArray;
62 class wxMsgCatalog;
63
64 // ============================================================================
65 // locale support
66 // ============================================================================
67
68 // ----------------------------------------------------------------------------
69 // wxLanguage: defines all supported languages
70 // ----------------------------------------------------------------------------
71
72 // --- --- --- generated code begins here --- --- ---
73
74 // This enum is generated by misc/languages/genlang.py
75 // When making changes, please put them into misc/languages/langtabl.txt
76 enum wxLanguage
77 {
78 // user's default/preffered language as got from OS:
79 wxLANGUAGE_DEFAULT,
80 // unknown language, if wxLocale::GetSystemLanguage fails:
81 wxLANGUAGE_UNKNOWN,
82
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,
239 wxLANGUAGE_SAMI,
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,
303 wxLANGUAGE_VALENCIAN,
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
318 // --- --- --- generated code ends here --- --- ---
319
320 // ----------------------------------------------------------------------------
321 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
322 // translation information
323 // ----------------------------------------------------------------------------
324
325 struct WXDLLIMPEXP_BASE wxLanguageInfo
326 {
327 int Language; // wxLanguage id
328 wxString CanonicalName; // Canonical name, e.g. fr_FR
329 #ifdef __WXMSW__
330 wxUint32 WinLang, // Win32 language identifiers
331 WinSublang;
332 #endif // __WXMSW__
333 wxString Description; // human-readable name of the language
334 wxLayoutDirection LayoutDirection;
335
336 #ifdef __WXMSW__
337 // return the LCID corresponding to this language
338 wxUint32 GetLCID() const;
339 #endif // __WXMSW__
340
341 // return the locale name corresponding to this language usable with
342 // setlocale() on the current system
343 wxString GetLocaleName() const;
344 };
345
346 // for Unix systems GetLocaleName() is trivial so implement it inline here, for
347 // MSW it's implemented in intl.cpp
348 #ifndef __WXMSW__
349 inline wxString wxLanguageInfo::GetLocaleName() const { return CanonicalName; }
350 #endif // !__WXMSW__
351
352 // ----------------------------------------------------------------------------
353 // wxLocaleCategory: the category of locale settings
354 // ----------------------------------------------------------------------------
355
356 enum 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 // default category for wxLocaleInfo values which only apply to a single
368 // category (e.g. wxLOCALE_SHORT_DATE_FMT)
369 wxLOCALE_CAT_DEFAULT,
370
371 wxLOCALE_CAT_MAX
372 };
373
374 // ----------------------------------------------------------------------------
375 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
376 // ----------------------------------------------------------------------------
377
378 enum wxLocaleInfo
379 {
380 // the thousands separator (for wxLOCALE_CAT_NUMBER or MONEY)
381 wxLOCALE_THOUSANDS_SEP,
382
383 // the character used as decimal point (for wxLOCALE_CAT_NUMBER or MONEY)
384 wxLOCALE_DECIMAL_POINT,
385
386 // the stftime()-formats used for short/long date and time representations
387 // (under some platforms short and long date formats are the same)
388 //
389 // NB: these elements should appear in this order, code in GetInfo() relies
390 // on it
391 wxLOCALE_SHORT_DATE_FMT,
392 wxLOCALE_LONG_DATE_FMT,
393 wxLOCALE_DATE_TIME_FMT,
394 wxLOCALE_TIME_FMT
395
396 };
397
398 // ----------------------------------------------------------------------------
399 // wxLocale: encapsulates all language dependent settings, including current
400 // message catalogs, date, time and currency formats (TODO) &c
401 // ----------------------------------------------------------------------------
402
403 enum wxLocaleInitFlags
404 {
405 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
406 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
407 };
408
409 class WXDLLIMPEXP_BASE wxLocale
410 {
411 public:
412 // ctor & dtor
413 // -----------
414
415 // call Init() if you use this ctor
416 wxLocale() { DoCommonInit(); }
417
418 // the ctor has a side effect of changing current locale
419 wxLocale(const wxString& name, // name (for messages)
420 const wxString& shortName = wxEmptyString, // dir prefix (for msg files)
421 const wxString& locale = wxEmptyString, // locale (for setlocale)
422 bool bLoadDefault = true, // preload wxstd.mo?
423 bool bConvertEncoding = false) // convert Win<->Unix if necessary?
424 {
425 DoCommonInit();
426
427 Init(name, shortName, locale, bLoadDefault, bConvertEncoding);
428 }
429
430 wxLocale(int language, // wxLanguage id or custom language
431 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING)
432 {
433 DoCommonInit();
434
435 Init(language, flags);
436 }
437
438 // the same as a function (returns true on success)
439 bool Init(const wxString& name,
440 const wxString& shortName = wxEmptyString,
441 const wxString& locale = wxEmptyString,
442 bool bLoadDefault = true,
443 bool bConvertEncoding = false);
444
445 // same as second ctor (returns true on success)
446 bool Init(int language = wxLANGUAGE_DEFAULT,
447 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
448
449 // restores old locale
450 virtual ~wxLocale();
451
452 // Try to get user's (or OS's) preferred language setting.
453 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
454 static int GetSystemLanguage();
455
456 // get the encoding used by default for text on this system, returns
457 // wxFONTENCODING_SYSTEM if it couldn't be determined
458 static wxFontEncoding GetSystemEncoding();
459
460 // get the string describing the system encoding, return empty string if
461 // couldn't be determined
462 static wxString GetSystemEncodingName();
463
464 // get the values of the given locale-dependent datum: the current locale
465 // is used, the US default value is returned if everything else fails
466 static wxString GetInfo(wxLocaleInfo index,
467 wxLocaleCategory cat = wxLOCALE_CAT_DEFAULT);
468
469 // return true if the locale was set successfully
470 bool IsOk() const { return m_pszOldLocale != NULL; }
471
472 // returns locale name
473 const wxString& GetLocale() const { return m_strLocale; }
474
475 // return current locale wxLanguage value
476 int GetLanguage() const { return m_language; }
477
478 // return locale name to be passed to setlocale()
479 wxString GetSysName() const;
480
481 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
482 // language code according to ISO 639 and YY is country name
483 // as specified by ISO 3166.
484 wxString GetCanonicalName() const { return m_strShort; }
485
486 // add a prefix to the catalog lookup path: the message catalog files will be
487 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
488 // (in this order).
489 //
490 // This only applies to subsequent invocations of AddCatalog()!
491 static void AddCatalogLookupPathPrefix(const wxString& prefix);
492
493 // add a catalog: it's searched for in standard places (current directory
494 // first, system one after), but the you may prepend additional directories to
495 // the search path with AddCatalogLookupPathPrefix().
496 //
497 // The loaded catalog will be used for message lookup by GetString().
498 //
499 // Returns 'true' if it was successfully loaded
500 bool AddCatalog(const wxString& domain);
501 bool AddCatalog(const wxString& domain,
502 wxLanguage msgIdLanguage, const wxString& msgIdCharset);
503
504 // check if the given locale is provided by OS and C run time
505 static bool IsAvailable(int lang);
506
507 // check if the given catalog is loaded
508 bool IsLoaded(const wxString& domain) const;
509
510 // Retrieve the language info struct for the given language
511 //
512 // Returns NULL if no info found, pointer must *not* be deleted by caller
513 static const wxLanguageInfo *GetLanguageInfo(int lang);
514
515 // Returns language name in English or empty string if the language
516 // is not in database
517 static wxString GetLanguageName(int lang);
518
519 // Find the language for the given locale string which may be either a
520 // canonical ISO 2 letter language code ("xx"), a language code followed by
521 // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
522 //
523 // Returns NULL if no info found, pointer must *not* be deleted by caller
524 static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
525
526 // Add custom language to the list of known languages.
527 // Notes: 1) wxLanguageInfo contains platform-specific data
528 // 2) must be called before Init to have effect
529 static void AddLanguage(const wxLanguageInfo& info);
530
531 // retrieve the translation for a string in all loaded domains unless
532 // the szDomain parameter is specified (and then only this domain is
533 // searched)
534 // n - additional parameter for PluralFormsParser
535 //
536 // return original string if translation is not available
537 // (in this case an error message is generated the first time
538 // a string is not found; use wxLogNull to suppress it)
539 //
540 // domains are searched in the last to first order, i.e. catalogs
541 // added later override those added before.
542 virtual const wxString& GetString(const wxString& origString,
543 const wxString& domain = wxEmptyString) const;
544 // plural form version of the same:
545 virtual const wxString& GetString(const wxString& origString,
546 const wxString& origString2,
547 size_t n,
548 const wxString& domain = wxEmptyString) const;
549
550 // this is hack to work around a problem with wxGetTranslation() which
551 // returns const wxString& and not wxString, so when it returns untranslated
552 // string, it needs to have a copy of it somewhere
553 static const wxString& GetUntranslatedString(const wxString& str);
554
555 // Returns the current short name for the locale
556 const wxString& GetName() const { return m_strShort; }
557
558 // return the contents of .po file header
559 wxString GetHeaderValue(const wxString& header,
560 const wxString& domain = wxEmptyString) const;
561
562 // These two methods are for internal use only. First one creates
563 // ms_languagesDB if it doesn't already exist, second one destroys
564 // it.
565 static void CreateLanguagesDB();
566 static void DestroyLanguagesDB();
567
568 private:
569 // find catalog by name in a linked list, return NULL if !found
570 wxMsgCatalog *FindCatalog(const wxString& domain) const;
571
572 // copy default table of languages from global static array to
573 // m_langugagesInfo, called by InitLanguagesDB
574 static void InitLanguagesDB();
575
576 // initialize the member fields to default values
577 void DoCommonInit();
578
579 wxString m_strLocale, // this locale name
580 m_strShort; // short name for the locale
581 int m_language; // this locale wxLanguage value
582
583 const char *m_pszOldLocale; // previous locale from setlocale()
584 wxLocale *m_pOldLocale; // previous wxLocale
585
586 wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs
587
588 bool m_bConvertEncoding;
589
590 bool m_initialized;
591
592 static wxLanguageInfoArray *ms_languagesDB;
593
594 wxDECLARE_NO_COPY_CLASS(wxLocale);
595 };
596
597 // ----------------------------------------------------------------------------
598 // global functions
599 // ----------------------------------------------------------------------------
600
601 // get the current locale object (note that it may be NULL!)
602 extern WXDLLIMPEXP_BASE wxLocale* wxGetLocale();
603
604 // get the translation of the string in the current locale
605 inline const wxString& wxGetTranslation(const wxString& str,
606 const wxString& domain = wxEmptyString)
607 {
608 wxLocale *pLoc = wxGetLocale();
609 if (pLoc)
610 return pLoc->GetString(str, domain);
611 else
612 // NB: this function returns reference to a string, so we have to keep
613 // a copy of it somewhere
614 return wxLocale::GetUntranslatedString(str);
615 }
616 inline const wxString& wxGetTranslation(const wxString& str1,
617 const wxString& str2,
618 size_t n,
619 const wxString& domain = wxEmptyString)
620 {
621 wxLocale *pLoc = wxGetLocale();
622 if (pLoc)
623 return pLoc->GetString(str1, str2, n, domain);
624 else
625 // NB: this function returns reference to a string, so we have to keep
626 // a copy of it somewhere
627 return n == 1
628 ? wxLocale::GetUntranslatedString(str1)
629 : wxLocale::GetUntranslatedString(str2);
630 }
631
632 #else // !wxUSE_INTL
633
634 // the macros should still be defined - otherwise compilation would fail
635
636 #if !defined(WXINTL_NO_GETTEXT_MACRO)
637 #if !defined(_)
638 #define _(s) (s)
639 #endif
640 #define wxPLURAL(sing, plur, n) ((n) == 1 ? (sing) : (plur))
641 #endif
642
643 #define wxTRANSLATE(str) str
644
645 // NB: we use a template here in order to avoid using
646 // wxLocale::GetUntranslatedString() above, which would be required if
647 // we returned const wxString&; this way, the compiler should be able to
648 // optimize wxGetTranslation() away
649
650 template<typename TString>
651 inline TString wxGetTranslation(TString str)
652 { return str; }
653
654 template<typename TString, typename TDomain>
655 inline TString wxGetTranslation(TString str, TDomain WXUNUSED(domain))
656 { return str; }
657
658 template<typename TString, typename TDomain>
659 inline TString wxGetTranslation(TString str1, TString str2, size_t n)
660 { return n == 1 ? str1 : str2; }
661
662 template<typename TString, typename TDomain>
663 inline TString wxGetTranslation(TString str1, TString str2, size_t n,
664 TDomain WXUNUSED(domain))
665 { return n == 1 ? str1 : str2; }
666
667 #endif // wxUSE_INTL/!wxUSE_INTL
668
669 // define this one just in case it occurs somewhere (instead of preferred
670 // wxTRANSLATE) too
671 #if !defined(WXINTL_NO_GETTEXT_MACRO)
672 #if !defined(gettext_noop)
673 #define gettext_noop(str) (str)
674 #endif
675 #if !defined(N_)
676 #define N_(s) (s)
677 #endif
678 #endif
679
680 #endif // _WX_INTL_H_