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: intl.h 61872 2009-09-09 22:37:05Z VZ $
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
25enum 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(wxT(s))
49    #define wxPLURAL(sing, plur, n)  wxGetTranslation(wxT(sing), wxT(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) wxT(str)
55
56// ----------------------------------------------------------------------------
57// forward decls
58// ----------------------------------------------------------------------------
59
60class WXDLLIMPEXP_FWD_BASE wxLocale;
61class WXDLLIMPEXP_FWD_BASE wxLanguageInfoArray;
62class 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
76enum 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_SAMOAN,
240    wxLANGUAGE_SANGHO,
241    wxLANGUAGE_SANSKRIT,
242    wxLANGUAGE_SCOTS_GAELIC,
243    wxLANGUAGE_SERBIAN,
244    wxLANGUAGE_SERBIAN_CYRILLIC,
245    wxLANGUAGE_SERBIAN_LATIN,
246    wxLANGUAGE_SERBO_CROATIAN,
247    wxLANGUAGE_SESOTHO,
248    wxLANGUAGE_SETSWANA,
249    wxLANGUAGE_SHONA,
250    wxLANGUAGE_SINDHI,
251    wxLANGUAGE_SINHALESE,
252    wxLANGUAGE_SISWATI,
253    wxLANGUAGE_SLOVAK,
254    wxLANGUAGE_SLOVENIAN,
255    wxLANGUAGE_SOMALI,
256    wxLANGUAGE_SPANISH,
257    wxLANGUAGE_SPANISH_ARGENTINA,
258    wxLANGUAGE_SPANISH_BOLIVIA,
259    wxLANGUAGE_SPANISH_CHILE,
260    wxLANGUAGE_SPANISH_COLOMBIA,
261    wxLANGUAGE_SPANISH_COSTA_RICA,
262    wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
263    wxLANGUAGE_SPANISH_ECUADOR,
264    wxLANGUAGE_SPANISH_EL_SALVADOR,
265    wxLANGUAGE_SPANISH_GUATEMALA,
266    wxLANGUAGE_SPANISH_HONDURAS,
267    wxLANGUAGE_SPANISH_MEXICAN,
268    wxLANGUAGE_SPANISH_MODERN,
269    wxLANGUAGE_SPANISH_NICARAGUA,
270    wxLANGUAGE_SPANISH_PANAMA,
271    wxLANGUAGE_SPANISH_PARAGUAY,
272    wxLANGUAGE_SPANISH_PERU,
273    wxLANGUAGE_SPANISH_PUERTO_RICO,
274    wxLANGUAGE_SPANISH_URUGUAY,
275    wxLANGUAGE_SPANISH_US,
276    wxLANGUAGE_SPANISH_VENEZUELA,
277    wxLANGUAGE_SUNDANESE,
278    wxLANGUAGE_SWAHILI,
279    wxLANGUAGE_SWEDISH,
280    wxLANGUAGE_SWEDISH_FINLAND,
281    wxLANGUAGE_TAGALOG,
282    wxLANGUAGE_TAJIK,
283    wxLANGUAGE_TAMIL,
284    wxLANGUAGE_TATAR,
285    wxLANGUAGE_TELUGU,
286    wxLANGUAGE_THAI,
287    wxLANGUAGE_TIBETAN,
288    wxLANGUAGE_TIGRINYA,
289    wxLANGUAGE_TONGA,
290    wxLANGUAGE_TSONGA,
291    wxLANGUAGE_TURKISH,
292    wxLANGUAGE_TURKMEN,
293    wxLANGUAGE_TWI,
294    wxLANGUAGE_UIGHUR,
295    wxLANGUAGE_UKRAINIAN,
296    wxLANGUAGE_URDU,
297    wxLANGUAGE_URDU_INDIA,
298    wxLANGUAGE_URDU_PAKISTAN,
299    wxLANGUAGE_UZBEK,
300    wxLANGUAGE_UZBEK_CYRILLIC,
301    wxLANGUAGE_UZBEK_LATIN,
302    wxLANGUAGE_VIETNAMESE,
303    wxLANGUAGE_VOLAPUK,
304    wxLANGUAGE_WELSH,
305    wxLANGUAGE_WOLOF,
306    wxLANGUAGE_XHOSA,
307    wxLANGUAGE_YIDDISH,
308    wxLANGUAGE_YORUBA,
309    wxLANGUAGE_ZHUANG,
310    wxLANGUAGE_ZULU,
311
312    // for custom, user-defined languages:
313    wxLANGUAGE_USER_DEFINED
314
315
316#if wxABI_VERSION >= 20808
317    // For binary compatibility, we can't put new items in their normal
318    // position in the enum, because it would change other values.  We have to
319    // put it somewhere well outside normal range -- the particular value used
320    // is arbitrary:
321    , wxLANGUAGE_VALENCIAN = 0x1fffffff,
322    wxLANGUAGE_SAMI
323#endif
324};
325
326// --- --- --- generated code ends here --- --- ---
327
328// ----------------------------------------------------------------------------
329// wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
330//                 translation information
331// ----------------------------------------------------------------------------
332
333struct WXDLLIMPEXP_BASE wxLanguageInfo
334{
335    int Language;                   // wxLanguage id
336    wxString CanonicalName;         // Canonical name, e.g. fr_FR
337#ifdef __WIN32__
338    wxUint32 WinLang,               // Win32 language identifiers
339             WinSublang;
340#endif // __WIN32__
341    wxString Description;           // human-readable name of the language
342    wxLayoutDirection LayoutDirection;
343};
344
345// ----------------------------------------------------------------------------
346// wxLocaleCategory: the category of locale settings
347// ----------------------------------------------------------------------------
348
349enum wxLocaleCategory
350{
351    // (any) numbers
352    wxLOCALE_CAT_NUMBER,
353
354    // date/time
355    wxLOCALE_CAT_DATE,
356
357    // monetary value
358    wxLOCALE_CAT_MONEY,
359
360    wxLOCALE_CAT_MAX
361};
362
363// ----------------------------------------------------------------------------
364// wxLocaleInfo: the items understood by wxLocale::GetInfo()
365// ----------------------------------------------------------------------------
366
367enum wxLocaleInfo
368{
369    // the thounsands separator
370    wxLOCALE_THOUSANDS_SEP,
371
372    // the character used as decimal point
373    wxLOCALE_DECIMAL_POINT
374
375};
376
377// ----------------------------------------------------------------------------
378// wxLocale: encapsulates all language dependent settings, including current
379//           message catalogs, date, time and currency formats (TODO) &c
380// ----------------------------------------------------------------------------
381
382enum wxLocaleInitFlags
383{
384    wxLOCALE_LOAD_DEFAULT  = 0x0001,     // load wxwin.mo?
385    wxLOCALE_CONV_ENCODING = 0x0002      // convert encoding on the fly?
386};
387
388class WXDLLIMPEXP_BASE wxLocale
389{
390public:
391    // ctor & dtor
392    // -----------
393
394        // call Init() if you use this ctor
395    wxLocale() { DoCommonInit(); }
396
397        // the ctor has a side effect of changing current locale
398    wxLocale(const wxChar *szName,                               // name (for messages)
399             const wxChar *szShort = (const wxChar *) NULL,      // dir prefix (for msg files)
400             const wxChar *szLocale = (const wxChar *) NULL,     // locale (for setlocale)
401             bool bLoadDefault = true,                           // preload wxstd.mo?
402             bool bConvertEncoding = false)                      // convert Win<->Unix if necessary?
403        {
404            DoCommonInit();
405
406            Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding);
407        }
408
409    wxLocale(int language, // wxLanguage id or custom language
410             int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING)
411        {
412            DoCommonInit();
413
414            Init(language, flags);
415        }
416
417        // the same as a function (returns true on success)
418    bool Init(const wxChar *szName,
419              const wxChar *szShort = (const wxChar *) NULL,
420              const wxChar *szLocale = (const wxChar *) NULL,
421              bool bLoadDefault = true,
422              bool bConvertEncoding = false);
423
424        // same as second ctor (returns true on success)
425    bool Init(int language = wxLANGUAGE_DEFAULT,
426              int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
427
428        // restores old locale
429    virtual ~wxLocale();
430
431    // Try to get user's (or OS's) preferred language setting.
432    // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
433    static int GetSystemLanguage();
434
435    // get the encoding used by default for text on this system, returns
436    // wxFONTENCODING_SYSTEM if it couldn't be determined
437    static wxFontEncoding GetSystemEncoding();
438
439    // get the string describing the system encoding, return empty string if
440    // couldn't be determined
441    static wxString GetSystemEncodingName();
442
443    // get the values of the given locale-dependent datum: the current locale
444    // is used, the US default value is returned if everything else fails
445    static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat);
446
447    // return true if the locale was set successfully
448    bool IsOk() const { return m_pszOldLocale != NULL; }
449
450    // returns locale name
451    const wxChar *GetLocale() const { return m_strLocale; }
452
453    // return current locale wxLanguage value
454    int GetLanguage() const { return m_language; }
455
456    // return locale name to be passed to setlocale()
457    wxString GetSysName() const;
458
459    // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
460    // language code according to ISO 639 and YY is country name
461    // as specified by ISO 3166.
462    wxString GetCanonicalName() const { return m_strShort; }
463
464    // add a prefix to the catalog lookup path: the message catalog files will be
465    // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
466    // (in this order).
467    //
468    // This only applies to subsequent invocations of AddCatalog()!
469    static void AddCatalogLookupPathPrefix(const wxString& prefix);
470
471    // add a catalog: it's searched for in standard places (current directory
472    // first, system one after), but the you may prepend additional directories to
473    // the search path with AddCatalogLookupPathPrefix().
474    //
475    // The loaded catalog will be used for message lookup by GetString().
476    //
477    // Returns 'true' if it was successfully loaded
478    bool AddCatalog(const wxChar *szDomain);
479    bool AddCatalog(const wxChar *szDomain,
480                    wxLanguage msgIdLanguage, const wxChar *msgIdCharset);
481
482    // check if the given locale is provided by OS and C run time
483    static bool IsAvailable(int lang);
484
485    // check if the given catalog is loaded
486    bool IsLoaded(const wxChar *szDomain) const;
487
488    // Retrieve the language info struct for the given language
489    //
490    // Returns NULL if no info found, pointer must *not* be deleted by caller
491    static const wxLanguageInfo *GetLanguageInfo(int lang);
492
493    // Returns language name in English or empty string if the language
494    // is not in database
495    static wxString GetLanguageName(int lang);
496
497    // Find the language for the given locale string which may be either a
498    // canonical ISO 2 letter language code ("xx"), a language code followed by
499    // the country code ("xx_XX") or a Windows full language name ("Xxxxx...")
500    //
501    // Returns NULL if no info found, pointer must *not* be deleted by caller
502    static const wxLanguageInfo *FindLanguageInfo(const wxString& locale);
503
504    // Add custom language to the list of known languages.
505    // Notes: 1) wxLanguageInfo contains platform-specific data
506    //        2) must be called before Init to have effect
507    static void AddLanguage(const wxLanguageInfo& info);
508
509    // retrieve the translation for a string in all loaded domains unless
510    // the szDomain parameter is specified (and then only this domain is
511    // searched)
512    // n - additional parameter for PluralFormsParser
513    //
514    // return original string if translation is not available
515    // (in this case an error message is generated the first time
516    //  a string is not found; use wxLogNull to suppress it)
517    //
518    // domains are searched in the last to first order, i.e. catalogs
519    // added later override those added before.
520    virtual const wxChar *GetString(const wxChar *szOrigString,
521                                    const wxChar *szDomain = NULL) const;
522    // plural form version of the same:
523    virtual const wxChar *GetString(const wxChar *szOrigString,
524                                    const wxChar *szOrigString2,
525                                    size_t n,
526                                    const wxChar *szDomain = NULL) const;
527
528    // Returns the current short name for the locale
529    const wxString& GetName() const { return m_strShort; }
530
531    // return the contents of .po file header
532    wxString GetHeaderValue( const wxChar* szHeader,
533                             const wxChar* szDomain = NULL ) const;
534
535    // These two methods are for internal use only. First one creates
536    // ms_languagesDB if it doesn't already exist, second one destroys
537    // it.
538    static void CreateLanguagesDB();
539    static void DestroyLanguagesDB();
540
541private:
542    // find catalog by name in a linked list, return NULL if !found
543    wxMsgCatalog  *FindCatalog(const wxChar *szDomain) const;
544
545    // copy default table of languages from global static array to
546    // m_langugagesInfo, called by InitLanguagesDB
547    static void InitLanguagesDB();
548
549    // initialize the member fields to default values
550    void DoCommonInit();
551
552    wxString       m_strLocale,       // this locale name
553                   m_strShort;        // short name for the locale
554    int            m_language;        // this locale wxLanguage value
555
556    const wxChar  *m_pszOldLocale;    // previous locale from setlocale()
557    wxLocale      *m_pOldLocale;      // previous wxLocale
558
559    wxMsgCatalog  *m_pMsgCat;         // pointer to linked list of catalogs
560
561    bool           m_bConvertEncoding;
562
563    bool           m_initialized;
564
565    static wxLanguageInfoArray *ms_languagesDB;
566
567    DECLARE_NO_COPY_CLASS(wxLocale)
568};
569
570// ----------------------------------------------------------------------------
571// global functions
572// ----------------------------------------------------------------------------
573
574// get the current locale object (note that it may be NULL!)
575extern WXDLLIMPEXP_BASE wxLocale* wxGetLocale();
576
577// get the translation of the string in the current locale
578inline const wxChar *
579wxGetTranslation(const wxChar *sz, const wxChar* domain = NULL)
580{
581    wxLocale *pLoc = wxGetLocale();
582    if (pLoc)
583        return pLoc->GetString(sz, domain);
584    else
585        return sz;
586}
587
588inline const wxChar *
589wxGetTranslation(const wxChar *sz1, const wxChar *sz2,
590                 size_t n,
591                 const wxChar *domain = NULL)
592{
593    wxLocale *pLoc = wxGetLocale();
594    if (pLoc)
595        return pLoc->GetString(sz1, sz2, n, domain);
596    else
597        return n == 1 ? sz1 : sz2;
598}
599
600#else // !wxUSE_INTL
601
602// the macros should still be defined - otherwise compilation would fail
603
604#if !defined(WXINTL_NO_GETTEXT_MACRO)
605    #if !defined(_)
606        #define _(s)                 (wxT(s))
607    #endif
608    #define wxPLURAL(sing, plur, n)  ((n) == 1 ? wxT(sing) : wxT(plur))
609#endif
610
611#define wxTRANSLATE(str) wxT(str)
612
613inline const wxChar *
614wxGetTranslation(const wxChar *sz, const wxChar * WXUNUSED(domain) = NULL)
615{
616    return sz;
617}
618
619#endif // wxUSE_INTL/!wxUSE_INTL
620
621// define this one just in case it occurs somewhere (instead of preferred
622// wxTRANSLATE) too
623#if !defined(WXINTL_NO_GETTEXT_MACRO)
624    #if !defined(gettext_noop)
625        #define gettext_noop(str) wxT(str)
626    #endif
627    #if !defined(N_)
628        #define N_(s)             wxT(s)
629    #endif
630#endif
631
632#endif // _WX_INTL_H_
633