]> git.saurik.com Git - wxWidgets.git/blob - src/common/intl.cpp
added timestamping to wxLogStream
[wxWidgets.git] / src / common / intl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: intl.cpp
3 // Purpose: Internationalization and localisation for wxWindows
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declaration
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "intl.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_INTL
32
33 // standard headers
34 #include <locale.h>
35 #include <ctype.h>
36
37 // wxWindows
38 #include "wx/defs.h"
39 #include "wx/string.h"
40 #include "wx/tokenzr.h"
41 #include "wx/intl.h"
42 #include "wx/file.h"
43 #include "wx/log.h"
44 #include "wx/debug.h"
45 #include "wx/utils.h"
46 #include "wx/dynarray.h"
47 #ifdef __WIN32__
48 #include "wx/msw/private.h"
49 #endif
50
51
52 #include <stdlib.h>
53
54 // ----------------------------------------------------------------------------
55 // simple types
56 // ----------------------------------------------------------------------------
57
58 // this should *not* be wxChar, this type must have exactly 8 bits!
59 typedef unsigned char size_t8;
60
61 #ifdef __WXMSW__
62 #if defined(__WIN16__)
63 typedef unsigned long size_t32;
64 #elif defined(__WIN32__)
65 typedef unsigned int size_t32;
66 #else
67 // Win64 will have different type sizes
68 #error "Please define a 32 bit type"
69 #endif
70 #else // !Windows
71 // SIZEOF_XXX are defined by configure
72 #if defined(SIZEOF_INT) && (SIZEOF_INT == 4)
73 typedef unsigned int size_t32;
74 #elif defined(SIZEOF_LONG) && (SIZEOF_LONG == 4)
75 typedef unsigned long size_t32;
76 #else
77 // assume sizeof(int) == 4 - what else can we do
78 typedef unsigned int size_t32;
79
80 // ... but at least check it during run time
81 static class IntSizeChecker
82 {
83 public:
84 IntSizeChecker()
85 {
86 // Asserting a sizeof directly causes some compilers to
87 // issue a "using constant in a conditional expression" warning
88 size_t intsize = sizeof(int);
89
90 wxASSERT_MSG( intsize == 4,
91 "size_t32 is incorrectly defined!" );
92 }
93 } intsizechecker;
94 #endif
95 #endif // Win/!Win
96
97 // ----------------------------------------------------------------------------
98 // constants
99 // ----------------------------------------------------------------------------
100
101 // magic number identifying the .mo format file
102 const size_t32 MSGCATALOG_MAGIC = 0x950412de;
103 const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
104
105 // extension of ".mo" files
106 #define MSGCATALOG_EXTENSION _T(".mo")
107
108 // ----------------------------------------------------------------------------
109 // global functions
110 // ----------------------------------------------------------------------------
111
112 #ifdef __WXDEBUG__
113
114 // small class to suppress the translation erros until exit from current scope
115 class NoTransErr
116 {
117 public:
118 NoTransErr() { ms_suppressCount++; }
119 ~NoTransErr() { ms_suppressCount--; }
120
121 static bool Suppress() { return ms_suppressCount > 0; }
122
123 private:
124 static size_t ms_suppressCount;
125 };
126
127 size_t NoTransErr::ms_suppressCount = 0;
128
129 #else // !Debug
130
131 class NoTransErr
132 {
133 public:
134 NoTransErr() { }
135 ~NoTransErr() { }
136 };
137
138 #endif // Debug/!Debug
139
140 static wxLocale *wxSetLocale(wxLocale *pLocale);
141
142 // ----------------------------------------------------------------------------
143 // wxMsgCatalog corresponds to one disk-file message catalog.
144 //
145 // This is a "low-level" class and is used only by wxLocale (that's why
146 // it's designed to be stored in a linked list)
147 // ----------------------------------------------------------------------------
148
149 class wxMsgCatalog
150 {
151 public:
152 // ctor & dtor
153 wxMsgCatalog();
154 ~wxMsgCatalog();
155
156 // load the catalog from disk (szDirPrefix corresponds to language)
157 bool Load(const wxChar *szDirPrefix, const wxChar *szName, bool bConvertEncoding = FALSE);
158 bool IsLoaded() const { return m_pData != NULL; }
159
160 // get name of the catalog
161 const wxChar *GetName() const { return m_pszName; }
162
163 // get the translated string: returns NULL if not found
164 const char *GetString(const char *sz) const;
165
166 // public variable pointing to the next element in a linked list (or NULL)
167 wxMsgCatalog *m_pNext;
168
169 private:
170 // this implementation is binary compatible with GNU gettext() version 0.10
171
172 // an entry in the string table
173 struct wxMsgTableEntry
174 {
175 size_t32 nLen; // length of the string
176 size_t32 ofsString; // pointer to the string
177 };
178
179 // header of a .mo file
180 struct wxMsgCatalogHeader
181 {
182 size_t32 magic, // offset +00: magic id
183 revision, // +04: revision
184 numStrings; // +08: number of strings in the file
185 size_t32 ofsOrigTable, // +0C: start of original string table
186 ofsTransTable; // +10: start of translated string table
187 size_t32 nHashSize, // +14: hash table size
188 ofsHashTable; // +18: offset of hash table start
189 };
190
191 // all data is stored here, NULL if no data loaded
192 size_t8 *m_pData;
193
194 // data description
195 size_t32 m_numStrings, // number of strings in this domain
196 m_nHashSize; // number of entries in hash table
197 size_t32 *m_pHashTable; // pointer to hash table
198 wxMsgTableEntry *m_pOrigTable, // pointer to original strings
199 *m_pTransTable; // translated
200
201 const char *StringAtOfs(wxMsgTableEntry *pTable, size_t32 index) const
202 { return (const char *)(m_pData + Swap(pTable[index].ofsString)); }
203
204 // convert encoding to platform native one, if neccessary
205 void ConvertEncoding();
206
207 // utility functions
208 // calculate the hash value of given string
209 static inline size_t32 GetHash(const char *sz);
210 // big<->little endian
211 inline size_t32 Swap(size_t32 ui) const;
212
213 // internal state
214 bool HasHashTable() const // true if hash table is present
215 { return m_nHashSize > 2 && m_pHashTable != NULL; }
216
217 bool m_bSwapped; // wrong endianness?
218
219 wxChar *m_pszName; // name of the domain
220 };
221
222 // ----------------------------------------------------------------------------
223 // global variables
224 // ----------------------------------------------------------------------------
225
226 // the list of the directories to search for message catalog files
227 static wxArrayString s_searchPrefixes;
228
229 // ============================================================================
230 // implementation
231 // ============================================================================
232
233 // ----------------------------------------------------------------------------
234 // wxMsgCatalog class
235 // ----------------------------------------------------------------------------
236
237 // calculate hash value using the so called hashpjw function by P.J. Weinberger
238 // [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools]
239 size_t32 wxMsgCatalog::GetHash(const char *sz)
240 {
241 #define HASHWORDBITS 32 // the length of size_t32
242
243 size_t32 hval = 0;
244 size_t32 g;
245 while ( *sz != '\0' ) {
246 hval <<= 4;
247 hval += (size_t32)*sz++;
248 g = hval & ((size_t32)0xf << (HASHWORDBITS - 4));
249 if ( g != 0 ) {
250 hval ^= g >> (HASHWORDBITS - 8);
251 hval ^= g;
252 }
253 }
254
255 return hval;
256 }
257
258 // swap the 2 halves of 32 bit integer if needed
259 size_t32 wxMsgCatalog::Swap(size_t32 ui) const
260 {
261 return m_bSwapped ? (ui << 24) | ((ui & 0xff00) << 8) |
262 ((ui >> 8) & 0xff00) | (ui >> 24)
263 : ui;
264 }
265
266 wxMsgCatalog::wxMsgCatalog()
267 {
268 m_pData = NULL;
269 m_pszName = NULL;
270 }
271
272 wxMsgCatalog::~wxMsgCatalog()
273 {
274 wxDELETEA(m_pData);
275 wxDELETEA(m_pszName);
276 }
277
278 // return all directories to search for given prefix
279 static wxString GetAllMsgCatalogSubdirs(const wxChar *prefix,
280 const wxChar *lang)
281 {
282 wxString searchPath;
283
284 // search first in prefix/fr/LC_MESSAGES, then in prefix/fr and finally in
285 // prefix (assuming the language is 'fr')
286 searchPath << prefix << wxFILE_SEP_PATH << lang << wxFILE_SEP_PATH
287 << wxT("LC_MESSAGES") << wxPATH_SEP
288 << prefix << wxFILE_SEP_PATH << lang << wxPATH_SEP
289 << prefix << wxPATH_SEP;
290
291 return searchPath;
292 }
293
294 // construct the search path for the given language
295 static wxString GetFullSearchPath(const wxChar *lang)
296 {
297 wxString searchPath;
298
299 // first take the entries explicitly added by the program
300 size_t count = s_searchPrefixes.Count();
301 for ( size_t n = 0; n < count; n++ )
302 {
303 searchPath << GetAllMsgCatalogSubdirs(s_searchPrefixes[n], lang)
304 << wxPATH_SEP;
305 }
306
307 // LC_PATH is a standard env var containing the search path for the .mo
308 // files
309 const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH"));
310 if ( pszLcPath != NULL )
311 searchPath << GetAllMsgCatalogSubdirs(pszLcPath, lang);
312
313 // then take the current directory
314 // FIXME it should be the directory of the executable
315 searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang);
316
317 // and finally add some standard ones
318 searchPath
319 << GetAllMsgCatalogSubdirs(wxT("/usr/share/locale"), lang)
320 << GetAllMsgCatalogSubdirs(wxT("/usr/lib/locale"), lang)
321 << GetAllMsgCatalogSubdirs(wxT("/usr/local/share/locale"), lang);
322
323 return searchPath;
324 }
325
326 // open disk file and read in it's contents
327 bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName0, bool bConvertEncoding)
328 {
329 /* We need to handle locales like de_AT.iso-8859-1
330 For this we first chop off the .CHARSET specifier and ignore it.
331 FIXME: UNICODE SUPPORT: must use CHARSET specifier!
332 */
333 wxString szName = szName0;
334 if(szName.Find(wxT('.')) != -1) // contains a dot
335 szName = szName.Left(szName.Find(wxT('.')));
336
337 wxString searchPath = GetFullSearchPath(szDirPrefix);
338 const wxChar *sublocale = wxStrchr(szDirPrefix, wxT('_'));
339 if ( sublocale )
340 {
341 // also add just base locale name: for things like "fr_BE" (belgium
342 // french) we should use "fr" if no belgium specific message catalogs
343 // exist
344 searchPath << GetFullSearchPath(wxString(szDirPrefix).
345 Left((size_t)(sublocale - szDirPrefix)))
346 << wxPATH_SEP;
347 }
348
349 wxString strFile = szName;
350 strFile += MSGCATALOG_EXTENSION;
351
352 // don't give translation errors here because the wxstd catalog might
353 // not yet be loaded (and it's normal)
354 //
355 // (we're using an object because we have several return paths)
356
357 NoTransErr noTransErr;
358 wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
359 szName.c_str(), searchPath.c_str());
360
361 wxString strFullName;
362 if ( !wxFindFileInPath(&strFullName, searchPath, strFile) ) {
363 wxLogVerbose(_("catalog file for domain '%s' not found."), szName.c_str());
364 return FALSE;
365 }
366
367 // open file
368 wxLogVerbose(_("using catalog '%s' from '%s'."),
369 szName.c_str(), strFullName.c_str());
370
371 wxFile fileMsg(strFullName);
372 if ( !fileMsg.IsOpened() )
373 return FALSE;
374
375 // get the file size
376 off_t nSize = fileMsg.Length();
377 if ( nSize == wxInvalidOffset )
378 return FALSE;
379
380 // read the whole file in memory
381 m_pData = new size_t8[nSize];
382 if ( fileMsg.Read(m_pData, nSize) != nSize ) {
383 wxDELETEA(m_pData);
384 return FALSE;
385 }
386
387 // examine header
388 bool bValid = (size_t)nSize > sizeof(wxMsgCatalogHeader);
389
390 wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
391 if ( bValid ) {
392 // we'll have to swap all the integers if it's true
393 m_bSwapped = pHeader->magic == MSGCATALOG_MAGIC_SW;
394
395 // check the magic number
396 bValid = m_bSwapped || pHeader->magic == MSGCATALOG_MAGIC;
397 }
398
399 if ( !bValid ) {
400 // it's either too short or has incorrect magic number
401 wxLogWarning(_("'%s' is not a valid message catalog."), strFullName.c_str());
402
403 wxDELETEA(m_pData);
404 return FALSE;
405 }
406
407 // initialize
408 m_numStrings = Swap(pHeader->numStrings);
409 m_pOrigTable = (wxMsgTableEntry *)(m_pData +
410 Swap(pHeader->ofsOrigTable));
411 m_pTransTable = (wxMsgTableEntry *)(m_pData +
412 Swap(pHeader->ofsTransTable));
413
414 m_nHashSize = Swap(pHeader->nHashSize);
415 m_pHashTable = (size_t32 *)(m_pData + Swap(pHeader->ofsHashTable));
416
417 m_pszName = new wxChar[wxStrlen(szName) + 1];
418 wxStrcpy(m_pszName, szName);
419
420 if (bConvertEncoding)
421 ConvertEncoding();
422
423 // everything is fine
424 return TRUE;
425 }
426
427 // search for a string
428 const char *wxMsgCatalog::GetString(const char *szOrig) const
429 {
430 if ( szOrig == NULL )
431 return NULL;
432
433 if ( HasHashTable() ) { // use hash table for lookup if possible
434 size_t32 nHashVal = GetHash(szOrig);
435 size_t32 nIndex = nHashVal % m_nHashSize;
436
437 size_t32 nIncr = 1 + (nHashVal % (m_nHashSize - 2));
438
439 #if defined(__VISAGECPP__)
440 // VA just can't stand while(1) or while(TRUE)
441 bool bOs2var = TRUE;
442 while(bOs2var) {
443 #else
444 while (1) {
445 #endif
446 size_t32 nStr = Swap(m_pHashTable[nIndex]);
447 if ( nStr == 0 )
448 return NULL;
449
450 if ( strcmp(szOrig, StringAtOfs(m_pOrigTable, nStr - 1)) == 0 )
451 return StringAtOfs(m_pTransTable, nStr - 1);
452
453 if ( nIndex >= m_nHashSize - nIncr)
454 nIndex -= m_nHashSize - nIncr;
455 else
456 nIndex += nIncr;
457 }
458 }
459 else { // no hash table: use default binary search
460 size_t32 bottom = 0,
461 top = m_numStrings,
462 current;
463 while ( bottom < top ) {
464 current = (bottom + top) / 2;
465 int res = strcmp(szOrig, StringAtOfs(m_pOrigTable, current));
466 if ( res < 0 )
467 top = current;
468 else if ( res > 0 )
469 bottom = current + 1;
470 else // found!
471 return StringAtOfs(m_pTransTable, current);
472 }
473 }
474
475 // not found
476 return NULL;
477 }
478
479
480 #if wxUSE_GUI
481 #include "wx/fontmap.h"
482 #include "wx/encconv.h"
483 #endif
484
485 void wxMsgCatalog::ConvertEncoding()
486 {
487 #if wxUSE_GUI
488 wxFontEncoding enc;
489
490 // first, find encoding header:
491 const char *hdr = StringAtOfs(m_pOrigTable, 0);
492 if (hdr == NULL) return; // not supported by this catalog, does not have non-fuzzy header
493 if (hdr[0] != 0) return; // ditto
494
495 /* we support catalogs with header (msgid "") that is _not_ marked as "#, fuzzy" (otherwise
496 the string would not be included into compiled catalog) */
497 wxString header(StringAtOfs(m_pTransTable, 0));
498 wxString charset;
499 int pos = header.Find(wxT("Content-Type: text/plain; charset="));
500 if (pos == wxNOT_FOUND)
501 return; // incorrectly filled Content-Type header
502 size_t n = pos + 34; /*strlen("Content-Type: text/plain; charset=")*/
503 while (header[n] != wxT('\n'))
504 charset << header[n++];
505
506 enc = wxTheFontMapper->CharsetToEncoding(charset, FALSE);
507 if ( enc == wxFONTENCODING_SYSTEM )
508 return; // unknown encoding
509
510 wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc);
511 if (a[0] == enc)
512 return; // no conversion needed, locale uses native encoding
513
514 if (a.GetCount() == 0)
515 return; // we don't know common equiv. under this platform
516
517 wxEncodingConverter converter;
518
519 converter.Init(enc, a[0]);
520 for (size_t i = 0; i < m_numStrings; i++)
521 converter.Convert((char*)StringAtOfs(m_pTransTable, i));
522 #endif
523 }
524
525
526 // ----------------------------------------------------------------------------
527 // wxLocale
528 // ----------------------------------------------------------------------------
529
530 #include "wx/arrimpl.cpp"
531 WX_DECLARE_EXPORTED_OBJARRAY(wxLanguageInfo, wxLanguageInfoArray);
532 WX_DEFINE_OBJARRAY(wxLanguageInfoArray);
533
534
535
536 wxLocale::wxLocale()
537 {
538 m_pszOldLocale = NULL;
539 m_pMsgCat = NULL;
540 m_languagesDB = NULL;
541 m_language = wxLANGUAGE_UNKNOWN;
542 }
543
544 // NB: this function has (desired) side effect of changing current locale
545 bool wxLocale::Init(const wxChar *szName,
546 const wxChar *szShort,
547 const wxChar *szLocale,
548 bool bLoadDefault,
549 bool bConvertEncoding)
550 {
551 m_strLocale = szName;
552 m_strShort = szShort;
553 m_bConvertEncoding = bConvertEncoding;
554 m_language = wxLANGUAGE_UNKNOWN;
555
556 // change current locale (default: same as long name)
557 if ( szLocale == NULL )
558 {
559 // the argument to setlocale()
560 szLocale = szShort;
561 }
562 m_pszOldLocale = wxSetlocale(LC_ALL, szLocale);
563 if ( m_pszOldLocale == NULL )
564 wxLogError(_("locale '%s' can not be set."), szLocale);
565
566 // the short name will be used to look for catalog files as well,
567 // so we need something here
568 if ( m_strShort.IsEmpty() ) {
569 // FIXME I don't know how these 2 letter abbreviations are formed,
570 // this wild guess is surely wrong
571 m_strShort = tolower(szLocale[0]) + tolower(szLocale[1]);
572 }
573
574 // save the old locale to be able to restore it later
575 m_pOldLocale = wxSetLocale(this);
576
577 // load the default catalog with wxWindows standard messages
578 m_pMsgCat = NULL;
579 bool bOk = TRUE;
580 if ( bLoadDefault )
581 bOk = AddCatalog(wxT("wxstd"));
582
583 return bOk;
584 }
585
586
587
588 bool wxLocale::Init(int language, int flags)
589 {
590 wxLanguageInfo *info = NULL;
591 int lang = language;
592
593 if (m_languagesDB == NULL)
594 {
595 m_languagesDB = new wxLanguageInfoArray;
596 InitLanguagesDB();
597 }
598
599 if (lang == wxLANGUAGE_DEFAULT) lang = GetSystemLanguage();
600 if (lang != wxLANGUAGE_UNKNOWN)
601 {
602 for (size_t i = 0; i < m_languagesDB->GetCount(); i++)
603 {
604 if (m_languagesDB->Item(i).Language == lang)
605 {
606 info = &m_languagesDB->Item(i);
607 break;
608 }
609 }
610 }
611
612 // We failed to detect system language, so we will use English:
613 if (lang == wxLANGUAGE_UNKNOWN)
614 {
615 return FALSE;
616 }
617 // Unknown language:
618 if (info == NULL)
619 {
620 wxLogError(wxT("Unknown language %i."), lang);
621 return FALSE;
622 }
623
624 wxString name = info->Description;
625 wxString canonical = info->CanonicalName;
626 wxString locale;
627 wxChar *retloc;
628
629 // Set the locale:
630 #ifdef __UNIX__
631 if (language == wxLANGUAGE_DEFAULT) locale = wxEmptyString;
632 else locale = info->CanonicalName;
633
634 retloc = wxSetlocale(LC_ALL, locale);
635
636 if (retloc == NULL)
637 {
638 // Some C libraries don't like xx_YY form and require xx only
639 retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
640 }
641 if (retloc == NULL)
642 {
643 // Some C libraries (namely glibc) still use old ISO 639,
644 // so will translate the abbrev for them
645 wxString mid = locale.Mid(0,2);
646 if (mid == wxT("he")) locale = wxT("iw") + locale.Mid(3);
647 else if (mid == wxT("id")) locale = wxT("in") + locale.Mid(3);
648 else if (mid == wxT("yi")) locale = wxT("ji") + locale.Mid(3);
649 retloc = wxSetlocale(LC_ALL, locale);
650 }
651 if (retloc == NULL)
652 {
653 // (This time, we changed locale in previous if-branch, so try again.)
654 // Some C libraries don't like xx_YY form and require xx only
655 retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
656 }
657 if (retloc == NULL)
658 {
659 wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
660 return FALSE;
661 }
662
663 #elif defined(__WIN32__)
664 if (language != wxLANGUAGE_DEFAULT)
665 {
666 wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
667 SORT_DEFAULT);
668 if (SetThreadLocale(lcid))
669 retloc = wxSetlocale(LC_ALL, wxEmptyString);
670 else
671 {
672 // Windows9X doesn't support SetThreadLocale, so we must
673 // translate LCID to CRT's setlocale string ourselves
674 locale.Empty();
675 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
676 {
677 wxChar buffer[256];
678 buffer[0] = wxT('\0');
679 GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
680 locale << buffer;
681 if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
682 locale << wxT("_") << buffer;
683 }
684 if (locale.IsEmpty())
685 {
686 wxLogLastError(wxT("SetThreadLocale"));
687 wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
688 return FALSE;
689 }
690 else
691 retloc = wxSetlocale(LC_ALL, locale);
692 }
693 }
694 else
695 retloc = wxSetlocale(LC_ALL, wxEmptyString);
696
697 if (retloc == NULL)
698 {
699 wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
700 return FALSE;
701 }
702
703 #else
704 return FALSE;
705 #endif
706
707 return Init(name, canonical, wxString(retloc),
708 (flags & wxLOCALE_LOAD_DEFAULT) != 0,
709 (flags & wxLOCALE_CONV_ENCODING) != 0);
710 }
711
712
713
714 void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
715 {
716 if ( s_searchPrefixes.Index(prefix) == wxNOT_FOUND )
717 {
718 s_searchPrefixes.Add(prefix);
719 }
720 //else: already have it
721 }
722
723
724 int wxLocale::GetSystemLanguage()
725 {
726 int wxlang = wxLANGUAGE_UNKNOWN;
727 size_t i;
728
729 wxASSERT_MSG(m_languagesDB != NULL, "Languages DB not initialized, call wxLocale::Init!");
730
731 #if defined(__UNIX__)
732 wxString lang;
733 if (!wxGetEnv(wxT("LC_ALL"), &lang) &&
734 !wxGetEnv(wxT("LC_MESSAGES"), &lang) &&
735 !wxGetEnv(wxT("LANG"), &lang))
736 return wxLANGUAGE_UNKNOWN;
737
738 bool is_abbrev = lang.Len() == 2 ||
739 (lang.Len() == 5 && lang[2] == wxT('_'));
740
741 // 0. Make sure the abbrev is according to latest ISO 639
742 // (this is neccessary because glibc uses iw and in instead
743 // of he and id respectively).
744 if (is_abbrev)
745 {
746 wxString mid = lang.Mid(0,2);
747 if (mid == wxT("iw")) lang = wxT("he") + lang.Mid(3);
748 else if (mid == wxT("in")) lang = wxT("id") + lang.Mid(3);
749 else if (mid == wxT("ji")) lang = wxT("yi") + lang.Mid(3);
750 }
751
752 // 1. Try to find the lang as is:
753 if (is_abbrev)
754 {
755 for (i = 0; i < m_languagesDB->GetCount(); i++)
756 {
757 if (m_languagesDB->Item(i).CanonicalName == lang)
758 {
759 wxlang = m_languagesDB->Item(i).Language;
760 break;
761 }
762 }
763 }
764
765 // 2. If lang is of the form xx_YY, try to find xx:
766 if (wxlang == wxLANGUAGE_UNKNOWN && is_abbrev && lang.Len() == 5)
767 {
768 wxString lang2 = lang.Mid(0,2);
769 for (i = 0; i < m_languagesDB->GetCount(); i++)
770 {
771 if (m_languagesDB->Item(i).CanonicalName == lang2)
772 {
773 wxlang = m_languagesDB->Item(i).Language;
774 break;
775 }
776 }
777 }
778
779 // 3. If lang is of the form xx, try to find any xx_YY record:
780 if (wxlang == wxLANGUAGE_UNKNOWN && is_abbrev && lang.Len() == 2)
781 {
782 for (i = 0; i < m_languagesDB->GetCount(); i++)
783 {
784 if (m_languagesDB->Item(i).CanonicalName.Mid(0,2) == lang)
785 {
786 wxlang = m_languagesDB->Item(i).Language;
787 break;
788 }
789 }
790 }
791
792 // 4. If everything failed, try to find the name in verbose description
793 // (SuSE is known to use LANG="german"):
794 if (wxlang == wxLANGUAGE_UNKNOWN && !is_abbrev)
795 {
796 for (i = 0; i < m_languagesDB->GetCount(); i++)
797 {
798 if (m_languagesDB->Item(i).Description.CmpNoCase(lang) == 0)
799 {
800 wxlang = m_languagesDB->Item(i).Language;
801 break;
802 }
803 }
804 }
805
806 #elif defined(__WIN32__)
807 LCID lcid = GetUserDefaultLCID();
808 if (lcid == 0) return wxLANGUAGE_UNKNOWN;
809 wxUint32 lang = PRIMARYLANGID(LANGIDFROMLCID(lcid));
810 wxUint32 sublang = SUBLANGID(LANGIDFROMLCID(lcid));
811
812 for (i = 0; i < m_languagesDB->GetCount(); i++)
813 {
814 if (m_languagesDB->Item(i).WinLang == lang &&
815 m_languagesDB->Item(i).WinSublang == sublang)
816 {
817 wxlang = m_languagesDB->Item(i).Language;
818 break;
819 }
820 }
821 #endif
822
823 return wxlang;
824 }
825
826
827
828 void wxLocale::AddLanguage(const wxLanguageInfo& info)
829 {
830 wxASSERT_MSG(m_languagesDB != NULL, "Languages DB not initialized, call wxLocale::Init!");
831 m_languagesDB->Add(info);
832 }
833
834
835
836 wxString wxLocale::GetSysName() const
837 {
838 return wxSetlocale(LC_ALL, NULL);
839 }
840
841
842
843 // clean up
844 wxLocale::~wxLocale()
845 {
846 // free memory
847 wxMsgCatalog *pTmpCat;
848 while ( m_pMsgCat != NULL ) {
849 pTmpCat = m_pMsgCat;
850 m_pMsgCat = m_pMsgCat->m_pNext;
851 delete pTmpCat;
852 }
853
854 delete m_languagesDB;
855
856 // restore old locale
857 wxSetLocale(m_pOldLocale);
858 wxSetlocale(LC_ALL, m_pszOldLocale);
859 }
860
861 // get the translation of given string in current locale
862 const wxMB2WXbuf wxLocale::GetString(const wxChar *szOrigString,
863 const wxChar *szDomain) const
864 {
865 if ( wxIsEmpty(szOrigString) )
866 return szDomain;
867
868 const char *pszTrans = NULL;
869 #if wxUSE_UNICODE
870 const wxWX2MBbuf szOrgString = wxConvCurrent->cWX2MB(szOrigString);
871 #else // ANSI
872 #define szOrgString szOrigString
873 #endif // Unicode/ANSI
874
875 wxMsgCatalog *pMsgCat;
876 if ( szDomain != NULL ) {
877 pMsgCat = FindCatalog(szDomain);
878
879 // does the catalog exist?
880 if ( pMsgCat != NULL )
881 pszTrans = pMsgCat->GetString(szOrgString);
882 }
883 else {
884 // search in all domains
885 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) {
886 pszTrans = pMsgCat->GetString(szOrgString);
887 if ( pszTrans != NULL ) // take the first found
888 break;
889 }
890 }
891
892 if ( pszTrans == NULL ) {
893 #ifdef __WXDEBUG__
894 if ( !NoTransErr::Suppress() ) {
895 NoTransErr noTransErr;
896
897 if ( szDomain != NULL )
898 {
899 wxLogDebug(_T("string '%s' not found in domain '%s' for locale '%s'."),
900 szOrigString, szDomain, m_strLocale.c_str());
901 }
902 else
903 {
904 wxLogDebug(_T("string '%s' not found in locale '%s'."),
905 szOrigString, m_strLocale.c_str());
906 }
907 }
908 #endif // __WXDEBUG__
909
910 return (wxMB2WXbuf)(szOrigString);
911 }
912 else
913 {
914 return wxConvertMB2WX(pszTrans); // or preferably wxCSConv(charset).cMB2WX(pszTrans) or something,
915 // a macro similar to wxConvertMB2WX could be written for that
916 }
917
918 #undef szOrgString
919 }
920
921 // find catalog by name in a linked list, return NULL if !found
922 wxMsgCatalog *wxLocale::FindCatalog(const wxChar *szDomain) const
923 {
924 // linear search in the linked list
925 wxMsgCatalog *pMsgCat;
926 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) {
927 if ( wxStricmp(pMsgCat->GetName(), szDomain) == 0 )
928 return pMsgCat;
929 }
930
931 return NULL;
932 }
933
934 // check if the given catalog is loaded
935 bool wxLocale::IsLoaded(const wxChar *szDomain) const
936 {
937 return FindCatalog(szDomain) != NULL;
938 }
939
940 // add a catalog to our linked list
941 bool wxLocale::AddCatalog(const wxChar *szDomain)
942 {
943 wxMsgCatalog *pMsgCat = new wxMsgCatalog;
944
945 if ( pMsgCat->Load(m_strShort, szDomain, m_bConvertEncoding) ) {
946 // add it to the head of the list so that in GetString it will
947 // be searched before the catalogs added earlier
948 pMsgCat->m_pNext = m_pMsgCat;
949 m_pMsgCat = pMsgCat;
950
951 return TRUE;
952 }
953 else {
954 // don't add it because it couldn't be loaded anyway
955 delete pMsgCat;
956
957 return FALSE;
958 }
959 }
960
961
962
963
964
965
966 // ----------------------------------------------------------------------------
967 // global functions and variables
968 // ----------------------------------------------------------------------------
969
970 // retrieve/change current locale
971 // ------------------------------
972
973 // the current locale object
974 static wxLocale *g_pLocale = NULL;
975
976 wxLocale *wxGetLocale()
977 {
978 return g_pLocale;
979 }
980
981 wxLocale *wxSetLocale(wxLocale *pLocale)
982 {
983 wxLocale *pOld = g_pLocale;
984 g_pLocale = pLocale;
985 return pOld;
986 }
987
988
989
990
991 // ----------------------------------------------------------------------------
992 // default languages table & initialization
993 // ----------------------------------------------------------------------------
994
995 // This table is generated by misc/languages/genlang.py
996 // When making changes, please put them into misc/languages/langtabl.txt
997
998 #ifdef __WXMSW__
999 #define SETWINLANG(info,lang,sublang) \
1000 info.WinLang = lang, info.WinSublang = sublang;
1001 #else
1002 #define SETWINLANG(info,lang,sublang)
1003 #endif
1004
1005 #define LNG(wxlang, canonical, winlang, winsublang, desc) \
1006 info.Language = wxlang; \
1007 info.CanonicalName = wxT(canonical); \
1008 info.Description = desc; \
1009 SETWINLANG(info, winlang, winsublang) \
1010 AddLanguage(info);
1011
1012 void wxLocale::InitLanguagesDB()
1013 {
1014 wxLanguageInfo info;
1015 wxStringTokenizer tkn;
1016
1017 LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , "Abkhazian")
1018 LNG(wxLANGUAGE_AFAR, "aa" , 0 , 0 , "Afar")
1019 LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , "Afrikaans")
1020 LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , "Albanian")
1021 LNG(wxLANGUAGE_AMHARIC, "am" , 0 , 0 , "Amharic")
1022 LNG(wxLANGUAGE_ARABIC, "ar" , LANG_ARABIC , SUBLANG_DEFAULT , "Arabic")
1023 LNG(wxLANGUAGE_ARABIC_ALGERIA, "ar_DZ", LANG_ARABIC , SUBLANG_ARABIC_ALGERIA , "Arabic (Algeria)")
1024 LNG(wxLANGUAGE_ARABIC_BAHRAIN, "ar_BH", LANG_ARABIC , SUBLANG_ARABIC_BAHRAIN , "Arabic (Bahrain)")
1025 LNG(wxLANGUAGE_ARABIC_EGYPT, "ar_EG", LANG_ARABIC , SUBLANG_ARABIC_EGYPT , "Arabic (Egypt)")
1026 LNG(wxLANGUAGE_ARABIC_IRAQ, "ar_IQ", LANG_ARABIC , SUBLANG_ARABIC_IRAQ , "Arabic (Iraq)")
1027 LNG(wxLANGUAGE_ARABIC_JORDAN, "ar_JO", LANG_ARABIC , SUBLANG_ARABIC_JORDAN , "Arabic (Jordan)")
1028 LNG(wxLANGUAGE_ARABIC_KUWAIT, "ar_KW", LANG_ARABIC , SUBLANG_ARABIC_KUWAIT , "Arabic (Kuwait)")
1029 LNG(wxLANGUAGE_ARABIC_LEBANON, "ar_LB", LANG_ARABIC , SUBLANG_ARABIC_LEBANON , "Arabic (Lebanon)")
1030 LNG(wxLANGUAGE_ARABIC_LIBYA, "ar_LY", LANG_ARABIC , SUBLANG_ARABIC_LIBYA , "Arabic (Libya)")
1031 LNG(wxLANGUAGE_ARABIC_MOROCCO, "ar_MA", LANG_ARABIC , SUBLANG_ARABIC_MOROCCO , "Arabic (Morocco)")
1032 LNG(wxLANGUAGE_ARABIC_OMAN, "ar_OM", LANG_ARABIC , SUBLANG_ARABIC_OMAN , "Arabic (Oman)")
1033 LNG(wxLANGUAGE_ARABIC_QATAR, "ar_QA", LANG_ARABIC , SUBLANG_ARABIC_QATAR , "Arabic (Qatar)")
1034 LNG(wxLANGUAGE_ARABIC_SAUDI_ARABIA, "ar_SA", LANG_ARABIC , SUBLANG_ARABIC_SAUDI_ARABIA , "Arabic (Saudi Arabia)")
1035 LNG(wxLANGUAGE_ARABIC_SUDAN, "ar_SD", 0 , 0 , "Arabic (Sudan)")
1036 LNG(wxLANGUAGE_ARABIC_SYRIA, "ar_SY", LANG_ARABIC , SUBLANG_ARABIC_SYRIA , "Arabic (Syria)")
1037 LNG(wxLANGUAGE_ARABIC_TUNISIA, "ar_TN", LANG_ARABIC , SUBLANG_ARABIC_TUNISIA , "Arabic (Tunisia)")
1038 LNG(wxLANGUAGE_ARABIC_UAE, "ar_AE", LANG_ARABIC , SUBLANG_ARABIC_UAE , "Arabic (Uae)")
1039 LNG(wxLANGUAGE_ARABIC_YEMEN, "ar_YE", LANG_ARABIC , SUBLANG_ARABIC_YEMEN , "Arabic (Yemen)")
1040 LNG(wxLANGUAGE_ARMENIAN, "hy" , LANG_ARMENIAN , SUBLANG_DEFAULT , "Armenian")
1041 LNG(wxLANGUAGE_ASSAMESE, "as" , LANG_ASSAMESE , SUBLANG_DEFAULT , "Assamese")
1042 LNG(wxLANGUAGE_AYMARA, "ay" , 0 , 0 , "Aymara")
1043 LNG(wxLANGUAGE_AZERI, "az" , LANG_AZERI , SUBLANG_DEFAULT , "Azeri")
1044 LNG(wxLANGUAGE_AZERI_CYRILLIC, "az" , LANG_AZERI , SUBLANG_AZERI_CYRILLIC , "Azeri (Cyrillic)")
1045 LNG(wxLANGUAGE_AZERI_LATIN, "az" , LANG_AZERI , SUBLANG_AZERI_LATIN , "Azeri (Latin)")
1046 LNG(wxLANGUAGE_BASHKIR, "ba" , 0 , 0 , "Bashkir")
1047 LNG(wxLANGUAGE_BASQUE, "eu_ES", LANG_BASQUE , SUBLANG_DEFAULT , "Basque")
1048 LNG(wxLANGUAGE_BELARUSIAN, "be_BY", LANG_BELARUSIAN, SUBLANG_DEFAULT , "Belarusian")
1049 LNG(wxLANGUAGE_BENGALI, "bn" , LANG_BENGALI , SUBLANG_DEFAULT , "Bengali")
1050 LNG(wxLANGUAGE_BHUTANI, "dz" , 0 , 0 , "Bhutani")
1051 LNG(wxLANGUAGE_BIHARI, "bh" , 0 , 0 , "Bihari")
1052 LNG(wxLANGUAGE_BISLAMA, "bi" , 0 , 0 , "Bislama")
1053 LNG(wxLANGUAGE_BRETON, "br" , 0 , 0 , "Breton")
1054 LNG(wxLANGUAGE_BULGARIAN, "bg_BG", LANG_BULGARIAN , SUBLANG_DEFAULT , "Bulgarian")
1055 LNG(wxLANGUAGE_BURMESE, "my" , 0 , 0 , "Burmese")
1056 LNG(wxLANGUAGE_CAMBODIAN, "km" , 0 , 0 , "Cambodian")
1057 LNG(wxLANGUAGE_CATALAN, "ca_ES", LANG_CATALAN , SUBLANG_DEFAULT , "Catalan")
1058 LNG(wxLANGUAGE_CHINESE, "zh_CN", LANG_CHINESE , SUBLANG_DEFAULT , "Chinese")
1059 LNG(wxLANGUAGE_CHINESE_SIMPLIFIED, "zh_CN", LANG_CHINESE , SUBLANG_CHINESE_SIMPLIFIED , "Chinese (Simplified)")
1060 LNG(wxLANGUAGE_CHINESE_TRADITIONAL, "zh_CN", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , "Chinese (Traditional)")
1061 LNG(wxLANGUAGE_CHINESE_HONGKONG, "zh_HK", LANG_CHINESE , SUBLANG_CHINESE_HONGKONG , "Chinese (Hongkong)")
1062 LNG(wxLANGUAGE_CHINESE_MACAU, "zh_MO", LANG_CHINESE , SUBLANG_CHINESE_MACAU , "Chinese (Macau)")
1063 LNG(wxLANGUAGE_CHINESE_SINGAPORE, "zh_SG", LANG_CHINESE , SUBLANG_CHINESE_SINGAPORE , "Chinese (Singapore)")
1064 LNG(wxLANGUAGE_CHINESE_TAIWAN, "zh_TW", 0 , 0 , "Chinese (Taiwan)")
1065 LNG(wxLANGUAGE_CORSICAN, "co" , 0 , 0 , "Corsican")
1066 LNG(wxLANGUAGE_CROATIAN, "hr_HR", LANG_CROATIAN , SUBLANG_DEFAULT , "Croatian")
1067 LNG(wxLANGUAGE_CZECH, "cs_CZ", LANG_CZECH , SUBLANG_DEFAULT , "Czech")
1068 LNG(wxLANGUAGE_DANISH, "da_DK", LANG_DANISH , SUBLANG_DEFAULT , "Danish")
1069 LNG(wxLANGUAGE_DUTCH, "nl_NL", LANG_DUTCH , SUBLANG_DUTCH , "Dutch")
1070 LNG(wxLANGUAGE_DUTCH_BELGIAN, "nl_BE", LANG_DUTCH , SUBLANG_DUTCH_BELGIAN , "Dutch (Belgian)")
1071 LNG(wxLANGUAGE_ENGLISH, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , "English")
1072 LNG(wxLANGUAGE_ENGLISH_UK, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , "English (U.K.)")
1073 LNG(wxLANGUAGE_ENGLISH_US, "en_US", LANG_ENGLISH , SUBLANG_ENGLISH_US , "English (U.S.)")
1074 LNG(wxLANGUAGE_ENGLISH_AUSTRALIA, "en_AU", LANG_ENGLISH , SUBLANG_ENGLISH_AUS , "English (Australia)")
1075 LNG(wxLANGUAGE_ENGLISH_BELIZE, "en_BZ", LANG_ENGLISH , SUBLANG_ENGLISH_BELIZE , "English (Belize)")
1076 LNG(wxLANGUAGE_ENGLISH_BOTSWANA, "en_BW", 0 , 0 , "English (Botswana)")
1077 LNG(wxLANGUAGE_ENGLISH_CANADA, "en_CA", LANG_ENGLISH , SUBLANG_ENGLISH_CAN , "English (Canada)")
1078 LNG(wxLANGUAGE_ENGLISH_CARIBBEAN, "en_CB", LANG_ENGLISH , SUBLANG_ENGLISH_CARIBBEAN , "English (Caribbean)")
1079 LNG(wxLANGUAGE_ENGLISH_DENMARK, "en_DK", 0 , 0 , "English (Denmark)")
1080 LNG(wxLANGUAGE_ENGLISH_EIRE, "en_IE", LANG_ENGLISH , SUBLANG_ENGLISH_EIRE , "English (Eire)")
1081 LNG(wxLANGUAGE_ENGLISH_JAMAICA, "en_JM", LANG_ENGLISH , SUBLANG_ENGLISH_JAMAICA , "English (Jamaica)")
1082 LNG(wxLANGUAGE_ENGLISH_NEW_ZEALAND, "en_NZ", LANG_ENGLISH , SUBLANG_ENGLISH_NZ , "English (New Zealand)")
1083 LNG(wxLANGUAGE_ENGLISH_PHILIPPINES, "en_PH", LANG_ENGLISH , SUBLANG_ENGLISH_PHILIPPINES , "English (Philippines)")
1084 LNG(wxLANGUAGE_ENGLISH_SOUTH_AFRICA, "en_ZA", LANG_ENGLISH , SUBLANG_ENGLISH_SOUTH_AFRICA , "English (South Africa)")
1085 LNG(wxLANGUAGE_ENGLISH_TRINIDAD, "en_TT", LANG_ENGLISH , SUBLANG_ENGLISH_TRINIDAD , "English (Trinidad)")
1086 LNG(wxLANGUAGE_ENGLISH_ZIMBABWE, "en_ZW", LANG_ENGLISH , SUBLANG_ENGLISH_ZIMBABWE , "English (Zimbabwe)")
1087 LNG(wxLANGUAGE_ESPERANTO, "eo" , 0 , 0 , "Esperanto")
1088 LNG(wxLANGUAGE_ESTONIAN, "et_EE", LANG_ESTONIAN , SUBLANG_DEFAULT , "Estonian")
1089 LNG(wxLANGUAGE_FAEROESE, "fo_FO", LANG_FAEROESE , SUBLANG_DEFAULT , "Faeroese")
1090 LNG(wxLANGUAGE_FARSI, "" , LANG_FARSI , SUBLANG_DEFAULT , "Farsi")
1091 LNG(wxLANGUAGE_FIJI, "fj" , 0 , 0 , "Fiji")
1092 LNG(wxLANGUAGE_FINNISH, "fi_FI", LANG_FINNISH , SUBLANG_DEFAULT , "Finnish")
1093 LNG(wxLANGUAGE_FRENCH, "fr_FR", LANG_FRENCH , SUBLANG_FRENCH , "French")
1094 LNG(wxLANGUAGE_FRENCH_BELGIAN, "fr_BE", LANG_FRENCH , SUBLANG_FRENCH_BELGIAN , "French (Belgian)")
1095 LNG(wxLANGUAGE_FRENCH_CANADIAN, "fr_CA", LANG_FRENCH , SUBLANG_FRENCH_CANADIAN , "French (Canadian)")
1096 LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , "French (Luxembourg)")
1097 LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , "French (Monaco)")
1098 LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , "French (Swiss)")
1099 LNG(wxLANGUAGE_FRISIAN, "fy" , 0 , 0 , "Frisian")
1100 LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , "Galician")
1101 LNG(wxLANGUAGE_GEORGIAN, "ka" , LANG_GEORGIAN , SUBLANG_DEFAULT , "Georgian")
1102 LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , "German")
1103 LNG(wxLANGUAGE_GERMAN_AUSTRIAN, "de_AT", LANG_GERMAN , SUBLANG_GERMAN_AUSTRIAN , "German (Austrian)")
1104 LNG(wxLANGUAGE_GERMAN_BELGIUM, "de_BE", 0 , 0 , "German (Belgium)")
1105 LNG(wxLANGUAGE_GERMAN_LIECHTENSTEIN, "de_LI", LANG_GERMAN , SUBLANG_GERMAN_LIECHTENSTEIN , "German (Liechtenstein)")
1106 LNG(wxLANGUAGE_GERMAN_LUXEMBOURG, "de_LU", LANG_GERMAN , SUBLANG_GERMAN_LUXEMBOURG , "German (Luxembourg)")
1107 LNG(wxLANGUAGE_GERMAN_SWISS, "de_CH", LANG_GERMAN , SUBLANG_GERMAN_SWISS , "German (Swiss)")
1108 LNG(wxLANGUAGE_GREEK, "el_GR", LANG_GREEK , SUBLANG_DEFAULT , "Greek")
1109 LNG(wxLANGUAGE_GREENLANDIC, "kl_GL", 0 , 0 , "Greenlandic")
1110 LNG(wxLANGUAGE_GUARANI, "gn" , 0 , 0 , "Guarani")
1111 LNG(wxLANGUAGE_GUJARATI, "gu" , LANG_GUJARATI , SUBLANG_DEFAULT , "Gujarati")
1112 LNG(wxLANGUAGE_HAUSA, "ha" , 0 , 0 , "Hausa")
1113 LNG(wxLANGUAGE_HEBREW, "he_IL", LANG_HEBREW , SUBLANG_DEFAULT , "Hebrew")
1114 LNG(wxLANGUAGE_HINDI, "hi_IN", LANG_HINDI , SUBLANG_DEFAULT , "Hindi")
1115 LNG(wxLANGUAGE_HUNGARIAN, "hu_HU", LANG_HUNGARIAN , SUBLANG_DEFAULT , "Hungarian")
1116 LNG(wxLANGUAGE_ICELANDIC, "is_IS", LANG_ICELANDIC , SUBLANG_DEFAULT , "Icelandic")
1117 LNG(wxLANGUAGE_INDONESIAN, "id_ID", LANG_INDONESIAN, SUBLANG_DEFAULT , "Indonesian")
1118 LNG(wxLANGUAGE_INTERLINGUA, "ia" , 0 , 0 , "Interlingua")
1119 LNG(wxLANGUAGE_INTERLINGUE, "ie" , 0 , 0 , "Interlingue")
1120 LNG(wxLANGUAGE_INUKTITUT, "iu" , 0 , 0 , "Inuktitut")
1121 LNG(wxLANGUAGE_INUPIAK, "ik" , 0 , 0 , "Inupiak")
1122 LNG(wxLANGUAGE_IRISH, "ga_IE", 0 , 0 , "Irish")
1123 LNG(wxLANGUAGE_ITALIAN, "it_IT", LANG_ITALIAN , SUBLANG_ITALIAN , "Italian")
1124 LNG(wxLANGUAGE_ITALIAN_SWISS, "it_CH", LANG_ITALIAN , SUBLANG_ITALIAN_SWISS , "Italian (Swiss)")
1125 LNG(wxLANGUAGE_JAPANESE, "ja_JP", LANG_JAPANESE , SUBLANG_DEFAULT , "Japanese")
1126 LNG(wxLANGUAGE_JAVANESE, "jw" , 0 , 0 , "Javanese")
1127 LNG(wxLANGUAGE_KANNADA, "kn" , LANG_KANNADA , SUBLANG_DEFAULT , "Kannada")
1128 LNG(wxLANGUAGE_KASHMIRI, "ks" , LANG_KASHMIRI , SUBLANG_DEFAULT , "Kashmiri")
1129 LNG(wxLANGUAGE_KASHMIRI_INDIA, "ks_IN", LANG_KASHMIRI , SUBLANG_KASHMIRI_INDIA , "Kashmiri (India)")
1130 LNG(wxLANGUAGE_KAZAKH, "kk" , LANG_KAZAK , SUBLANG_DEFAULT , "Kazakh")
1131 LNG(wxLANGUAGE_KERNEWEK, "kw_GB", 0 , 0 , "Kernewek")
1132 LNG(wxLANGUAGE_KINYARWANDA, "rw" , 0 , 0 , "Kinyarwanda")
1133 LNG(wxLANGUAGE_KIRGHIZ, "ky" , 0 , 0 , "Kirghiz")
1134 LNG(wxLANGUAGE_KIRUNDI, "rn" , 0 , 0 , "Kirundi")
1135 LNG(wxLANGUAGE_KONKANI, "" , LANG_KONKANI , SUBLANG_DEFAULT , "Konkani")
1136 LNG(wxLANGUAGE_KOREAN, "ko_KR", LANG_KOREAN , SUBLANG_KOREAN , "Korean")
1137 LNG(wxLANGUAGE_KURDISH, "ku" , 0 , 0 , "Kurdish")
1138 LNG(wxLANGUAGE_LAOTHIAN, "lo" , 0 , 0 , "Laothian")
1139 LNG(wxLANGUAGE_LATIN, "la" , 0 , 0 , "Latin")
1140 LNG(wxLANGUAGE_LATVIAN, "lv_LV", LANG_LATVIAN , SUBLANG_DEFAULT , "Latvian")
1141 LNG(wxLANGUAGE_LINGALA, "ln" , 0 , 0 , "Lingala")
1142 LNG(wxLANGUAGE_LITHUANIAN, "lt_LT", LANG_LITHUANIAN, SUBLANG_LITHUANIAN , "Lithuanian")
1143 LNG(wxLANGUAGE_MACEDONIAN, "mk_MK", LANG_MACEDONIAN, SUBLANG_DEFAULT , "Macedonian")
1144 LNG(wxLANGUAGE_MALAGASY, "mg" , 0 , 0 , "Malagasy")
1145 LNG(wxLANGUAGE_MALAY, "ms_MY", LANG_MALAY , SUBLANG_DEFAULT , "Malay")
1146 LNG(wxLANGUAGE_MALAYALAM, "ml" , LANG_MALAYALAM , SUBLANG_DEFAULT , "Malayalam")
1147 LNG(wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, "ms_BN", LANG_MALAY , SUBLANG_MALAY_BRUNEI_DARUSSALAM , "Malay (Brunei Darussalam)")
1148 LNG(wxLANGUAGE_MALAY_MALAYSIA, "ms_MY", LANG_MALAY , SUBLANG_MALAY_MALAYSIA , "Malay (Malaysia)")
1149 LNG(wxLANGUAGE_MALTESE, "mt_MT", 0 , 0 , "Maltese")
1150 LNG(wxLANGUAGE_MANIPURI, "" , LANG_MANIPURI , SUBLANG_DEFAULT , "Manipuri")
1151 LNG(wxLANGUAGE_MAORI, "mi" , 0 , 0 , "Maori")
1152 LNG(wxLANGUAGE_MARATHI, "mr_IN", LANG_MARATHI , SUBLANG_DEFAULT , "Marathi")
1153 LNG(wxLANGUAGE_MOLDAVIAN, "mo" , 0 , 0 , "Moldavian")
1154 LNG(wxLANGUAGE_MONGOLIAN, "mn" , 0 , 0 , "Mongolian")
1155 LNG(wxLANGUAGE_NAURU, "na" , 0 , 0 , "Nauru")
1156 LNG(wxLANGUAGE_NEPALI, "ne" , LANG_NEPALI , SUBLANG_DEFAULT , "Nepali")
1157 LNG(wxLANGUAGE_NEPALI_INDIA, "ne_IN", LANG_NEPALI , SUBLANG_NEPALI_INDIA , "Nepali (India)")
1158 LNG(wxLANGUAGE_NORWEGIAN_BOKMAL, "no_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_BOKMAL , "Norwegian (Bokmal)")
1159 LNG(wxLANGUAGE_NORWEGIAN_NYNORSK, "nn_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_NYNORSK , "Norwegian (Nynorsk)")
1160 LNG(wxLANGUAGE_OCCITAN, "oc" , 0 , 0 , "Occitan")
1161 LNG(wxLANGUAGE_ORIYA, "or" , LANG_ORIYA , SUBLANG_DEFAULT , "Oriya")
1162 LNG(wxLANGUAGE_OROMO, "om" , 0 , 0 , "(Afan) Oromo")
1163 LNG(wxLANGUAGE_PASHTO, "ps" , 0 , 0 , "Pashto, Pushto")
1164 LNG(wxLANGUAGE_PERSIAN, "fa_IR", 0 , 0 , "Persian")
1165 LNG(wxLANGUAGE_POLISH, "pl_PL", LANG_POLISH , SUBLANG_DEFAULT , "Polish")
1166 LNG(wxLANGUAGE_PORTUGUESE, "pt_PT", LANG_PORTUGUESE, SUBLANG_PORTUGUESE , "Portuguese")
1167 LNG(wxLANGUAGE_PORTUGUESE_BRAZILIAN, "pt_BR", LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN , "Portuguese (Brazilian)")
1168 LNG(wxLANGUAGE_PUNJABI, "pa" , LANG_PUNJABI , SUBLANG_DEFAULT , "Punjabi")
1169 LNG(wxLANGUAGE_QUECHUA, "qu" , 0 , 0 , "Quechua")
1170 LNG(wxLANGUAGE_RHAETO_ROMANCE, "rm" , 0 , 0 , "Rhaeto-Romance")
1171 LNG(wxLANGUAGE_ROMANIAN, "ro_RO", LANG_ROMANIAN , SUBLANG_DEFAULT , "Romanian")
1172 LNG(wxLANGUAGE_RUSSIAN, "ru_RU", LANG_RUSSIAN , SUBLANG_DEFAULT , "Russian")
1173 LNG(wxLANGUAGE_RUSSIAN_UKRAINE, "ru_UA", 0 , 0 , "Russian (Ukraine)")
1174 LNG(wxLANGUAGE_SAMOAN, "sm" , 0 , 0 , "Samoan")
1175 LNG(wxLANGUAGE_SANGHO, "sg" , 0 , 0 , "Sangho")
1176 LNG(wxLANGUAGE_SANSKRIT, "sa" , LANG_SANSKRIT , SUBLANG_DEFAULT , "Sanskrit")
1177 LNG(wxLANGUAGE_SCOTS_GAELIC, "gd" , 0 , 0 , "Scots Gaelic")
1178 LNG(wxLANGUAGE_SERBIAN, "sr_YU", LANG_SERBIAN , SUBLANG_DEFAULT , "Serbian")
1179 LNG(wxLANGUAGE_SERBIAN_CYRILLIC, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_CYRILLIC , "Serbian (Cyrillic)")
1180 LNG(wxLANGUAGE_SERBIAN_LATIN, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_LATIN , "Serbian (Latin)")
1181 LNG(wxLANGUAGE_SERBO_CROATIAN, "sh" , 0 , 0 , "Serbo-Croatian")
1182 LNG(wxLANGUAGE_SESOTHO, "st" , 0 , 0 , "Sesotho")
1183 LNG(wxLANGUAGE_SETSWANA, "tn" , 0 , 0 , "Setswana")
1184 LNG(wxLANGUAGE_SHONA, "sn" , 0 , 0 , "Shona")
1185 LNG(wxLANGUAGE_SINDHI, "sd" , LANG_SINDHI , SUBLANG_DEFAULT , "Sindhi")
1186 LNG(wxLANGUAGE_SINHALESE, "si" , 0 , 0 , "Sinhalese")
1187 LNG(wxLANGUAGE_SISWATI, "ss" , 0 , 0 , "Siswati")
1188 LNG(wxLANGUAGE_SLOVAK, "sk_SK", LANG_SLOVAK , SUBLANG_DEFAULT , "Slovak")
1189 LNG(wxLANGUAGE_SLOVENIAN, "sl_SI", LANG_SLOVENIAN , SUBLANG_DEFAULT , "Slovenian")
1190 LNG(wxLANGUAGE_SOMALI, "so" , 0 , 0 , "Somali")
1191 LNG(wxLANGUAGE_SPANISH, "es_ES", LANG_SPANISH , SUBLANG_SPANISH , "Spanish")
1192 LNG(wxLANGUAGE_SPANISH_ARGENTINA, "es_AR", LANG_SPANISH , SUBLANG_SPANISH_ARGENTINA , "Spanish (Argentina)")
1193 LNG(wxLANGUAGE_SPANISH_BOLIVIA, "es_BO", LANG_SPANISH , SUBLANG_SPANISH_BOLIVIA , "Spanish (Bolivia)")
1194 LNG(wxLANGUAGE_SPANISH_CHILE, "es_CL", LANG_SPANISH , SUBLANG_SPANISH_CHILE , "Spanish (Chile)")
1195 LNG(wxLANGUAGE_SPANISH_COLOMBIA, "es_CO", LANG_SPANISH , SUBLANG_SPANISH_COLOMBIA , "Spanish (Colombia)")
1196 LNG(wxLANGUAGE_SPANISH_COSTA_RICA, "es_CR", LANG_SPANISH , SUBLANG_SPANISH_COSTA_RICA , "Spanish (Costa Rica)")
1197 LNG(wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, "es_DO", LANG_SPANISH , SUBLANG_SPANISH_DOMINICAN_REPUBLIC, "Spanish (Dominican republic)")
1198 LNG(wxLANGUAGE_SPANISH_ECUADOR, "es_EC", LANG_SPANISH , SUBLANG_SPANISH_ECUADOR , "Spanish (Ecuador)")
1199 LNG(wxLANGUAGE_SPANISH_EL_SALVADOR, "es_SV", LANG_SPANISH , SUBLANG_SPANISH_EL_SALVADOR , "Spanish (El Salvador)")
1200 LNG(wxLANGUAGE_SPANISH_GUATEMALA, "es_GT", LANG_SPANISH , SUBLANG_SPANISH_GUATEMALA , "Spanish (Guatemala)")
1201 LNG(wxLANGUAGE_SPANISH_HONDURAS, "es_HN", LANG_SPANISH , SUBLANG_SPANISH_HONDURAS , "Spanish (Honduras)")
1202 LNG(wxLANGUAGE_SPANISH_MEXICAN, "es_MX", LANG_SPANISH , SUBLANG_SPANISH_MEXICAN , "Spanish (Mexican)")
1203 LNG(wxLANGUAGE_SPANISH_MODERN, "es_ES", LANG_SPANISH , SUBLANG_SPANISH_MODERN , "Spanish (Modern)")
1204 LNG(wxLANGUAGE_SPANISH_NICARAGUA, "es_NI", LANG_SPANISH , SUBLANG_SPANISH_NICARAGUA , "Spanish (Nicaragua)")
1205 LNG(wxLANGUAGE_SPANISH_PANAMA, "es_PA", LANG_SPANISH , SUBLANG_SPANISH_PANAMA , "Spanish (Panama)")
1206 LNG(wxLANGUAGE_SPANISH_PARAGUAY, "es_PY", LANG_SPANISH , SUBLANG_SPANISH_PARAGUAY , "Spanish (Paraguay)")
1207 LNG(wxLANGUAGE_SPANISH_PERU, "es_PE", LANG_SPANISH , SUBLANG_SPANISH_PERU , "Spanish (Peru)")
1208 LNG(wxLANGUAGE_SPANISH_PUERTO_RICO, "es_PR", LANG_SPANISH , SUBLANG_SPANISH_PUERTO_RICO , "Spanish (Puerto Rico)")
1209 LNG(wxLANGUAGE_SPANISH_URUGUAY, "es_UY", LANG_SPANISH , SUBLANG_SPANISH_URUGUAY , "Spanish (Uruguay)")
1210 LNG(wxLANGUAGE_SPANISH_US, "es_US", 0 , 0 , "Spanish (U.S.)")
1211 LNG(wxLANGUAGE_SPANISH_VENEZUELA, "es_VE", LANG_SPANISH , SUBLANG_SPANISH_VENEZUELA , "Spanish (Venezuela)")
1212 LNG(wxLANGUAGE_SUNDANESE, "su" , 0 , 0 , "Sundanese")
1213 LNG(wxLANGUAGE_SWAHILI, "sw_KE", LANG_SWAHILI , SUBLANG_DEFAULT , "Swahili")
1214 LNG(wxLANGUAGE_SWEDISH, "sv_SE", LANG_SWEDISH , SUBLANG_SWEDISH , "Swedish")
1215 LNG(wxLANGUAGE_SWEDISH_FINLAND, "sv_FI", LANG_SWEDISH , SUBLANG_SWEDISH_FINLAND , "Swedish (Finland)")
1216 LNG(wxLANGUAGE_TAGALOG, "tl" , 0 , 0 , "Tagalog")
1217 LNG(wxLANGUAGE_TAJIK, "tg" , 0 , 0 , "Tajik")
1218 LNG(wxLANGUAGE_TAMIL, "ta" , LANG_TAMIL , SUBLANG_DEFAULT , "Tamil")
1219 LNG(wxLANGUAGE_TATAR, "tt" , LANG_TATAR , SUBLANG_DEFAULT , "Tatar")
1220 LNG(wxLANGUAGE_TELUGU, "te" , LANG_TELUGU , SUBLANG_DEFAULT , "Telugu")
1221 LNG(wxLANGUAGE_THAI, "th_TH", LANG_THAI , SUBLANG_DEFAULT , "Thai")
1222 LNG(wxLANGUAGE_TIBETAN, "bo" , 0 , 0 , "Tibetan")
1223 LNG(wxLANGUAGE_TIGRINYA, "ti" , 0 , 0 , "Tigrinya")
1224 LNG(wxLANGUAGE_TONGA, "to" , 0 , 0 , "Tonga")
1225 LNG(wxLANGUAGE_TSONGA, "ts" , 0 , 0 , "Tsonga")
1226 LNG(wxLANGUAGE_TURKISH, "tr_TR", LANG_TURKISH , SUBLANG_DEFAULT , "Turkish")
1227 LNG(wxLANGUAGE_TURKMEN, "tk" , 0 , 0 , "Turkmen")
1228 LNG(wxLANGUAGE_TWI, "tw" , 0 , 0 , "Twi")
1229 LNG(wxLANGUAGE_UIGHUR, "ug" , 0 , 0 , "Uighur")
1230 LNG(wxLANGUAGE_UKRAINIAN, "uk_UA", LANG_UKRAINIAN , SUBLANG_DEFAULT , "Ukrainian")
1231 LNG(wxLANGUAGE_URDU, "ur" , LANG_URDU , SUBLANG_DEFAULT , "Urdu")
1232 LNG(wxLANGUAGE_URDU_INDIA, "ur_IN", LANG_URDU , SUBLANG_URDU_INDIA , "Urdu (India)")
1233 LNG(wxLANGUAGE_URDU_PAKISTAN, "ur_PK", LANG_URDU , SUBLANG_URDU_PAKISTAN , "Urdu (Pakistan)")
1234 LNG(wxLANGUAGE_UZBEK, "uz" , LANG_UZBEK , SUBLANG_DEFAULT , "Uzbek")
1235 LNG(wxLANGUAGE_UZBEK_CYRILLIC, "uz" , LANG_UZBEK , SUBLANG_UZBEK_CYRILLIC , "Uzbek (Cyrillic)")
1236 LNG(wxLANGUAGE_UZBEK_LATIN, "uz" , LANG_UZBEK , SUBLANG_UZBEK_LATIN , "Uzbek (Latin)")
1237 LNG(wxLANGUAGE_VIETNAMESE, "vi_VN", LANG_VIETNAMESE, SUBLANG_DEFAULT , "Vietnamese")
1238 LNG(wxLANGUAGE_VOLAPUK, "vo" , 0 , 0 , "Volapuk")
1239 LNG(wxLANGUAGE_WELSH, "cy" , 0 , 0 , "Welsh")
1240 LNG(wxLANGUAGE_WOLOF, "wo" , 0 , 0 , "Wolof")
1241 LNG(wxLANGUAGE_XHOSA, "xh" , 0 , 0 , "Xhosa")
1242 LNG(wxLANGUAGE_YIDDISH, "yi" , 0 , 0 , "Yiddish")
1243 LNG(wxLANGUAGE_YORUBA, "yo" , 0 , 0 , "Yoruba")
1244 LNG(wxLANGUAGE_ZHUANG, "za" , 0 , 0 , "Zhuang")
1245 LNG(wxLANGUAGE_ZULU, "zu" , 0 , 0 , "Zulu")
1246 };
1247 #undef LNG
1248
1249
1250
1251 #endif // wxUSE_INTL
1252