]> git.saurik.com Git - wxWidgets.git/blame - src/common/intl.cpp
Strip menu codes out from notebook page labels
[wxWidgets.git] / src / common / intl.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
dccce9ea 2// Name: src/common/intl.cpp
77ffb593 3// Purpose: Internationalization and localisation for wxWidgets
c801d85f 4// Author: Vadim Zeitlin
849a28d0
VS
5// Modified by: Michael N. Filippov <michael@idisys.iae.nsk.su>
6// (2003/09/30 - PluralForms support)
c801d85f
KB
7// Created: 29/01/98
8// RCS-ID: $Id$
9// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
13// ============================================================================
1678ad78 14// declaration
c801d85f
KB
15// ============================================================================
16
17// ----------------------------------------------------------------------------
18// headers
19// ----------------------------------------------------------------------------
20
8bcf4c86
VS
21#if defined(__BORLAND__) && !defined(__WXDEBUG__)
22 // There's a bug in Borland's compiler that breaks wxLocale with -O2,
23 // so make sure that flag is not used for this file:
24 #pragma option -O1
25#endif
26
3c221c50
SN
27#ifdef __EMX__
28// The following define is needed by Innotek's libc to
29// make the definition of struct localeconv available.
30#define __INTERNAL_DEFS
31#endif
32
c801d85f
KB
33// For compilers that support precompilation, includes "wx.h".
34#include "wx/wxprec.h"
35
36#ifdef __BORLANDC__
84c18814 37 #pragma hdrstop
c801d85f
KB
38#endif
39
d427503c
VZ
40#if wxUSE_INTL
41
ad9835c9
WS
42#ifndef WX_PRECOMP
43 #include "wx/dynarray.h"
44 #include "wx/string.h"
45 #include "wx/intl.h"
46 #include "wx/log.h"
ad9835c9 47 #include "wx/utils.h"
670f9935 48 #include "wx/app.h"
df69528b 49 #include "wx/hashmap.h"
02761f6c 50 #include "wx/module.h"
ad9835c9 51#endif // WX_PRECOMP
1c193821
JS
52
53#ifndef __WXWINCE__
ad9835c9 54 #include <locale.h>
1c193821
JS
55#endif
56
ad9835c9 57// standard headers
dccce9ea
VZ
58#include <ctype.h>
59#include <stdlib.h>
2ec6905c 60#ifdef HAVE_LANGINFO_H
670f9935 61 #include <langinfo.h>
2ec6905c 62#endif
7502ba29 63
1c193821
JS
64#ifdef __WIN32__
65 #include "wx/msw/private.h"
66#elif defined(__UNIX_LIKE__)
67 #include "wx/fontmap.h" // for CharsetToEncoding()
68#endif
69
c801d85f 70#include "wx/file.h"
58ad1bab 71#include "wx/filename.h"
dccce9ea 72#include "wx/tokenzr.h"
030c0bea
VS
73#include "wx/fontmap.h"
74#include "wx/encconv.h"
849a28d0 75#include "wx/ptr_scpd.h"
4d931bcc 76#include "wx/apptrait.h"
f830b2b1 77#include "wx/stdpaths.h"
dccce9ea 78
76a5e5d2 79#if defined(__WXMAC__)
670f9935 80 #include "wx/mac/private.h" // includes mac headers
76a5e5d2
SC
81#endif
82
84c18814
VZ
83// ----------------------------------------------------------------------------
84// simple types
85// ----------------------------------------------------------------------------
86
e939abfd 87// this should *not* be wxChar, this type must have exactly 8 bits!
563d535e
VS
88typedef wxUint8 size_t8;
89typedef wxUint32 size_t32;
84c18814 90
c801d85f
KB
91// ----------------------------------------------------------------------------
92// constants
93// ----------------------------------------------------------------------------
94
95// magic number identifying the .mo format file
c86f1403
VZ
96const size_t32 MSGCATALOG_MAGIC = 0x950412de;
97const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
c801d85f 98
ec37df57
VZ
99// the constants describing the format of lang_LANG locale string
100static const size_t LEN_LANG = 2;
101static const size_t LEN_SUBLANG = 2;
102static const size_t LEN_FULL = LEN_LANG + 1 + LEN_SUBLANG; // 1 for '_'
103
ca6a9a14
VZ
104#define TRACE_I18N _T("i18n")
105
c801d85f 106// ----------------------------------------------------------------------------
1678ad78 107// global functions
c801d85f
KB
108// ----------------------------------------------------------------------------
109
f6bcfd97 110#ifdef __WXDEBUG__
c801d85f 111
f6bcfd97
BP
112// small class to suppress the translation erros until exit from current scope
113class NoTransErr
114{
115public:
116 NoTransErr() { ms_suppressCount++; }
117 ~NoTransErr() { ms_suppressCount--; }
118
119 static bool Suppress() { return ms_suppressCount > 0; }
120
121private:
122 static size_t ms_suppressCount;
123};
c801d85f 124
f6bcfd97
BP
125size_t NoTransErr::ms_suppressCount = 0;
126
127#else // !Debug
128
129class NoTransErr
130{
131public:
132 NoTransErr() { }
133 ~NoTransErr() { }
134};
135
136#endif // Debug/!Debug
c801d85f 137
84c18814 138static wxLocale *wxSetLocale(wxLocale *pLocale);
c801d85f 139
ec37df57
VZ
140// helper functions of GetSystemLanguage()
141#ifdef __UNIX__
142
143// get just the language part
144static inline wxString ExtractLang(const wxString& langFull)
145{
146 return langFull.Left(LEN_LANG);
147}
148
149// get everything else (including the leading '_')
150static inline wxString ExtractNotLang(const wxString& langFull)
151{
152 return langFull.Mid(LEN_LANG);
153}
154
155#endif // __UNIX__
156
563d535e 157
849a28d0
VS
158// ----------------------------------------------------------------------------
159// Plural forms parser
160// ----------------------------------------------------------------------------
161
b7b97e77 162/*
849a28d0
VS
163 Simplified Grammar
164
165Expression:
166 LogicalOrExpression '?' Expression ':' Expression
167 LogicalOrExpression
168
169LogicalOrExpression:
170 LogicalAndExpression "||" LogicalOrExpression // to (a || b) || c
171 LogicalAndExpression
172
173LogicalAndExpression:
174 EqualityExpression "&&" LogicalAndExpression // to (a && b) && c
175 EqualityExpression
176
177EqualityExpression:
178 RelationalExpression "==" RelationalExperession
179 RelationalExpression "!=" RelationalExperession
180 RelationalExpression
181
182RelationalExpression:
183 MultiplicativeExpression '>' MultiplicativeExpression
184 MultiplicativeExpression '<' MultiplicativeExpression
185 MultiplicativeExpression ">=" MultiplicativeExpression
186 MultiplicativeExpression "<=" MultiplicativeExpression
187 MultiplicativeExpression
b7b97e77 188
849a28d0
VS
189MultiplicativeExpression:
190 PmExpression '%' PmExpression
191 PmExpression
192
193PmExpression:
194 N
195 Number
196 '(' Expression ')'
197*/
198
199class wxPluralFormsToken
200{
201public:
202 enum Type
203 {
204 T_ERROR, T_EOF, T_NUMBER, T_N, T_PLURAL, T_NPLURALS, T_EQUAL, T_ASSIGN,
205 T_GREATER, T_GREATER_OR_EQUAL, T_LESS, T_LESS_OR_EQUAL,
206 T_REMINDER, T_NOT_EQUAL,
207 T_LOGICAL_AND, T_LOGICAL_OR, T_QUESTION, T_COLON, T_SEMICOLON,
208 T_LEFT_BRACKET, T_RIGHT_BRACKET
209 };
210 Type type() const { return m_type; }
211 void setType(Type type) { m_type = type; }
212 // for T_NUMBER only
213 typedef int Number;
214 Number number() const { return m_number; }
215 void setNumber(Number num) { m_number = num; }
216private:
217 Type m_type;
218 Number m_number;
219};
220
221
222class wxPluralFormsScanner
223{
224public:
225 wxPluralFormsScanner(const char* s);
226 const wxPluralFormsToken& token() const { return m_token; }
227 bool nextToken(); // returns false if error
228private:
229 const char* m_s;
230 wxPluralFormsToken m_token;
231};
232
233wxPluralFormsScanner::wxPluralFormsScanner(const char* s) : m_s(s)
234{
235 nextToken();
236}
237
238bool wxPluralFormsScanner::nextToken()
239{
240 wxPluralFormsToken::Type type = wxPluralFormsToken::T_ERROR;
241 while (isspace(*m_s))
242 {
243 ++m_s;
244 }
245 if (*m_s == 0)
246 {
247 type = wxPluralFormsToken::T_EOF;
248 }
249 else if (isdigit(*m_s))
250 {
251 wxPluralFormsToken::Number number = *m_s++ - '0';
252 while (isdigit(*m_s))
253 {
254 number = number * 10 + (*m_s++ - '0');
255 }
256 m_token.setNumber(number);
257 type = wxPluralFormsToken::T_NUMBER;
258 }
259 else if (isalpha(*m_s))
260 {
261 const char* begin = m_s++;
262 while (isalnum(*m_s))
263 {
264 ++m_s;
265 }
266 size_t size = m_s - begin;
267 if (size == 1 && memcmp(begin, "n", size) == 0)
268 {
269 type = wxPluralFormsToken::T_N;
270 }
271 else if (size == 6 && memcmp(begin, "plural", size) == 0)
272 {
273 type = wxPluralFormsToken::T_PLURAL;
274 }
275 else if (size == 8 && memcmp(begin, "nplurals", size) == 0)
276 {
277 type = wxPluralFormsToken::T_NPLURALS;
278 }
279 }
280 else if (*m_s == '=')
281 {
282 ++m_s;
283 if (*m_s == '=')
284 {
285 ++m_s;
286 type = wxPluralFormsToken::T_EQUAL;
287 }
288 else
289 {
290 type = wxPluralFormsToken::T_ASSIGN;
291 }
292 }
293 else if (*m_s == '>')
294 {
295 ++m_s;
296 if (*m_s == '=')
297 {
298 ++m_s;
299 type = wxPluralFormsToken::T_GREATER_OR_EQUAL;
300 }
301 else
302 {
303 type = wxPluralFormsToken::T_GREATER;
304 }
305 }
306 else if (*m_s == '<')
307 {
308 ++m_s;
309 if (*m_s == '=')
310 {
311 ++m_s;
312 type = wxPluralFormsToken::T_LESS_OR_EQUAL;
313 }
314 else
315 {
316 type = wxPluralFormsToken::T_LESS;
317 }
318 }
319 else if (*m_s == '%')
320 {
321 ++m_s;
322 type = wxPluralFormsToken::T_REMINDER;
323 }
324 else if (*m_s == '!' && m_s[1] == '=')
325 {
326 m_s += 2;
327 type = wxPluralFormsToken::T_NOT_EQUAL;
328 }
329 else if (*m_s == '&' && m_s[1] == '&')
330 {
331 m_s += 2;
332 type = wxPluralFormsToken::T_LOGICAL_AND;
333 }
334 else if (*m_s == '|' && m_s[1] == '|')
335 {
336 m_s += 2;
337 type = wxPluralFormsToken::T_LOGICAL_OR;
338 }
339 else if (*m_s == '?')
340 {
341 ++m_s;
342 type = wxPluralFormsToken::T_QUESTION;
343 }
344 else if (*m_s == ':')
345 {
346 ++m_s;
347 type = wxPluralFormsToken::T_COLON;
348 } else if (*m_s == ';') {
349 ++m_s;
350 type = wxPluralFormsToken::T_SEMICOLON;
351 }
352 else if (*m_s == '(')
353 {
354 ++m_s;
355 type = wxPluralFormsToken::T_LEFT_BRACKET;
356 }
357 else if (*m_s == ')')
358 {
359 ++m_s;
360 type = wxPluralFormsToken::T_RIGHT_BRACKET;
361 }
362 m_token.setType(type);
363 return type != wxPluralFormsToken::T_ERROR;
364}
365
366class wxPluralFormsNode;
367
368// NB: Can't use wxDEFINE_SCOPED_PTR_TYPE because wxPluralFormsNode is not
369// fully defined yet:
370class wxPluralFormsNodePtr
371{
372public:
373 wxPluralFormsNodePtr(wxPluralFormsNode *p = NULL) : m_p(p) {}
374 ~wxPluralFormsNodePtr();
375 wxPluralFormsNode& operator*() const { return *m_p; }
376 wxPluralFormsNode* operator->() const { return m_p; }
377 wxPluralFormsNode* get() const { return m_p; }
378 wxPluralFormsNode* release();
379 void reset(wxPluralFormsNode *p);
380
381private:
382 wxPluralFormsNode *m_p;
383};
384
385class wxPluralFormsNode
386{
387public:
388 wxPluralFormsNode(const wxPluralFormsToken& token) : m_token(token) {}
389 const wxPluralFormsToken& token() const { return m_token; }
390 const wxPluralFormsNode* node(size_t i) const
391 { return m_nodes[i].get(); }
392 void setNode(size_t i, wxPluralFormsNode* n);
393 wxPluralFormsNode* releaseNode(size_t i);
394 wxPluralFormsToken::Number evaluate(wxPluralFormsToken::Number n) const;
395
396private:
397 wxPluralFormsToken m_token;
398 wxPluralFormsNodePtr m_nodes[3];
399};
b7b97e77 400
849a28d0
VS
401wxPluralFormsNodePtr::~wxPluralFormsNodePtr()
402{
403 delete m_p;
404}
405wxPluralFormsNode* wxPluralFormsNodePtr::release()
406{
407 wxPluralFormsNode *p = m_p;
408 m_p = NULL;
409 return p;
410}
411void wxPluralFormsNodePtr::reset(wxPluralFormsNode *p)
412{
413 if (p != m_p)
414 {
415 delete m_p;
416 m_p = p;
417 }
418}
419
420
421void wxPluralFormsNode::setNode(size_t i, wxPluralFormsNode* n)
422{
423 m_nodes[i].reset(n);
424}
425
426wxPluralFormsNode* wxPluralFormsNode::releaseNode(size_t i)
427{
428 return m_nodes[i].release();
429}
430
431wxPluralFormsToken::Number
432wxPluralFormsNode::evaluate(wxPluralFormsToken::Number n) const
433{
434 switch (token().type())
435 {
436 // leaf
437 case wxPluralFormsToken::T_NUMBER:
438 return token().number();
439 case wxPluralFormsToken::T_N:
440 return n;
441 // 2 args
442 case wxPluralFormsToken::T_EQUAL:
443 return node(0)->evaluate(n) == node(1)->evaluate(n);
444 case wxPluralFormsToken::T_NOT_EQUAL:
445 return node(0)->evaluate(n) != node(1)->evaluate(n);
446 case wxPluralFormsToken::T_GREATER:
447 return node(0)->evaluate(n) > node(1)->evaluate(n);
448 case wxPluralFormsToken::T_GREATER_OR_EQUAL:
449 return node(0)->evaluate(n) >= node(1)->evaluate(n);
450 case wxPluralFormsToken::T_LESS:
451 return node(0)->evaluate(n) < node(1)->evaluate(n);
452 case wxPluralFormsToken::T_LESS_OR_EQUAL:
453 return node(0)->evaluate(n) <= node(1)->evaluate(n);
454 case wxPluralFormsToken::T_REMINDER:
455 {
456 wxPluralFormsToken::Number number = node(1)->evaluate(n);
457 if (number != 0)
458 {
459 return node(0)->evaluate(n) % number;
460 }
461 else
462 {
463 return 0;
464 }
465 }
466 case wxPluralFormsToken::T_LOGICAL_AND:
467 return node(0)->evaluate(n) && node(1)->evaluate(n);
468 case wxPluralFormsToken::T_LOGICAL_OR:
469 return node(0)->evaluate(n) || node(1)->evaluate(n);
470 // 3 args
471 case wxPluralFormsToken::T_QUESTION:
472 return node(0)->evaluate(n)
473 ? node(1)->evaluate(n)
474 : node(2)->evaluate(n);
475 default:
476 return 0;
477 }
478}
479
480
481class wxPluralFormsCalculator
482{
483public:
484 wxPluralFormsCalculator() : m_nplurals(0), m_plural(0) {}
b7b97e77 485
849a28d0
VS
486 // input: number, returns msgstr index
487 int evaluate(int n) const;
488
489 // input: text after "Plural-Forms:" (e.g. "nplurals=2; plural=(n != 1);"),
490 // if s == 0, creates default handler
491 // returns 0 if error
492 static wxPluralFormsCalculator* make(const char* s = 0);
493
494 ~wxPluralFormsCalculator() {}
495
496 void init(wxPluralFormsToken::Number nplurals, wxPluralFormsNode* plural);
b7b97e77 497
849a28d0
VS
498private:
499 wxPluralFormsToken::Number m_nplurals;
500 wxPluralFormsNodePtr m_plural;
501};
502
4115960d 503wxDEFINE_SCOPED_PTR_TYPE(wxPluralFormsCalculator)
849a28d0
VS
504
505void wxPluralFormsCalculator::init(wxPluralFormsToken::Number nplurals,
506 wxPluralFormsNode* plural)
507{
508 m_nplurals = nplurals;
509 m_plural.reset(plural);
510}
511
512int wxPluralFormsCalculator::evaluate(int n) const
513{
514 if (m_plural.get() == 0)
515 {
516 return 0;
517 }
518 wxPluralFormsToken::Number number = m_plural->evaluate(n);
519 if (number < 0 || number > m_nplurals)
520 {
521 return 0;
522 }
523 return number;
524}
525
526
527class wxPluralFormsParser
528{
529public:
530 wxPluralFormsParser(wxPluralFormsScanner& scanner) : m_scanner(scanner) {}
531 bool parse(wxPluralFormsCalculator& rCalculator);
532
533private:
534 wxPluralFormsNode* parsePlural();
535 // stops at T_SEMICOLON, returns 0 if error
536 wxPluralFormsScanner& m_scanner;
537 const wxPluralFormsToken& token() const;
538 bool nextToken();
b7b97e77 539
849a28d0
VS
540 wxPluralFormsNode* expression();
541 wxPluralFormsNode* logicalOrExpression();
542 wxPluralFormsNode* logicalAndExpression();
543 wxPluralFormsNode* equalityExpression();
544 wxPluralFormsNode* multiplicativeExpression();
545 wxPluralFormsNode* relationalExpression();
546 wxPluralFormsNode* pmExpression();
547};
548
549bool wxPluralFormsParser::parse(wxPluralFormsCalculator& rCalculator)
550{
551 if (token().type() != wxPluralFormsToken::T_NPLURALS)
552 return false;
553 if (!nextToken())
554 return false;
555 if (token().type() != wxPluralFormsToken::T_ASSIGN)
556 return false;
557 if (!nextToken())
558 return false;
559 if (token().type() != wxPluralFormsToken::T_NUMBER)
560 return false;
561 wxPluralFormsToken::Number nplurals = token().number();
562 if (!nextToken())
563 return false;
564 if (token().type() != wxPluralFormsToken::T_SEMICOLON)
565 return false;
566 if (!nextToken())
567 return false;
568 if (token().type() != wxPluralFormsToken::T_PLURAL)
569 return false;
570 if (!nextToken())
571 return false;
572 if (token().type() != wxPluralFormsToken::T_ASSIGN)
573 return false;
574 if (!nextToken())
575 return false;
576 wxPluralFormsNode* plural = parsePlural();
577 if (plural == 0)
578 return false;
579 if (token().type() != wxPluralFormsToken::T_SEMICOLON)
580 return false;
581 if (!nextToken())
582 return false;
583 if (token().type() != wxPluralFormsToken::T_EOF)
584 return false;
585 rCalculator.init(nplurals, plural);
586 return true;
587}
588
589wxPluralFormsNode* wxPluralFormsParser::parsePlural()
590{
591 wxPluralFormsNode* p = expression();
592 if (p == NULL)
593 {
594 return NULL;
595 }
596 wxPluralFormsNodePtr n(p);
597 if (token().type() != wxPluralFormsToken::T_SEMICOLON)
598 {
599 return NULL;
600 }
601 return n.release();
602}
603
604const wxPluralFormsToken& wxPluralFormsParser::token() const
605{
606 return m_scanner.token();
607}
608
609bool wxPluralFormsParser::nextToken()
610{
611 if (!m_scanner.nextToken())
612 return false;
613 return true;
614}
615
616wxPluralFormsNode* wxPluralFormsParser::expression()
617{
618 wxPluralFormsNode* p = logicalOrExpression();
619 if (p == NULL)
620 return NULL;
621 wxPluralFormsNodePtr n(p);
622 if (token().type() == wxPluralFormsToken::T_QUESTION)
623 {
624 wxPluralFormsNodePtr qn(new wxPluralFormsNode(token()));
625 if (!nextToken())
626 {
627 return 0;
628 }
629 p = expression();
630 if (p == 0)
631 {
632 return 0;
633 }
634 qn->setNode(1, p);
635 if (token().type() != wxPluralFormsToken::T_COLON)
636 {
637 return 0;
638 }
639 if (!nextToken())
640 {
641 return 0;
642 }
643 p = expression();
644 if (p == 0)
645 {
646 return 0;
647 }
648 qn->setNode(2, p);
649 qn->setNode(0, n.release());
650 return qn.release();
651 }
652 return n.release();
653}
654
655wxPluralFormsNode*wxPluralFormsParser::logicalOrExpression()
656{
657 wxPluralFormsNode* p = logicalAndExpression();
658 if (p == NULL)
659 return NULL;
660 wxPluralFormsNodePtr ln(p);
661 if (token().type() == wxPluralFormsToken::T_LOGICAL_OR)
662 {
663 wxPluralFormsNodePtr un(new wxPluralFormsNode(token()));
664 if (!nextToken())
665 {
666 return 0;
667 }
668 p = logicalOrExpression();
669 if (p == 0)
670 {
671 return 0;
672 }
673 wxPluralFormsNodePtr rn(p); // right
674 if (rn->token().type() == wxPluralFormsToken::T_LOGICAL_OR)
675 {
676 // see logicalAndExpression comment
677 un->setNode(0, ln.release());
678 un->setNode(1, rn->releaseNode(0));
679 rn->setNode(0, un.release());
680 return rn.release();
681 }
a509f830
VZ
682
683
684 un->setNode(0, ln.release());
685 un->setNode(1, rn.release());
686 return un.release();
849a28d0
VS
687 }
688 return ln.release();
689}
690
691wxPluralFormsNode* wxPluralFormsParser::logicalAndExpression()
692{
693 wxPluralFormsNode* p = equalityExpression();
694 if (p == NULL)
695 return NULL;
696 wxPluralFormsNodePtr ln(p); // left
697 if (token().type() == wxPluralFormsToken::T_LOGICAL_AND)
698 {
699 wxPluralFormsNodePtr un(new wxPluralFormsNode(token())); // up
700 if (!nextToken())
701 {
702 return NULL;
703 }
704 p = logicalAndExpression();
705 if (p == 0)
706 {
707 return NULL;
708 }
709 wxPluralFormsNodePtr rn(p); // right
710 if (rn->token().type() == wxPluralFormsToken::T_LOGICAL_AND)
711 {
712// transform 1 && (2 && 3) -> (1 && 2) && 3
713// u r
714// l r -> u 3
715// 2 3 l 2
716 un->setNode(0, ln.release());
717 un->setNode(1, rn->releaseNode(0));
718 rn->setNode(0, un.release());
719 return rn.release();
720 }
a509f830
VZ
721
722 un->setNode(0, ln.release());
723 un->setNode(1, rn.release());
724 return un.release();
849a28d0
VS
725 }
726 return ln.release();
727}
728
729wxPluralFormsNode* wxPluralFormsParser::equalityExpression()
730{
731 wxPluralFormsNode* p = relationalExpression();
732 if (p == NULL)
733 return NULL;
734 wxPluralFormsNodePtr n(p);
735 if (token().type() == wxPluralFormsToken::T_EQUAL
736 || token().type() == wxPluralFormsToken::T_NOT_EQUAL)
737 {
738 wxPluralFormsNodePtr qn(new wxPluralFormsNode(token()));
739 if (!nextToken())
740 {
741 return NULL;
742 }
743 p = relationalExpression();
744 if (p == NULL)
745 {
746 return NULL;
747 }
748 qn->setNode(1, p);
749 qn->setNode(0, n.release());
750 return qn.release();
751 }
752 return n.release();
753}
754
755wxPluralFormsNode* wxPluralFormsParser::relationalExpression()
756{
757 wxPluralFormsNode* p = multiplicativeExpression();
758 if (p == NULL)
759 return NULL;
760 wxPluralFormsNodePtr n(p);
761 if (token().type() == wxPluralFormsToken::T_GREATER
762 || token().type() == wxPluralFormsToken::T_LESS
763 || token().type() == wxPluralFormsToken::T_GREATER_OR_EQUAL
764 || token().type() == wxPluralFormsToken::T_LESS_OR_EQUAL)
765 {
766 wxPluralFormsNodePtr qn(new wxPluralFormsNode(token()));
767 if (!nextToken())
768 {
769 return NULL;
770 }
771 p = multiplicativeExpression();
772 if (p == NULL)
773 {
774 return NULL;
775 }
776 qn->setNode(1, p);
777 qn->setNode(0, n.release());
778 return qn.release();
779 }
780 return n.release();
781}
782
783wxPluralFormsNode* wxPluralFormsParser::multiplicativeExpression()
784{
785 wxPluralFormsNode* p = pmExpression();
786 if (p == NULL)
787 return NULL;
788 wxPluralFormsNodePtr n(p);
789 if (token().type() == wxPluralFormsToken::T_REMINDER)
790 {
791 wxPluralFormsNodePtr qn(new wxPluralFormsNode(token()));
792 if (!nextToken())
793 {
794 return NULL;
795 }
796 p = pmExpression();
797 if (p == NULL)
798 {
799 return NULL;
800 }
801 qn->setNode(1, p);
802 qn->setNode(0, n.release());
803 return qn.release();
804 }
805 return n.release();
806}
807
808wxPluralFormsNode* wxPluralFormsParser::pmExpression()
809{
810 wxPluralFormsNodePtr n;
811 if (token().type() == wxPluralFormsToken::T_N
812 || token().type() == wxPluralFormsToken::T_NUMBER)
813 {
814 n.reset(new wxPluralFormsNode(token()));
815 if (!nextToken())
816 {
817 return NULL;
818 }
819 }
820 else if (token().type() == wxPluralFormsToken::T_LEFT_BRACKET) {
821 if (!nextToken())
822 {
823 return NULL;
824 }
825 wxPluralFormsNode* p = expression();
826 if (p == NULL)
827 {
828 return NULL;
829 }
830 n.reset(p);
831 if (token().type() != wxPluralFormsToken::T_RIGHT_BRACKET)
832 {
833 return NULL;
834 }
835 if (!nextToken())
836 {
837 return NULL;
838 }
839 }
840 else
841 {
842 return NULL;
843 }
844 return n.release();
845}
846
847wxPluralFormsCalculator* wxPluralFormsCalculator::make(const char* s)
848{
849 wxPluralFormsCalculatorPtr calculator(new wxPluralFormsCalculator);
850 if (s != NULL)
851 {
852 wxPluralFormsScanner scanner(s);
853 wxPluralFormsParser p(scanner);
854 if (!p.parse(*calculator))
855 {
856 return NULL;
857 }
858 }
859 return calculator.release();
860}
861
862
863
41524ffc 864
563d535e
VS
865// ----------------------------------------------------------------------------
866// wxMsgCatalogFile corresponds to one disk-file message catalog.
867//
868// This is a "low-level" class and is used only by wxMsgCatalog
869// ----------------------------------------------------------------------------
870
3f5c62f9 871WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxString, wxMessagesHash);
563d535e
VS
872
873class wxMsgCatalogFile
874{
875public:
876 // ctor & dtor
877 wxMsgCatalogFile();
878 ~wxMsgCatalogFile();
879
880 // load the catalog from disk (szDirPrefix corresponds to language)
849a28d0
VS
881 bool Load(const wxChar *szDirPrefix, const wxChar *szName,
882 wxPluralFormsCalculatorPtr& rPluralFormsCalculator);
563d535e
VS
883
884 // fills the hash with string-translation pairs
77c514d1
VZ
885 void FillHash(wxMessagesHash& hash,
886 const wxString& msgIdCharset,
d721baa9 887 bool convertEncoding) const;
563d535e 888
77c514d1
VZ
889 // return the charset of the strings in this catalog or empty string if
890 // none/unknown
891 wxString GetCharset() const { return m_charset; }
892
563d535e
VS
893private:
894 // this implementation is binary compatible with GNU gettext() version 0.10
895
896 // an entry in the string table
897 struct wxMsgTableEntry
898 {
899 size_t32 nLen; // length of the string
900 size_t32 ofsString; // pointer to the string
901 };
902
903 // header of a .mo file
904 struct wxMsgCatalogHeader
905 {
906 size_t32 magic, // offset +00: magic id
907 revision, // +04: revision
908 numStrings; // +08: number of strings in the file
909 size_t32 ofsOrigTable, // +0C: start of original string table
910 ofsTransTable; // +10: start of translated string table
911 size_t32 nHashSize, // +14: hash table size
912 ofsHashTable; // +18: offset of hash table start
913 };
914
915 // all data is stored here, NULL if no data loaded
916 size_t8 *m_pData;
917
869c7549
VZ
918 // amount of memory pointed to by m_pData.
919 size_t32 m_nSize;
920
563d535e
VS
921 // data description
922 size_t32 m_numStrings; // number of strings in this domain
923 wxMsgTableEntry *m_pOrigTable, // pointer to original strings
924 *m_pTransTable; // translated
925
77c514d1
VZ
926 wxString m_charset; // from the message catalog header
927
b7b97e77 928
869c7549
VZ
929 // swap the 2 halves of 32 bit integer if needed
930 size_t32 Swap(size_t32 ui) const
931 {
932 return m_bSwapped ? (ui << 24) | ((ui & 0xff00) << 8) |
933 ((ui >> 8) & 0xff00) | (ui >> 24)
934 : ui;
935 }
9e7ed2b0 936
869c7549
VZ
937 const char *StringAtOfs(wxMsgTableEntry *pTable, size_t32 n) const
938 {
939 const wxMsgTableEntry * const ent = pTable + n;
563d535e 940
869c7549
VZ
941 // this check could fail for a corrupt message catalog
942 size_t32 ofsString = Swap(ent->ofsString);
943 if ( ofsString + Swap(ent->nLen) > m_nSize)
849a28d0 944 {
869c7549 945 return NULL;
849a28d0 946 }
563d535e 947
869c7549 948 return (const char *)(m_pData + ofsString);
b7b97e77 949 }
869c7549
VZ
950
951 bool m_bSwapped; // wrong endianness?
22f3361e
VZ
952
953 DECLARE_NO_COPY_CLASS(wxMsgCatalogFile)
563d535e
VS
954};
955
956
c801d85f 957// ----------------------------------------------------------------------------
563d535e 958// wxMsgCatalog corresponds to one loaded message catalog.
c801d85f
KB
959//
960// This is a "low-level" class and is used only by wxLocale (that's why
961// it's designed to be stored in a linked list)
962// ----------------------------------------------------------------------------
963
964class wxMsgCatalog
965{
966public:
77c514d1
VZ
967 wxMsgCatalog() { m_conv = NULL; }
968 ~wxMsgCatalog();
969
563d535e 970 // load the catalog from disk (szDirPrefix corresponds to language)
d721baa9
VS
971 bool Load(const wxChar *szDirPrefix, const wxChar *szName,
972 const wxChar *msgIdCharset = NULL, bool bConvertEncoding = false);
c801d85f 973
563d535e
VS
974 // get name of the catalog
975 wxString GetName() const { return m_name; }
c801d85f 976
563d535e 977 // get the translated string: returns NULL if not found
849a28d0 978 const wxChar *GetString(const wxChar *sz, size_t n = size_t(-1)) const;
c801d85f 979
563d535e
VS
980 // public variable pointing to the next element in a linked list (or NULL)
981 wxMsgCatalog *m_pNext;
7af89395 982
c801d85f 983private:
563d535e
VS
984 wxMessagesHash m_messages; // all messages in the catalog
985 wxString m_name; // name of the domain
77c514d1
VZ
986
987 // the conversion corresponding to this catalog charset if we installed it
988 // as the global one
989 wxCSConv *m_conv;
990
849a28d0 991 wxPluralFormsCalculatorPtr m_pluralFormsCalculator;
c801d85f
KB
992};
993
fd323a5e
VZ
994// ----------------------------------------------------------------------------
995// global variables
996// ----------------------------------------------------------------------------
997
998// the list of the directories to search for message catalog files
f830b2b1 999static wxArrayString gs_searchPrefixes;
fd323a5e 1000
c801d85f
KB
1001// ============================================================================
1002// implementation
1003// ============================================================================
1004
1005// ----------------------------------------------------------------------------
563d535e 1006// wxMsgCatalogFile class
c801d85f
KB
1007// ----------------------------------------------------------------------------
1008
563d535e 1009wxMsgCatalogFile::wxMsgCatalogFile()
7af89395 1010{
869c7549
VZ
1011 m_pData = NULL;
1012 m_nSize = 0;
c801d85f
KB
1013}
1014
563d535e 1015wxMsgCatalogFile::~wxMsgCatalogFile()
7af89395 1016{
77c514d1 1017 delete [] m_pData;
c801d85f
KB
1018}
1019
b5297239
VS
1020// return the directories to search for message catalogs under the given
1021// prefix, separated by wxPATH_SEP
f830b2b1 1022static
b5297239 1023wxString GetMsgCatalogSubdirs(const wxChar *prefix, const wxChar *lang)
fd323a5e
VZ
1024{
1025 wxString searchPath;
f830b2b1 1026 searchPath << prefix << wxFILE_SEP_PATH << lang;
fd323a5e 1027
43e995b6
VS
1028 // Under Unix, the message catalogs are supposed to go into LC_MESSAGES
1029 // subdirectory so look there too. Note that we do it on all platforms
1030 // and not just Unix, because it doesn't cost much to look into one more
1031 // directory and doing it this way has two important benefits:
1032 // a) we don't break compatibility with wx-2.6 and older by stopping to
1033 // look in a directory where the catalogs used to be and thus silently
1034 // breaking apps after they are recompiled against the latest wx
1035 // b) it makes it possible to package app's support files in the same
1036 // way on all target platforms
f0a6989d
VZ
1037 const wxString searchPathOrig(searchPath);
1038 searchPath << wxFILE_SEP_PATH << wxT("LC_MESSAGES")
1039 << wxPATH_SEP << searchPathOrig;
fd323a5e
VZ
1040
1041 return searchPath;
1042}
1043
1044// construct the search path for the given language
e36e6f95 1045static wxString GetFullSearchPath(const wxChar *lang)
fd323a5e 1046{
fd323a5e 1047 // first take the entries explicitly added by the program
f830b2b1
VZ
1048 wxArrayString paths;
1049 paths.reserve(gs_searchPrefixes.size() + 1);
1050 size_t n,
1051 count = gs_searchPrefixes.size();
1052 for ( n = 0; n < count; n++ )
fd323a5e 1053 {
b5297239 1054 paths.Add(GetMsgCatalogSubdirs(gs_searchPrefixes[n], lang));
fd323a5e
VZ
1055 }
1056
30984dea 1057
f830b2b1
VZ
1058#if wxUSE_STDPATHS
1059 // then look in the standard location
1060 const wxString stdp = wxStandardPaths::Get().
1061 GetLocalizedResourcesDir(lang, wxStandardPaths::ResourceCat_Messages);
1062
1063 if ( paths.Index(stdp) == wxNOT_FOUND )
1064 paths.Add(stdp);
1065#endif // wxUSE_STDPATHS
1066
1067 // last look in default locations
1068#ifdef __UNIX__
5f170f33
VZ
1069 // LC_PATH is a standard env var containing the search path for the .mo
1070 // files
f6bcfd97 1071 const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH"));
f830b2b1
VZ
1072 if ( pszLcPath )
1073 {
b5297239 1074 const wxString lcp = GetMsgCatalogSubdirs(pszLcPath, lang);
f830b2b1
VZ
1075 if ( paths.Index(lcp) == wxNOT_FOUND )
1076 paths.Add(lcp);
1077 }
5f170f33 1078
f830b2b1
VZ
1079 // also add the one from where wxWin was installed:
1080 wxString wxp = wxGetInstallPrefix();
1081 if ( !wxp.empty() )
1082 {
b5297239 1083 wxp = GetMsgCatalogSubdirs(wxp + _T("/share/locale"), lang);
f830b2b1
VZ
1084 if ( paths.Index(wxp) == wxNOT_FOUND )
1085 paths.Add(wxp);
1086 }
c3ccca4a
VS
1087#endif // __UNIX__
1088
f830b2b1
VZ
1089
1090 // finally construct the full search path
1091 wxString searchPath;
1092 searchPath.reserve(500);
1093 count = paths.size();
1094 for ( n = 0; n < count; n++ )
1095 {
1096 searchPath += paths[n];
1097 if ( n != count - 1 )
1098 searchPath += wxPATH_SEP;
1099 }
45e97ca0 1100
fd323a5e
VZ
1101 return searchPath;
1102}
1103
c801d85f 1104// open disk file and read in it's contents
58ad1bab 1105bool wxMsgCatalogFile::Load(const wxChar *szDirPrefix, const wxChar *szName,
849a28d0 1106 wxPluralFormsCalculatorPtr& rPluralFormsCalculator)
c801d85f 1107{
ca6a9a14
VZ
1108 wxString searchPath;
1109
1110#if wxUSE_FONTMAP
1111 // first look for the catalog for this language and the current locale:
1112 // notice that we don't use the system name for the locale as this would
1113 // force us to install catalogs in different locations depending on the
1114 // system but always use the canonical name
1115 wxFontEncoding encSys = wxLocale::GetSystemEncoding();
1116 if ( encSys != wxFONTENCODING_SYSTEM )
1117 {
1118 wxString fullname(szDirPrefix);
1119 fullname << _T('.') << wxFontMapperBase::GetEncodingName(encSys);
1120 searchPath << GetFullSearchPath(fullname) << wxPATH_SEP;
1121 }
1122#endif // wxUSE_FONTMAP
1123
2ce0a6e2 1124
ca6a9a14 1125 searchPath += GetFullSearchPath(szDirPrefix);
223d09f6 1126 const wxChar *sublocale = wxStrchr(szDirPrefix, wxT('_'));
fd323a5e
VZ
1127 if ( sublocale )
1128 {
1129 // also add just base locale name: for things like "fr_BE" (belgium
1130 // french) we should use "fr" if no belgium specific message catalogs
1131 // exist
f830b2b1
VZ
1132 searchPath << wxPATH_SEP
1133 << GetFullSearchPath(wxString(szDirPrefix).
1134 Left((size_t)(sublocale - szDirPrefix)));
fd323a5e 1135 }
7af89395 1136
c801d85f
KB
1137 // don't give translation errors here because the wxstd catalog might
1138 // not yet be loaded (and it's normal)
1139 //
1140 // (we're using an object because we have several return paths)
ed58dbea 1141
c801d85f 1142 NoTransErr noTransErr;
5f170f33 1143 wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
58ad1bab 1144 szName, searchPath.c_str());
ca6a9a14
VZ
1145 wxLogTrace(TRACE_I18N, _T("Looking for \"%s.mo\" in \"%s\""),
1146 szName, searchPath.c_str());
c801d85f 1147
58ad1bab 1148 wxFileName fn(szName);
de085fcc 1149 fn.SetExt(_T("mo"));
c801d85f 1150 wxString strFullName;
58ad1bab
VZ
1151 if ( !wxFindFileInPath(&strFullName, searchPath, fn.GetFullPath()) ) {
1152 wxLogVerbose(_("catalog file for domain '%s' not found."), szName);
ca6a9a14 1153 wxLogTrace(TRACE_I18N, _T("Catalog \"%s.mo\" not found"), szName);
7beb59f3 1154 return false;
c801d85f
KB
1155 }
1156
1157 // open file
58ad1bab 1158 wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str());
ca6a9a14 1159 wxLogTrace(TRACE_I18N, _T("Using catalog \"%s\"."), strFullName.c_str());
7af89395 1160
c801d85f
KB
1161 wxFile fileMsg(strFullName);
1162 if ( !fileMsg.IsOpened() )
7beb59f3 1163 return false;
c801d85f 1164
170b04ba 1165 // get the file size (assume it is less than 4Gb...)
17a1ebd1
VZ
1166 wxFileOffset lenFile = fileMsg.Length();
1167 if ( lenFile == wxInvalidOffset )
7beb59f3 1168 return false;
c801d85f 1169
17a1ebd1 1170 size_t nSize = wx_truncate_cast(size_t, lenFile);
4a10ea8b 1171 wxASSERT_MSG( nSize == lenFile + size_t(0), _T("message catalog bigger than 4GB?") );
17a1ebd1 1172
c801d85f 1173 // read the whole file in memory
c86f1403 1174 m_pData = new size_t8[nSize];
c88c6e94 1175 if ( fileMsg.Read(m_pData, nSize) != lenFile ) {
a3622daa 1176 wxDELETEA(m_pData);
7beb59f3 1177 return false;
c801d85f 1178 }
7af89395 1179
c801d85f 1180 // examine header
30984dea 1181 bool bValid = nSize + (size_t)0 > sizeof(wxMsgCatalogHeader);
7af89395 1182
fd3f686c 1183 wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
c801d85f 1184 if ( bValid ) {
c801d85f
KB
1185 // we'll have to swap all the integers if it's true
1186 m_bSwapped = pHeader->magic == MSGCATALOG_MAGIC_SW;
1187
1188 // check the magic number
1189 bValid = m_bSwapped || pHeader->magic == MSGCATALOG_MAGIC;
1190 }
7af89395 1191
c801d85f
KB
1192 if ( !bValid ) {
1193 // it's either too short or has incorrect magic number
1a5a8367 1194 wxLogWarning(_("'%s' is not a valid message catalog."), strFullName.c_str());
7af89395 1195
a3622daa 1196 wxDELETEA(m_pData);
7beb59f3 1197 return false;
c801d85f 1198 }
7af89395 1199
c801d85f
KB
1200 // initialize
1201 m_numStrings = Swap(pHeader->numStrings);
7af89395 1202 m_pOrigTable = (wxMsgTableEntry *)(m_pData +
1678ad78 1203 Swap(pHeader->ofsOrigTable));
7af89395 1204 m_pTransTable = (wxMsgTableEntry *)(m_pData +
1678ad78 1205 Swap(pHeader->ofsTransTable));
2e0ef2ae 1206 m_nSize = (size_t32)nSize;
b7b97e77 1207
849a28d0
VS
1208 // now parse catalog's header and try to extract catalog charset and
1209 // plural forms formula from it:
1210
1211 const char* headerData = StringAtOfs(m_pOrigTable, 0);
1212 if (headerData && headerData[0] == 0)
1213 {
1214 // Extract the charset:
1215 wxString header = wxString::FromAscii(StringAtOfs(m_pTransTable, 0));
1216 int begin = header.Find(wxT("Content-Type: text/plain; charset="));
1217 if (begin != wxNOT_FOUND)
1218 {
1219 begin += 34; //strlen("Content-Type: text/plain; charset=")
1220 size_t end = header.find('\n', begin);
1221 if (end != size_t(-1))
1222 {
1223 m_charset.assign(header, begin, end - begin);
1224 if (m_charset == wxT("CHARSET"))
1225 {
1226 // "CHARSET" is not valid charset, but lazy translator
1227 m_charset.Clear();
1228 }
1229 }
1230 }
1231 // else: incorrectly filled Content-Type header
b7b97e77 1232
849a28d0
VS
1233 // Extract plural forms:
1234 begin = header.Find(wxT("Plural-Forms:"));
1235 if (begin != wxNOT_FOUND)
1236 {
1237 begin += 13;
1238 size_t end = header.find('\n', begin);
1239 if (end != size_t(-1))
1240 {
1241 wxString pfs(header, begin, end - begin);
1242 wxPluralFormsCalculator* pCalculator = wxPluralFormsCalculator
1243 ::make(pfs.ToAscii());
1244 if (pCalculator != 0)
1245 {
1246 rPluralFormsCalculator.reset(pCalculator);
1247 }
1248 else
1249 {
ca6a9a14 1250 wxLogVerbose(_("Cannot parse Plural-Forms:'%s'"), pfs.c_str());
849a28d0
VS
1251 }
1252 }
1253 }
1254 if (rPluralFormsCalculator.get() == NULL)
1255 {
1256 rPluralFormsCalculator.reset(wxPluralFormsCalculator::make());
1257 }
1258 }
c801d85f 1259
c801d85f 1260 // everything is fine
849a28d0 1261 return true;
c801d85f
KB
1262}
1263
d721baa9
VS
1264void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
1265 const wxString& msgIdCharset,
1266 bool convertEncoding) const
c801d85f 1267{
7a4b1e66
VZ
1268#if wxUSE_UNICODE
1269 // this parameter doesn't make sense, we always must convert encoding in
1270 // Unicode build
1271 convertEncoding = true;
1272#elif wxUSE_FONTMAP
7cb06872
VZ
1273 if ( convertEncoding )
1274 {
77c514d1 1275 // determine if we need any conversion at all
7cb06872
VZ
1276 wxFontEncoding encCat = wxFontMapperBase::GetEncodingFromName(m_charset);
1277 if ( encCat == wxLocale::GetSystemEncoding() )
1278 {
1279 // no need to convert
1280 convertEncoding = false;
1281 }
1282 }
7a4b1e66 1283#endif // wxUSE_UNICODE/wxUSE_FONTMAP
7cb06872 1284
563d535e 1285#if wxUSE_WCHAR_T
35d10652
VZ
1286 // conversion to use to convert catalog strings to the GUI encoding
1287 wxMBConv *inputConv,
7a4b1e66
VZ
1288 *inputConvPtr = NULL; // same as inputConv but safely deleteable
1289 if ( convertEncoding && !m_charset.empty() )
35d10652 1290 {
7a4b1e66
VZ
1291 inputConvPtr =
1292 inputConv = new wxCSConv(m_charset);
35d10652 1293 }
7a4b1e66 1294 else // no need or not possible to convert the encoding
35d10652 1295 {
f15fa3a9 1296#if wxUSE_UNICODE
7a4b1e66
VZ
1297 // we must somehow convert the narrow strings in the message catalog to
1298 // wide strings, so use the default conversion if we have no charset
f15fa3a9
VZ
1299 inputConv = wxConvCurrent;
1300#else // !wxUSE_UNICODE
35d10652 1301 inputConv = NULL;
f15fa3a9 1302#endif // wxUSE_UNICODE/!wxUSE_UNICODE
35d10652 1303 }
d721baa9 1304
35d10652
VZ
1305 // conversion to apply to msgid strings before looking them up: we only
1306 // need it if the msgids are neither in 7 bit ASCII nor in the same
1307 // encoding as the catalog
1308 wxCSConv *sourceConv = msgIdCharset.empty() || (msgIdCharset == m_charset)
1309 ? NULL
1310 : new wxCSConv(msgIdCharset);
d721baa9 1311
849a28d0 1312#elif wxUSE_FONTMAP
d721baa9
VS
1313 wxASSERT_MSG( msgIdCharset == NULL,
1314 _T("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
7beb59f3 1315
849a28d0 1316 wxEncodingConverter converter;
563d535e
VS
1317 if ( convertEncoding )
1318 {
baf736e1 1319 wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
267e11c5 1320 wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(m_charset, false);
563d535e
VS
1321 if ( enc == wxFONTENCODING_SYSTEM )
1322 {
7beb59f3 1323 convertEncoding = false; // unknown encoding
563d535e
VS
1324 }
1325 else
1326 {
baf736e1 1327 targetEnc = wxLocale::GetSystemEncoding();
563d535e
VS
1328 if (targetEnc == wxFONTENCODING_SYSTEM)
1329 {
1330 wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc);
1331 if (a[0] == enc)
1332 // no conversion needed, locale uses native encoding
7beb59f3 1333 convertEncoding = false;
563d535e
VS
1334 if (a.GetCount() == 0)
1335 // we don't know common equiv. under this platform
7beb59f3 1336 convertEncoding = false;
563d535e
VS
1337 targetEnc = a[0];
1338 }
1339 }
1340
1341 if ( convertEncoding )
1342 {
563d535e 1343 converter.Init(enc, targetEnc);
563d535e
VS
1344 }
1345 }
563d535e 1346#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
0c93d67c 1347 (void)convertEncoding; // get rid of warnings about unused parameter
bc385ba9 1348
4a10ea8b 1349 for (size_t32 i = 0; i < m_numStrings; i++)
563d535e 1350 {
849a28d0 1351 const char *data = StringAtOfs(m_pOrigTable, i);
7a4b1e66
VZ
1352
1353 wxString msgid;
d721baa9 1354#if wxUSE_UNICODE
7a4b1e66 1355 msgid = wxString(data, *inputConv);
35d10652 1356#else // ASCII
f15fa3a9
VZ
1357 #if wxUSE_WCHAR_T
1358 if ( inputConv && sourceConv )
1359 msgid = wxString(inputConv->cMB2WC(data), *sourceConv);
1360 else
1361 #endif
7a4b1e66 1362 msgid = data;
d721baa9 1363#endif // wxUSE_UNICODE
563d535e 1364
849a28d0
VS
1365 data = StringAtOfs(m_pTransTable, i);
1366 size_t length = Swap(m_pTransTable[i].nLen);
1367 size_t offset = 0;
1368 size_t index = 0;
1369 while (offset < length)
1370 {
7a4b1e66
VZ
1371 const char * const str = data + offset;
1372
849a28d0 1373 wxString msgstr;
7a4b1e66
VZ
1374#if wxUSE_UNICODE
1375 msgstr = wxString(str, *inputConv);
1376#elif wxUSE_WCHAR_T
35d10652 1377 if ( inputConv )
7a4b1e66 1378 msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI);
849a28d0 1379 else
7a4b1e66 1380 msgstr = str;
849a28d0
VS
1381#else // !wxUSE_WCHAR_T
1382 #if wxUSE_FONTMAP
1383 if ( convertEncoding )
7a4b1e66 1384 msgstr = wxString(converter.Convert(str));
849a28d0
VS
1385 else
1386 #endif
7a4b1e66 1387 msgstr = str;
849a28d0 1388#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
9e7ed2b0 1389
849a28d0
VS
1390 if ( !msgstr.empty() )
1391 {
1392 hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr;
1393 }
7a4b1e66
VZ
1394
1395 // skip this string
1396 offset += strlen(str) + 1;
849a28d0
VS
1397 ++index;
1398 }
41780009 1399 }
9e7ed2b0 1400
849a28d0 1401#if wxUSE_WCHAR_T
d721baa9 1402 delete sourceConv;
7a4b1e66
VZ
1403 delete inputConvPtr;
1404#endif // wxUSE_WCHAR_T
563d535e 1405}
bc385ba9 1406
849a28d0 1407
563d535e
VS
1408// ----------------------------------------------------------------------------
1409// wxMsgCatalog class
1410// ----------------------------------------------------------------------------
bc385ba9 1411
77c514d1
VZ
1412wxMsgCatalog::~wxMsgCatalog()
1413{
1414 if ( m_conv )
1415 {
1416 if ( wxConvUI == m_conv )
1417 {
1418 // we only change wxConvUI if it points to wxConvLocal so we reset
1419 // it back to it too
1420 wxConvUI = &wxConvLocal;
1421 }
1422
1423 delete m_conv;
1424 }
1425}
1426
9e7ed2b0 1427bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName,
d721baa9 1428 const wxChar *msgIdCharset, bool bConvertEncoding)
563d535e
VS
1429{
1430 wxMsgCatalogFile file;
9e7ed2b0 1431
563d535e 1432 m_name = szName;
9e7ed2b0 1433
77c514d1
VZ
1434 if ( !file.Load(szDirPrefix, szName, m_pluralFormsCalculator) )
1435 return false;
1436
1437 file.FillHash(m_messages, msgIdCharset, bConvertEncoding);
1438
1439 // we should use a conversion compatible with the message catalog encoding
1440 // in the GUI if we don't convert the strings to the current conversion but
1441 // as the encoding is global, only change it once, otherwise we could get
1442 // into trouble if we use several message catalogs with different encodings
1443 //
1444 // this is, of course, a hack but it at least allows the program to use
1445 // message catalogs in any encodings without asking the user to change his
1446 // locale
1447 if ( !bConvertEncoding &&
1448 !file.GetCharset().empty() &&
1449 wxConvUI == &wxConvLocal )
563d535e 1450 {
77c514d1
VZ
1451 wxConvUI =
1452 m_conv = new wxCSConv(file.GetCharset());
563d535e 1453 }
821d0fef 1454
77c514d1 1455 return true;
afc94fa6
VS
1456}
1457
849a28d0 1458const wxChar *wxMsgCatalog::GetString(const wxChar *sz, size_t n) const
563d535e 1459{
849a28d0
VS
1460 int index = 0;
1461 if (n != size_t(-1))
1462 {
1463 index = m_pluralFormsCalculator->evaluate(n);
1464 }
1465 wxMessagesHash::const_iterator i;
1466 if (index != 0)
1467 {
1468 i = m_messages.find(wxString(sz) + wxChar(index)); // plural
1469 }
1470 else
1471 {
1472 i = m_messages.find(sz);
1473 }
1474
563d535e
VS
1475 if ( i != m_messages.end() )
1476 {
1477 return i->second.c_str();
1478 }
1479 else
1480 return NULL;
1481}
afc94fa6 1482
c801d85f
KB
1483// ----------------------------------------------------------------------------
1484// wxLocale
1485// ----------------------------------------------------------------------------
1486
d3f3e35f
VS
1487#include "wx/arrimpl.cpp"
1488WX_DECLARE_EXPORTED_OBJARRAY(wxLanguageInfo, wxLanguageInfoArray);
4115960d 1489WX_DEFINE_OBJARRAY(wxLanguageInfoArray)
d3f3e35f 1490
41780009
VS
1491wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL;
1492
1493/*static*/ void wxLocale::CreateLanguagesDB()
1494{
1495 if (ms_languagesDB == NULL)
1496 {
1497 ms_languagesDB = new wxLanguageInfoArray;
1498 InitLanguagesDB();
1499 }
1500}
1501
1502/*static*/ void wxLocale::DestroyLanguagesDB()
1503{
1504 delete ms_languagesDB;
1505 ms_languagesDB = NULL;
1506}
1507
1508
ea8f6fc7 1509void wxLocale::DoCommonInit()
c801d85f 1510{
23fcecf7 1511 m_pszOldLocale = NULL;
eb48778d
VZ
1512
1513 m_pOldLocale = wxSetLocale(this);
1514
23fcecf7 1515 m_pMsgCat = NULL;
d3f3e35f 1516 m_language = wxLANGUAGE_UNKNOWN;
3202d00d 1517 m_initialized = false;
23fcecf7
VZ
1518}
1519
1520// NB: this function has (desired) side effect of changing current locale
e36e6f95
OK
1521bool wxLocale::Init(const wxChar *szName,
1522 const wxChar *szShort,
1523 const wxChar *szLocale,
afc94fa6
VS
1524 bool bLoadDefault,
1525 bool bConvertEncoding)
23fcecf7 1526{
3202d00d
VS
1527 wxASSERT_MSG( !m_initialized,
1528 _T("you can't call wxLocale::Init more than once") );
b7b97e77 1529
3202d00d 1530 m_initialized = true;
23fcecf7
VZ
1531 m_strLocale = szName;
1532 m_strShort = szShort;
afc94fa6 1533 m_bConvertEncoding = bConvertEncoding;
d3f3e35f 1534 m_language = wxLANGUAGE_UNKNOWN;
23fcecf7 1535
c801d85f
KB
1536 // change current locale (default: same as long name)
1537 if ( szLocale == NULL )
9dea50fc
VZ
1538 {
1539 // the argument to setlocale()
1540 szLocale = szShort;
52558258 1541
7beb59f3 1542 wxCHECK_MSG( szLocale, false, _T("no locale to set in wxLocale::Init()") );
9dea50fc 1543 }
10545ca4 1544
1c193821
JS
1545#ifdef __WXWINCE__
1546 // FIXME: I'm guessing here
1547 wxChar localeName[256];
1548 int ret = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, localeName,
1549 256);
1550 if (ret != 0)
1551 {
b7b97e77 1552 m_pszOldLocale = wxStrdup(localeName);
1c193821
JS
1553 }
1554 else
1555 m_pszOldLocale = NULL;
1556
1557 // TODO: how to find languageId
1558 // SetLocaleInfo(languageId, SORT_DEFAULT, localeName);
1559#else
c76b6474
VS
1560 wxMB2WXbuf oldLocale = wxSetlocale(LC_ALL, szLocale);
1561 if ( oldLocale )
1562 m_pszOldLocale = wxStrdup(oldLocale);
1563 else
1564 m_pszOldLocale = NULL;
1c193821
JS
1565#endif
1566
c801d85f 1567 if ( m_pszOldLocale == NULL )
1a5a8367 1568 wxLogError(_("locale '%s' can not be set."), szLocale);
c801d85f
KB
1569
1570 // the short name will be used to look for catalog files as well,
1571 // so we need something here
525d8583 1572 if ( m_strShort.empty() ) {
fd323a5e
VZ
1573 // FIXME I don't know how these 2 letter abbreviations are formed,
1574 // this wild guess is surely wrong
c7c06291 1575 if ( szLocale && szLocale[0] )
70426fba
VZ
1576 {
1577 m_strShort += (wxChar)wxTolower(szLocale[0]);
1578 if ( szLocale[1] )
1579 m_strShort += (wxChar)wxTolower(szLocale[1]);
1580 }
c801d85f 1581 }
7af89395 1582
77ffb593 1583 // load the default catalog with wxWidgets standard messages
c801d85f 1584 m_pMsgCat = NULL;
7beb59f3 1585 bool bOk = true;
c801d85f 1586 if ( bLoadDefault )
4d931bcc 1587 {
223d09f6 1588 bOk = AddCatalog(wxT("wxstd"));
23fcecf7 1589
4d931bcc
MW
1590 // there may be a catalog with toolkit specific overrides, it is not
1591 // an error if this does not exist
8bb6b2c0 1592 if ( bOk )
4d931bcc 1593 {
8bb6b2c0
VZ
1594 wxString port(wxPlatformInfo().GetPortIdName());
1595 if ( !port.empty() )
1596 {
1597 AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
1598 }
4d931bcc
MW
1599 }
1600 }
1601
23fcecf7 1602 return bOk;
c801d85f
KB
1603}
1604
41524ffc 1605
1cc549e5 1606#if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WXMAC__)
41524ffc
VS
1607static wxWCharBuffer wxSetlocaleTryUTF(int c, const wxChar *lc)
1608{
1609 wxMB2WXbuf l = wxSetlocale(c, lc);
2d34a303 1610 if ( !l && lc && lc[0] != 0 )
41524ffc 1611 {
7beb59f3 1612 wxString buf(lc);
2d34a303 1613 wxString buf2;
7beb59f3
WS
1614 buf2 = buf + wxT(".UTF-8");
1615 l = wxSetlocale(c, buf2.c_str());
2d34a303
VS
1616 if ( !l )
1617 {
1618 buf2 = buf + wxT(".utf-8");
7beb59f3 1619 l = wxSetlocale(c, buf2.c_str());
2d34a303
VS
1620 }
1621 if ( !l )
1622 {
1623 buf2 = buf + wxT(".UTF8");
7beb59f3 1624 l = wxSetlocale(c, buf2.c_str());
2d34a303
VS
1625 }
1626 if ( !l )
1627 {
1628 buf2 = buf + wxT(".utf8");
7beb59f3 1629 l = wxSetlocale(c, buf2.c_str());
2d34a303 1630 }
41524ffc
VS
1631 }
1632 return l;
1633}
1634#else
1635#define wxSetlocaleTryUTF(c, lc) wxSetlocale(c, lc)
1636#endif
1637
d3f3e35f
VS
1638bool wxLocale::Init(int language, int flags)
1639{
d3f3e35f 1640 int lang = language;
ec37df57
VZ
1641 if (lang == wxLANGUAGE_DEFAULT)
1642 {
1643 // auto detect the language
1644 lang = GetSystemLanguage();
1645 }
1646
1647 // We failed to detect system language, so we will use English:
1648 if (lang == wxLANGUAGE_UNKNOWN)
1649 {
7beb59f3 1650 return false;
ec37df57
VZ
1651 }
1652
14f8fa9d 1653 const wxLanguageInfo *info = GetLanguageInfo(lang);
d3f3e35f 1654
d3f3e35f
VS
1655 // Unknown language:
1656 if (info == NULL)
1657 {
1658 wxLogError(wxT("Unknown language %i."), lang);
7beb59f3 1659 return false;
d3f3e35f
VS
1660 }
1661
1662 wxString name = info->Description;
1663 wxString canonical = info->CanonicalName;
1664 wxString locale;
ec37df57 1665
d3f3e35f 1666 // Set the locale:
55034339
WS
1667#if defined(__OS2__)
1668 wxMB2WXbuf retloc = wxSetlocale(LC_ALL , wxEmptyString);
1669#elif defined(__UNIX__) && !defined(__WXMAC__)
d368dbea 1670 if (language != wxLANGUAGE_DEFAULT)
ec37df57 1671 locale = info->CanonicalName;
d3f3e35f 1672
41524ffc 1673 wxMB2WXbuf retloc = wxSetlocaleTryUTF(LC_ALL, locale);
d3f3e35f 1674
d368dbea 1675 const wxString langOnly = locale.Left(2);
2b5f62a0 1676 if ( !retloc )
d3f3e35f
VS
1677 {
1678 // Some C libraries don't like xx_YY form and require xx only
d368dbea 1679 retloc = wxSetlocaleTryUTF(LC_ALL, langOnly);
d3f3e35f 1680 }
d368dbea
VZ
1681
1682#if wxUSE_FONTMAP
1683 // some systems (e.g. FreeBSD and HP-UX) don't have xx_YY aliases but
1684 // require the full xx_YY.encoding form, so try using UTF-8 because this is
1685 // the only thing we can do generically
1686 //
1687 // TODO: add encodings applicable to each language to the lang DB and try
1688 // them all in turn here
2b5f62a0 1689 if ( !retloc )
d3f3e35f 1690 {
d368dbea
VZ
1691 const wxChar **names =
1692 wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8);
1693 while ( *names )
1694 {
1695 retloc = wxSetlocale(LC_ALL, locale + _T('.') + *names++);
1696 if ( retloc )
1697 break;
1698 }
d3f3e35f 1699 }
d368dbea
VZ
1700#endif // wxUSE_FONTMAP
1701
2b5f62a0 1702 if ( !retloc )
d3f3e35f 1703 {
d368dbea
VZ
1704 // Some C libraries (namely glibc) still use old ISO 639,
1705 // so will translate the abbrev for them
1706 wxString localeAlt;
1707 if ( langOnly == wxT("he") )
1708 localeAlt = wxT("iw") + locale.Mid(3);
1709 else if ( langOnly == wxT("id") )
1710 localeAlt = wxT("in") + locale.Mid(3);
1711 else if ( langOnly == wxT("yi") )
1712 localeAlt = wxT("ji") + locale.Mid(3);
1713 else if ( langOnly == wxT("nb") )
1714 localeAlt = wxT("no_NO");
1715 else if ( langOnly == wxT("nn") )
1716 localeAlt = wxT("no_NY");
1717
1718 if ( !localeAlt.empty() )
1719 {
1720 retloc = wxSetlocaleTryUTF(LC_ALL, localeAlt);
1721 if ( !retloc )
1722 retloc = wxSetlocaleTryUTF(LC_ALL, locale.Left(2));
1723 }
d3f3e35f 1724 }
d368dbea 1725
2b5f62a0 1726 if ( !retloc )
d3f3e35f
VS
1727 {
1728 wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
7beb59f3 1729 return false;
d3f3e35f 1730 }
d368dbea
VZ
1731
1732#ifdef __AIX__
1733 // at least in AIX 5.2 libc is buggy and the string returned from setlocale(LC_ALL)
1734 // can't be passed back to it because it returns 6 strings (one for each locale
1735 // category), i.e. for C locale we get back "C C C C C C"
1736 //
1737 // this contradicts IBM own docs but this is not of much help, so just work around
1738 // it in the crudest possible manner
1739 wxChar *p = wxStrchr((wxChar *)retloc, _T(' '));
1740 if ( p )
1741 *p = _T('\0');
1742#endif // __AIX__
1743
d3f3e35f 1744#elif defined(__WIN32__)
65dc921d
VS
1745
1746 #if wxUSE_UNICODE && (defined(__VISUALC__) || defined(__MINGW32__))
1747 // NB: setlocale() from msvcrt.dll (used by VC++ and Mingw)
1748 // can't set locale to language that can only be written using
1749 // Unicode. Therefore wxSetlocale call failed, but we don't want
1750 // to report it as an error -- so that at least message catalogs
1751 // can be used. Watch for code marked with
1752 // #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS bellow.
1753 #define SETLOCALE_FAILS_ON_UNICODE_LANGS
1754 #endif
b7b97e77
VZ
1755
1756#if !wxUSE_UNICODE
1757 const
1758#endif
2b5f62a0 1759 wxMB2WXbuf retloc = wxT("C");
d3f3e35f
VS
1760 if (language != wxLANGUAGE_DEFAULT)
1761 {
63986ba6 1762 if (info->WinLang == 0)
d3f3e35f 1763 {
63986ba6 1764 wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str());
2b5f62a0 1765 // retloc already set to "C"
63986ba6
VS
1766 }
1767 else
ec37df57 1768 {
b7b97e77 1769 int codepage
999836aa
VZ
1770 #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1771 = -1
1772 #endif
1773 ;
ec37df57 1774 wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
63986ba6 1775 SORT_DEFAULT);
1c193821
JS
1776 // FIXME
1777#ifndef __WXWINCE__
65dc921d 1778 SetThreadLocale(lcid);
1c193821 1779#endif
65dc921d
VS
1780 // NB: we must translate LCID to CRT's setlocale string ourselves,
1781 // because SetThreadLocale does not modify change the
1782 // interpretation of setlocale(LC_ALL, "") call:
1783 wxChar buffer[256];
1784 buffer[0] = wxT('\0');
1785 GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
1786 locale << buffer;
1787 if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
1788 locale << wxT("_") << buffer;
1789 if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0)
1790 {
1791 codepage = wxAtoi(buffer);
1792 if (codepage != 0)
1793 locale << wxT(".") << buffer;
1794 }
525d8583 1795 if (locale.empty())
2b5f62a0 1796 {
65dc921d
VS
1797 wxLogLastError(wxT("SetThreadLocale"));
1798 wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
7beb59f3 1799 return false;
2b5f62a0 1800 }
63986ba6 1801 else
c611452f 1802 {
1c193821
JS
1803 // FIXME
1804#ifndef __WXWINCE__
65dc921d 1805 retloc = wxSetlocale(LC_ALL, locale);
1c193821 1806#endif
65dc921d
VS
1807#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1808 if (codepage == 0 && (const wxChar*)retloc == NULL)
2b5f62a0 1809 {
65dc921d 1810 retloc = wxT("C");
2b5f62a0 1811 }
65dc921d 1812#endif
c611452f 1813 }
d3f3e35f
VS
1814 }
1815 }
c611452f 1816 else
2b5f62a0 1817 {
1c193821
JS
1818 // FIXME
1819#ifndef __WXWINCE__
c611452f 1820 retloc = wxSetlocale(LC_ALL, wxEmptyString);
1c193821
JS
1821#else
1822 retloc = NULL;
1823#endif
65dc921d
VS
1824#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1825 if ((const wxChar*)retloc == NULL)
1826 {
1827 wxChar buffer[16];
1828 if (GetLocaleInfo(LOCALE_USER_DEFAULT,
1829 LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
1830 wxStrcmp(buffer, wxT("0")) == 0)
1831 {
1832 retloc = wxT("C");
1833 }
1834 }
1835#endif
2b5f62a0 1836 }
c611452f 1837
2b5f62a0 1838 if ( !retloc )
d3f3e35f
VS
1839 {
1840 wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
7beb59f3 1841 return false;
d3f3e35f 1842 }
85fb2206 1843#elif defined(__WXMAC__)
b51daa4f 1844 if (lang == wxLANGUAGE_DEFAULT)
85fb2206
SC
1845 locale = wxEmptyString;
1846 else
1847 locale = info->CanonicalName;
1848
1849 wxMB2WXbuf retloc = wxSetlocale(LC_ALL, locale);
1850
1851 if ( !retloc )
1852 {
1853 // Some C libraries don't like xx_YY form and require xx only
1854 retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
1855 }
1856 if ( !retloc )
1857 {
1858 wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
1859 return false;
1860 }
d3f3e35f 1861#else
ead190e4 1862 wxUnusedVar(flags);
7beb59f3 1863 return false;
e879e020 1864 #define WX_NO_LOCALE_SUPPORT
d3f3e35f 1865#endif
ec37df57 1866
e879e020 1867#ifndef WX_NO_LOCALE_SUPPORT
10545ca4 1868 wxChar *szLocale = retloc ? wxStrdup(retloc) : NULL;
b7e1957a 1869 bool ret = Init(name, canonical, szLocale,
b78a78f7
VS
1870 (flags & wxLOCALE_LOAD_DEFAULT) != 0,
1871 (flags & wxLOCALE_CONV_ENCODING) != 0);
10545ca4
VZ
1872 free(szLocale);
1873
549a7c37 1874 if (IsOk()) // setlocale() succeeded
10545ca4
VZ
1875 m_language = lang;
1876
b78a78f7 1877 return ret;
b7e1957a 1878#endif // !WX_NO_LOCALE_SUPPORT
d3f3e35f
VS
1879}
1880
1881
1882
fd323a5e
VZ
1883void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
1884{
f830b2b1 1885 if ( gs_searchPrefixes.Index(prefix) == wxNOT_FOUND )
fd323a5e 1886 {
f830b2b1 1887 gs_searchPrefixes.Add(prefix);
fd323a5e
VZ
1888 }
1889 //else: already have it
1890}
1891
41780009 1892/*static*/ int wxLocale::GetSystemLanguage()
d3f3e35f 1893{
41780009 1894 CreateLanguagesDB();
ec37df57
VZ
1895
1896 // init i to avoid compiler warning
1897 size_t i = 0,
41780009 1898 count = ms_languagesDB->GetCount();
d3f3e35f 1899
432e8391 1900#if defined(__UNIX__) && !defined(__WXMAC__)
ec37df57
VZ
1901 // first get the string identifying the language from the environment
1902 wxString langFull;
1903 if (!wxGetEnv(wxT("LC_ALL"), &langFull) &&
1904 !wxGetEnv(wxT("LC_MESSAGES"), &langFull) &&
1905 !wxGetEnv(wxT("LANG"), &langFull))
1906 {
41780009
VS
1907 // no language specified, threat it as English
1908 return wxLANGUAGE_ENGLISH;
ec37df57 1909 }
d3f3e35f 1910
efd1393b 1911 if ( langFull == _T("C") || langFull == _T("POSIX") )
d3f3e35f 1912 {
ec37df57 1913 // default C locale
41780009 1914 return wxLANGUAGE_ENGLISH;
d3f3e35f
VS
1915 }
1916
ec37df57
VZ
1917 // the language string has the following form
1918 //
efd1393b 1919 // lang[_LANG][.encoding][@modifier]
ec37df57 1920 //
efd1393b
VZ
1921 // (see environ(5) in the Open Unix specification)
1922 //
1923 // where lang is the primary language, LANG is a sublang/territory,
1924 // encoding is the charset to use and modifier "allows the user to select
1925 // a specific instance of localization data within a single category"
ec37df57
VZ
1926 //
1927 // for example, the following strings are valid:
1928 // fr
1929 // fr_FR
1930 // de_DE.iso88591
efd1393b
VZ
1931 // de_DE@euro
1932 // de_DE.iso88591@euro
ec37df57
VZ
1933
1934 // for now we don't use the encoding, although we probably should (doing
1935 // translations of the msg catalogs on the fly as required) (TODO)
efd1393b
VZ
1936 //
1937 // we don't use the modifiers neither but we probably should translate
1938 // "euro" into iso885915
1939 size_t posEndLang = langFull.find_first_of(_T("@."));
1940 if ( posEndLang != wxString::npos )
1941 {
1942 langFull.Truncate(posEndLang);
1943 }
ec37df57
VZ
1944
1945 // in addition to the format above, we also can have full language names
1946 // in LANG env var - for example, SuSE is known to use LANG="german" - so
1947 // check for this
1948
1949 // do we have just the language (or sublang too)?
df69528b 1950 bool justLang = langFull.length() == LEN_LANG;
ec37df57 1951 if ( justLang ||
df69528b 1952 (langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxT('_')) )
d3f3e35f 1953 {
ec37df57 1954 // 0. Make sure the lang is according to latest ISO 639
3103e8a9 1955 // (this is necessary because glibc uses iw and in instead
ec37df57
VZ
1956 // of he and id respectively).
1957
1958 // the language itself (second part is the dialect/sublang)
1959 wxString langOrig = ExtractLang(langFull);
1960
1961 wxString lang;
1962 if ( langOrig == wxT("iw"))
1963 lang = _T("he");
cf5e94bc 1964 else if (langOrig == wxT("in"))
ec37df57 1965 lang = wxT("id");
cf5e94bc 1966 else if (langOrig == wxT("ji"))
ec37df57 1967 lang = wxT("yi");
cf5e94bc
VS
1968 else if (langOrig == wxT("no_NO"))
1969 lang = wxT("nb_NO");
1970 else if (langOrig == wxT("no_NY"))
1971 lang = wxT("nn_NO");
1972 else if (langOrig == wxT("no"))
1973 lang = wxT("nb_NO");
ec37df57
VZ
1974 else
1975 lang = langOrig;
1976
1977 // did we change it?
1978 if ( lang != langOrig )
d3f3e35f 1979 {
ec37df57
VZ
1980 langFull = lang + ExtractNotLang(langFull);
1981 }
1982
1983 // 1. Try to find the language either as is:
1984 for ( i = 0; i < count; i++ )
1985 {
41780009 1986 if ( ms_languagesDB->Item(i).CanonicalName == langFull )
d3f3e35f 1987 {
d3f3e35f
VS
1988 break;
1989 }
1990 }
d3f3e35f 1991
ec37df57
VZ
1992 // 2. If langFull is of the form xx_YY, try to find xx:
1993 if ( i == count && !justLang )
d3f3e35f 1994 {
ec37df57 1995 for ( i = 0; i < count; i++ )
d3f3e35f 1996 {
41780009 1997 if ( ms_languagesDB->Item(i).CanonicalName == lang )
ec37df57
VZ
1998 {
1999 break;
2000 }
d3f3e35f
VS
2001 }
2002 }
d3f3e35f 2003
ec37df57
VZ
2004 // 3. If langFull is of the form xx, try to find any xx_YY record:
2005 if ( i == count && justLang )
d3f3e35f 2006 {
ec37df57 2007 for ( i = 0; i < count; i++ )
d3f3e35f 2008 {
41780009 2009 if ( ExtractLang(ms_languagesDB->Item(i).CanonicalName)
ec37df57
VZ
2010 == langFull )
2011 {
2012 break;
2013 }
d3f3e35f
VS
2014 }
2015 }
2016 }
ec37df57 2017 else // not standard format
d3f3e35f 2018 {
ec37df57
VZ
2019 // try to find the name in verbose description
2020 for ( i = 0; i < count; i++ )
d3f3e35f 2021 {
41780009 2022 if (ms_languagesDB->Item(i).Description.CmpNoCase(langFull) == 0)
d3f3e35f 2023 {
d3f3e35f
VS
2024 break;
2025 }
2026 }
2027 }
0e32fdb8 2028#elif defined(__WXMAC__)
44c44c82 2029 const wxChar * lc = NULL ;
0e32fdb8
SC
2030 long lang = GetScriptVariable( smSystemScript, smScriptLang) ;
2031 switch( GetScriptManagerVariable( smRegionCode ) ) {
2032 case verUS :
44c44c82 2033 lc = wxT("en_US") ;
0e32fdb8
SC
2034 break ;
2035 case verFrance :
44c44c82 2036 lc = wxT("fr_FR") ;
0e32fdb8
SC
2037 break ;
2038 case verBritain :
44c44c82 2039 lc = wxT("en_GB") ;
0e32fdb8
SC
2040 break ;
2041 case verGermany :
44c44c82 2042 lc = wxT("de_DE") ;
0e32fdb8
SC
2043 break ;
2044 case verItaly :
44c44c82 2045 lc = wxT("it_IT") ;
0e32fdb8
SC
2046 break ;
2047 case verNetherlands :
44c44c82 2048 lc = wxT("nl_NL") ;
0e32fdb8
SC
2049 break ;
2050 case verFlemish :
44c44c82 2051 lc = wxT("nl_BE") ;
0e32fdb8
SC
2052 break ;
2053 case verSweden :
44c44c82 2054 lc = wxT("sv_SE" );
0e32fdb8
SC
2055 break ;
2056 case verSpain :
44c44c82 2057 lc = wxT("es_ES" );
0e32fdb8
SC
2058 break ;
2059 case verDenmark :
44c44c82 2060 lc = wxT("da_DK") ;
0e32fdb8
SC
2061 break ;
2062 case verPortugal :
44c44c82 2063 lc = wxT("pt_PT") ;
0e32fdb8
SC
2064 break ;
2065 case verFrCanada:
44c44c82 2066 lc = wxT("fr_CA") ;
0e32fdb8
SC
2067 break ;
2068 case verNorway:
cf5e94bc 2069 lc = wxT("nb_NO") ;
0e32fdb8
SC
2070 break ;
2071 case verIsrael:
44c44c82 2072 lc = wxT("iw_IL") ;
0e32fdb8
SC
2073 break ;
2074 case verJapan:
44c44c82 2075 lc = wxT("ja_JP") ;
0e32fdb8
SC
2076 break ;
2077 case verAustralia:
44c44c82 2078 lc = wxT("en_AU") ;
0e32fdb8
SC
2079 break ;
2080 case verArabic:
44c44c82 2081 lc = wxT("ar") ;
0e32fdb8
SC
2082 break ;
2083 case verFinland:
44c44c82 2084 lc = wxT("fi_FI") ;
0e32fdb8
SC
2085 break ;
2086 case verFrSwiss:
44c44c82 2087 lc = wxT("fr_CH") ;
0e32fdb8
SC
2088 break ;
2089 case verGrSwiss:
44c44c82 2090 lc = wxT("de_CH") ;
0e32fdb8
SC
2091 break ;
2092 case verGreece:
44c44c82 2093 lc = wxT("el_GR") ;
0e32fdb8
SC
2094 break ;
2095 case verIceland:
44c44c82 2096 lc = wxT("is_IS") ;
0e32fdb8
SC
2097 break ;
2098 case verMalta:
44c44c82 2099 lc = wxT("mt_MT") ;
0e32fdb8
SC
2100 break ;
2101 case verCyprus:
2102 // _CY is not part of wx, so we have to translate according to the system language
2103 if ( lang == langGreek ) {
44c44c82 2104 lc = wxT("el_GR") ;
0e32fdb8
SC
2105 }
2106 else if ( lang == langTurkish ) {
44c44c82 2107 lc = wxT("tr_TR") ;
0e32fdb8
SC
2108 }
2109 break ;
2110 case verTurkey:
44c44c82 2111 lc = wxT("tr_TR") ;
0e32fdb8
SC
2112 break ;
2113 case verYugoCroatian:
44c44c82 2114 lc = wxT("hr_HR") ;
0e32fdb8
SC
2115 break ;
2116 case verIndiaHindi:
44c44c82 2117 lc = wxT("hi_IN") ;
0e32fdb8
SC
2118 break ;
2119 case verPakistanUrdu:
44c44c82 2120 lc = wxT("ur_PK") ;
0e32fdb8
SC
2121 break ;
2122 case verTurkishModified:
44c44c82 2123 lc = wxT("tr_TR") ;
0e32fdb8
SC
2124 break ;
2125 case verItalianSwiss:
44c44c82 2126 lc = wxT("it_CH") ;
0e32fdb8
SC
2127 break ;
2128 case verInternational:
44c44c82 2129 lc = wxT("en") ;
0e32fdb8
SC
2130 break ;
2131 case verRomania:
44c44c82 2132 lc = wxT("ro_RO") ;
0e32fdb8
SC
2133 break ;
2134 case verGreecePoly:
44c44c82 2135 lc = wxT("el_GR") ;
0e32fdb8
SC
2136 break ;
2137 case verLithuania:
44c44c82 2138 lc = wxT("lt_LT") ;
0e32fdb8
SC
2139 break ;
2140 case verPoland:
44c44c82 2141 lc = wxT("pl_PL") ;
0e32fdb8
SC
2142 break ;
2143 case verMagyar :
2144 case verHungary:
44c44c82 2145 lc = wxT("hu_HU") ;
0e32fdb8
SC
2146 break ;
2147 case verEstonia:
44c44c82 2148 lc = wxT("et_EE") ;
0e32fdb8
SC
2149 break ;
2150 case verLatvia:
44c44c82 2151 lc = wxT("lv_LV") ;
0e32fdb8
SC
2152 break ;
2153 case verSami:
2154 // not known
2155 break ;
2156 case verFaroeIsl:
44c44c82 2157 lc = wxT("fo_FO") ;
0e32fdb8
SC
2158 break ;
2159 case verIran:
44c44c82 2160 lc = wxT("fa_IR") ;
0e32fdb8
SC
2161 break ;
2162 case verRussia:
44c44c82 2163 lc = wxT("ru_RU") ;
0e32fdb8
SC
2164 break ;
2165 case verIreland:
44c44c82 2166 lc = wxT("ga_IE") ;
0e32fdb8
SC
2167 break ;
2168 case verKorea:
44c44c82 2169 lc = wxT("ko_KR") ;
0e32fdb8
SC
2170 break ;
2171 case verChina:
44c44c82 2172 lc = wxT("zh_CN") ;
0e32fdb8
SC
2173 break ;
2174 case verTaiwan:
44c44c82 2175 lc = wxT("zh_TW") ;
0e32fdb8
SC
2176 break ;
2177 case verThailand:
44c44c82 2178 lc = wxT("th_TH") ;
0e32fdb8
SC
2179 break ;
2180 case verCzech:
44c44c82 2181 lc = wxT("cs_CZ") ;
0e32fdb8
SC
2182 break ;
2183 case verSlovak:
44c44c82 2184 lc = wxT("sk_SK") ;
0e32fdb8
SC
2185 break ;
2186 case verBengali:
44c44c82 2187 lc = wxT("bn") ;
0e32fdb8
SC
2188 break ;
2189 case verByeloRussian:
44c44c82 2190 lc = wxT("be_BY") ;
0e32fdb8
SC
2191 break ;
2192 case verUkraine:
44c44c82 2193 lc = wxT("uk_UA") ;
0e32fdb8
SC
2194 break ;
2195 case verGreeceAlt:
44c44c82 2196 lc = wxT("el_GR") ;
0e32fdb8
SC
2197 break ;
2198 case verSerbian:
44c44c82 2199 lc = wxT("sr_YU") ;
0e32fdb8
SC
2200 break ;
2201 case verSlovenian:
44c44c82 2202 lc = wxT("sl_SI") ;
0e32fdb8
SC
2203 break ;
2204 case verMacedonian:
44c44c82 2205 lc = wxT("mk_MK") ;
0e32fdb8
SC
2206 break ;
2207 case verCroatia:
44c44c82 2208 lc = wxT("hr_HR") ;
0e32fdb8
SC
2209 break ;
2210 case verBrazil:
44c44c82 2211 lc = wxT("pt_BR ") ;
0e32fdb8
SC
2212 break ;
2213 case verBulgaria:
44c44c82 2214 lc = wxT("bg_BG") ;
0e32fdb8
SC
2215 break ;
2216 case verCatalonia:
44c44c82 2217 lc = wxT("ca_ES") ;
0e32fdb8
SC
2218 break ;
2219 case verScottishGaelic:
44c44c82 2220 lc = wxT("gd") ;
0e32fdb8
SC
2221 break ;
2222 case verManxGaelic:
44c44c82 2223 lc = wxT("gv") ;
0e32fdb8
SC
2224 break ;
2225 case verBreton:
44c44c82 2226 lc = wxT("br") ;
0e32fdb8
SC
2227 break ;
2228 case verNunavut:
44c44c82 2229 lc = wxT("iu_CA") ;
0e32fdb8
SC
2230 break ;
2231 case verWelsh:
44c44c82 2232 lc = wxT("cy") ;
0e32fdb8
SC
2233 break ;
2234 case verIrishGaelicScript:
44c44c82 2235 lc = wxT("ga_IE") ;
0e32fdb8
SC
2236 break ;
2237 case verEngCanada:
44c44c82 2238 lc = wxT("en_CA") ;
0e32fdb8
SC
2239 break ;
2240 case verBhutan:
44c44c82 2241 lc = wxT("dz_BT") ;
0e32fdb8
SC
2242 break ;
2243 case verArmenian:
44c44c82 2244 lc = wxT("hy_AM") ;
0e32fdb8
SC
2245 break ;
2246 case verGeorgian:
44c44c82 2247 lc = wxT("ka_GE") ;
0e32fdb8
SC
2248 break ;
2249 case verSpLatinAmerica:
44c44c82 2250 lc = wxT("es_AR") ;
0e32fdb8
SC
2251 break ;
2252 case verTonga:
44c44c82 2253 lc = wxT("to_TO" );
0e32fdb8
SC
2254 break ;
2255 case verFrenchUniversal:
44c44c82 2256 lc = wxT("fr_FR") ;
0e32fdb8
SC
2257 break ;
2258 case verAustria:
44c44c82 2259 lc = wxT("de_AT") ;
0e32fdb8
SC
2260 break ;
2261 case verGujarati:
44c44c82 2262 lc = wxT("gu_IN") ;
0e32fdb8
SC
2263 break ;
2264 case verPunjabi:
44c44c82 2265 lc = wxT("pa") ;
0e32fdb8
SC
2266 break ;
2267 case verIndiaUrdu:
44c44c82 2268 lc = wxT("ur_IN") ;
0e32fdb8
SC
2269 break ;
2270 case verVietnam:
44c44c82 2271 lc = wxT("vi_VN") ;
0e32fdb8
SC
2272 break ;
2273 case verFrBelgium:
44c44c82 2274 lc = wxT("fr_BE") ;
0e32fdb8
SC
2275 break ;
2276 case verUzbek:
44c44c82 2277 lc = wxT("uz_UZ") ;
0e32fdb8
SC
2278 break ;
2279 case verSingapore:
44c44c82 2280 lc = wxT("zh_SG") ;
0e32fdb8
SC
2281 break ;
2282 case verNynorsk:
44c44c82 2283 lc = wxT("nn_NO") ;
0e32fdb8
SC
2284 break ;
2285 case verAfrikaans:
44c44c82 2286 lc = wxT("af_ZA") ;
0e32fdb8
SC
2287 break ;
2288 case verEsperanto:
44c44c82 2289 lc = wxT("eo") ;
0e32fdb8
SC
2290 break ;
2291 case verMarathi:
44c44c82 2292 lc = wxT("mr_IN") ;
0e32fdb8
SC
2293 break ;
2294 case verTibetan:
44c44c82 2295 lc = wxT("bo") ;
0e32fdb8
SC
2296 break ;
2297 case verNepal:
44c44c82 2298 lc = wxT("ne_NP") ;
0e32fdb8
SC
2299 break ;
2300 case verGreenland:
44c44c82 2301 lc = wxT("kl_GL") ;
0e32fdb8
SC
2302 break ;
2303 default :
2304 break ;
2305 }
2306 for ( i = 0; i < count; i++ )
2307 {
2308 if ( ms_languagesDB->Item(i).CanonicalName == lc )
2309 {
2310 break;
2311 }
2312 }
9e7ed2b0 2313
d3f3e35f
VS
2314#elif defined(__WIN32__)
2315 LCID lcid = GetUserDefaultLCID();
ec37df57 2316 if ( lcid != 0 )
d3f3e35f 2317 {
ec37df57
VZ
2318 wxUint32 lang = PRIMARYLANGID(LANGIDFROMLCID(lcid));
2319 wxUint32 sublang = SUBLANGID(LANGIDFROMLCID(lcid));
2320
2321 for ( i = 0; i < count; i++ )
d3f3e35f 2322 {
41780009
VS
2323 if (ms_languagesDB->Item(i).WinLang == lang &&
2324 ms_languagesDB->Item(i).WinSublang == sublang)
ec37df57
VZ
2325 {
2326 break;
2327 }
d3f3e35f
VS
2328 }
2329 }
ec37df57
VZ
2330 //else: leave wxlang == wxLANGUAGE_UNKNOWN
2331#endif // Unix/Win32
d3f3e35f 2332
ec37df57
VZ
2333 if ( i < count )
2334 {
2335 // we did find a matching entry, use it
41780009 2336 return ms_languagesDB->Item(i).Language;
ec37df57 2337 }
d3f3e35f 2338
ec37df57
VZ
2339 // no info about this language in the database
2340 return wxLANGUAGE_UNKNOWN;
2341}
d3f3e35f 2342
dccce9ea
VZ
2343// ----------------------------------------------------------------------------
2344// encoding stuff
2345// ----------------------------------------------------------------------------
2346
2347// this is a bit strange as under Windows we get the encoding name using its
2348// numeric value and under Unix we do it the other way round, but this just
97626624 2349// reflects the way different systems provide the encoding info
dccce9ea
VZ
2350
2351/* static */
2352wxString wxLocale::GetSystemEncodingName()
2353{
2354 wxString encname;
2355
c67d6888 2356#if defined(__WIN32__) && !defined(__WXMICROWIN__)
dccce9ea
VZ
2357 // FIXME: what is the error return value for GetACP()?
2358 UINT codepage = ::GetACP();
ecffe992 2359 encname.Printf(_T("windows-%u"), codepage);
1ad48afb
SC
2360#elif defined(__WXMAC__)
2361 // default is just empty string, this resolves to the default system
2362 // encoding later
dccce9ea
VZ
2363#elif defined(__UNIX_LIKE__)
2364
2365#if defined(HAVE_LANGINFO_H) && defined(CODESET)
2366 // GNU libc provides current character set this way (this conforms
2367 // to Unix98)
2ec6905c
VS
2368 char *oldLocale = strdup(setlocale(LC_CTYPE, NULL));
2369 setlocale(LC_CTYPE, "");
f284605f 2370 const char *alang = nl_langinfo(CODESET);
2ec6905c 2371 setlocale(LC_CTYPE, oldLocale);
030c0bea 2372 free(oldLocale);
84f858e9
VZ
2373
2374 if ( alang )
dccce9ea 2375 {
09d2016d 2376 encname = wxString::FromAscii( alang );
dccce9ea 2377 }
09d2016d 2378 else // nl_langinfo() failed
dccce9ea
VZ
2379#endif // HAVE_LANGINFO_H
2380 {
2381 // if we can't get at the character set directly, try to see if it's in
2382 // the environment variables (in most cases this won't work, but I was
2383 // out of ideas)
b1ac3b56
RR
2384 char *lang = getenv( "LC_ALL");
2385 char *dot = lang ? strchr(lang, '.') : (char *)NULL;
dccce9ea
VZ
2386 if (!dot)
2387 {
b1ac3b56 2388 lang = getenv( "LC_CTYPE" );
dccce9ea 2389 if ( lang )
b1ac3b56 2390 dot = strchr(lang, '.' );
dccce9ea
VZ
2391 }
2392 if (!dot)
2393 {
b1ac3b56 2394 lang = getenv( "LANG");
dccce9ea 2395 if ( lang )
b1ac3b56 2396 dot = strchr(lang, '.');
dccce9ea
VZ
2397 }
2398
2399 if ( dot )
2400 {
b1ac3b56 2401 encname = wxString::FromAscii( dot+1 );
dccce9ea
VZ
2402 }
2403 }
2404#endif // Win32/Unix
2405
2406 return encname;
2407}
2408
2409/* static */
2410wxFontEncoding wxLocale::GetSystemEncoding()
2411{
c67d6888 2412#if defined(__WIN32__) && !defined(__WXMICROWIN__)
dccce9ea
VZ
2413 UINT codepage = ::GetACP();
2414
3c832d58 2415 // wxWidgets only knows about CP1250-1257, 874, 932, 936, 949, 950
dccce9ea
VZ
2416 if ( codepage >= 1250 && codepage <= 1257 )
2417 {
2418 return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250);
2419 }
c7821f94 2420
3c832d58
DS
2421 if ( codepage == 874 )
2422 {
2423 return wxFONTENCODING_CP874;
2424 }
2425
c7821f94
VZ
2426 if ( codepage == 932 )
2427 {
2428 return wxFONTENCODING_CP932;
2429 }
2430
2431 if ( codepage == 936 )
2432 {
2433 return wxFONTENCODING_CP936;
2434 }
2435
2436 if ( codepage == 949 )
2437 {
2438 return wxFONTENCODING_CP949;
2439 }
2440
2441 if ( codepage == 950 )
2442 {
2443 return wxFONTENCODING_CP950;
2444 }
ec79aded 2445#elif defined(__WXMAC__)
7beb59f3 2446 TextEncoding encoding = 0 ;
9e687455 2447#if TARGET_CARBON
7beb59f3 2448 encoding = CFStringGetSystemEncoding() ;
9e687455 2449#else
7beb59f3 2450 UpgradeScriptInfoToTextEncoding ( smSystemScript , kTextLanguageDontCare , kTextRegionDontCare , NULL , &encoding ) ;
9e687455
SC
2451#endif
2452 return wxMacGetFontEncFromSystemEnc( encoding ) ;
1e6feb95 2453#elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
09d2016d 2454 const wxString encname = GetSystemEncodingName();
dccce9ea
VZ
2455 if ( !encname.empty() )
2456 {
09d2016d 2457 wxFontEncoding enc = wxFontMapperBase::GetEncodingFromName(encname);
9cf28550 2458
2b5f62a0 2459 // on some modern Linux systems (RedHat 8) the default system locale
13f095d2 2460 // is UTF8 -- but it isn't supported by wxGTK1 in ANSI build at all so
2b5f62a0 2461 // don't even try to use it in this case
13f095d2
VZ
2462#if !wxUSE_UNICODE && \
2463 ((defined(__WXGTK__) && !defined(__WXGTK20__)) || defined(__WXMOTIF__))
2b5f62a0
VZ
2464 if ( enc == wxFONTENCODING_UTF8 )
2465 {
2466 // the most similar supported encoding...
2467 enc = wxFONTENCODING_ISO8859_1;
2468 }
2469#endif // !wxUSE_UNICODE
2470
09d2016d
VZ
2471 // GetEncodingFromName() returns wxFONTENCODING_DEFAULT for C locale
2472 // (a.k.a. US-ASCII) which is arguably a bug but keep it like this for
2473 // backwards compatibility and just take care to not return
2474 // wxFONTENCODING_DEFAULT from here as this surely doesn't make sense
2475 if ( enc != wxFONTENCODING_MAX && enc != wxFONTENCODING_DEFAULT )
9cf28550
VZ
2476 {
2477 return enc;
2478 }
2479 //else: return wxFONTENCODING_SYSTEM below
dccce9ea
VZ
2480 }
2481#endif // Win32/Unix
2482
2483 return wxFONTENCODING_SYSTEM;
2484}
2485
14f8fa9d
VZ
2486/* static */
2487void wxLocale::AddLanguage(const wxLanguageInfo& info)
d3f3e35f 2488{
41780009
VS
2489 CreateLanguagesDB();
2490 ms_languagesDB->Add(info);
d3f3e35f
VS
2491}
2492
14f8fa9d
VZ
2493/* static */
2494const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang)
2495{
2496 CreateLanguagesDB();
2497
f0ab09cc
VZ
2498 // calling GetLanguageInfo(wxLANGUAGE_DEFAULT) is a natural thing to do, so
2499 // make it work
2500 if ( lang == wxLANGUAGE_DEFAULT )
2501 lang = GetSystemLanguage();
2502
9d1e1be4 2503 const size_t count = ms_languagesDB->GetCount();
14f8fa9d
VZ
2504 for ( size_t i = 0; i < count; i++ )
2505 {
2506 if ( ms_languagesDB->Item(i).Language == lang )
2507 {
2508 return &ms_languagesDB->Item(i);
2509 }
2510 }
2511
2512 return NULL;
2513}
2514
4a6e4a46
VS
2515/* static */
2516wxString wxLocale::GetLanguageName(int lang)
2517{
2518 const wxLanguageInfo *info = GetLanguageInfo(lang);
2519 if ( !info )
2520 return wxEmptyString;
2521 else
2522 return info->Description;
2523}
2524
9d1e1be4
VZ
2525/* static */
2526const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale)
2527{
2528 CreateLanguagesDB();
2529
2530 const wxLanguageInfo *infoRet = NULL;
2531
2532 const size_t count = ms_languagesDB->GetCount();
2533 for ( size_t i = 0; i < count; i++ )
2534 {
2535 const wxLanguageInfo *info = &ms_languagesDB->Item(i);
2536
2537 if ( wxStricmp(locale, info->CanonicalName) == 0 ||
2538 wxStricmp(locale, info->Description) == 0 )
2539 {
2540 // exact match, stop searching
2541 infoRet = info;
2542 break;
2543 }
2544
2545 if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(_T('_'))) == 0 )
2546 {
2547 // a match -- but maybe we'll find an exact one later, so continue
2548 // looking
2549 //
2550 // OTOH, maybe we had already found a language match and in this
2551 // case don't overwrite it becauce the entry for the default
2552 // country always appears first in ms_languagesDB
2553 if ( !infoRet )
2554 infoRet = info;
2555 }
2556 }
2557
2558 return infoRet;
2559}
2560
d3f3e35f
VS
2561wxString wxLocale::GetSysName() const
2562{
1c193821
JS
2563 // FIXME
2564#ifndef __WXWINCE__
d3f3e35f 2565 return wxSetlocale(LC_ALL, NULL);
1c193821
JS
2566#else
2567 return wxEmptyString;
2568#endif
d3f3e35f
VS
2569}
2570
c801d85f
KB
2571// clean up
2572wxLocale::~wxLocale()
2573{
fd323a5e
VZ
2574 // free memory
2575 wxMsgCatalog *pTmpCat;
2576 while ( m_pMsgCat != NULL ) {
2577 pTmpCat = m_pMsgCat;
2578 m_pMsgCat = m_pMsgCat->m_pNext;
2579 delete pTmpCat;
2580 }
2581
eb48778d
VZ
2582 // restore old locale pointer
2583 wxSetLocale(m_pOldLocale);
bea561ce 2584
1c193821
JS
2585 // FIXME
2586#ifndef __WXWINCE__
e36e6f95 2587 wxSetlocale(LC_ALL, m_pszOldLocale);
1c193821 2588#endif
10545ca4 2589 free((wxChar *)m_pszOldLocale); // const_cast
c801d85f
KB
2590}
2591
2592// get the translation of given string in current locale
563d535e
VS
2593const wxChar *wxLocale::GetString(const wxChar *szOrigString,
2594 const wxChar *szDomain) const
849a28d0
VS
2595{
2596 return GetString(szOrigString, szOrigString, size_t(-1), szDomain);
2597}
2598
2599const wxChar *wxLocale::GetString(const wxChar *szOrigString,
2600 const wxChar *szOrigString2,
2601 size_t n,
2602 const wxChar *szDomain) const
c801d85f 2603{
563d535e 2604 if ( wxIsEmpty(szOrigString) )
849a28d0 2605 return wxEmptyString;
c801d85f 2606
563d535e
VS
2607 const wxChar *pszTrans = NULL;
2608 wxMsgCatalog *pMsgCat;
7af89395 2609
9e7ed2b0 2610 if ( szDomain != NULL )
563d535e
VS
2611 {
2612 pMsgCat = FindCatalog(szDomain);
2613
2614 // does the catalog exist?
2615 if ( pMsgCat != NULL )
849a28d0 2616 pszTrans = pMsgCat->GetString(szOrigString, n);
563d535e 2617 }
9e7ed2b0 2618 else
563d535e
VS
2619 {
2620 // search in all domains
9e7ed2b0 2621 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
563d535e 2622 {
849a28d0 2623 pszTrans = pMsgCat->GetString(szOrigString, n);
563d535e
VS
2624 if ( pszTrans != NULL ) // take the first found
2625 break;
2626 }
c801d85f
KB
2627 }
2628
9e7ed2b0 2629 if ( pszTrans == NULL )
563d535e
VS
2630 {
2631#ifdef __WXDEBUG__
9e7ed2b0 2632 if ( !NoTransErr::Suppress() )
563d535e
VS
2633 {
2634 NoTransErr noTransErr;
e90c1d2a 2635
6b91d113
VZ
2636 wxLogTrace(TRACE_I18N,
2637 _T("string \"%s\"[%ld] not found in %slocale '%s'."),
2638 szOrigString, (long)n,
2639 szDomain ? wxString::Format(_T("domain '%s' "), szDomain).c_str()
2640 : _T(""),
2641 m_strLocale.c_str());
563d535e
VS
2642 }
2643#endif // __WXDEBUG__
12419383 2644
849a28d0
VS
2645 if (n == size_t(-1))
2646 return szOrigString;
2647 else
2648 return n == 1 ? szOrigString : szOrigString2;
563d535e 2649 }
12419383 2650
563d535e 2651 return pszTrans;
c801d85f
KB
2652}
2653
c48908df
VZ
2654wxString wxLocale::GetHeaderValue( const wxChar* szHeader,
2655 const wxChar* szDomain ) const
2656{
e6bf9573 2657 if ( wxIsEmpty(szHeader) )
c48908df
VZ
2658 return wxEmptyString;
2659
2660 wxChar const * pszTrans = NULL;
2661 wxMsgCatalog *pMsgCat;
2662
2663 if ( szDomain != NULL )
2664 {
2665 pMsgCat = FindCatalog(szDomain);
2666
2667 // does the catalog exist?
2668 if ( pMsgCat == NULL )
2669 return wxEmptyString;
2670
525d8583 2671 pszTrans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
c48908df
VZ
2672 }
2673 else
2674 {
2675 // search in all domains
2676 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2677 {
525d8583 2678 pszTrans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
c48908df
VZ
2679 if ( pszTrans != NULL ) // take the first found
2680 break;
2681 }
2682 }
2683
2684 if ( wxIsEmpty(pszTrans) )
2685 return wxEmptyString;
2686
e6bf9573 2687 wxChar const * pszFound = wxStrstr(pszTrans, szHeader);
c48908df
VZ
2688 if ( pszFound == NULL )
2689 return wxEmptyString;
7beb59f3 2690
e6bf9573 2691 pszFound += wxStrlen(szHeader) + 2 /* ': ' */;
c48908df
VZ
2692
2693 // Every header is separated by \n
7beb59f3 2694
c48908df
VZ
2695 wxChar const * pszEndLine = wxStrchr(pszFound, wxT('\n'));
2696 if ( pszEndLine == NULL ) pszEndLine = pszFound + wxStrlen(pszFound);
2697
2698
2699 // wxString( wxChar*, length);
2700 wxString retVal( pszFound, pszEndLine - pszFound );
2701
2702 return retVal;
2703}
2704
2705
c801d85f 2706// find catalog by name in a linked list, return NULL if !found
e36e6f95 2707wxMsgCatalog *wxLocale::FindCatalog(const wxChar *szDomain) const
c801d85f 2708{
563d535e
VS
2709 // linear search in the linked list
2710 wxMsgCatalog *pMsgCat;
9e7ed2b0 2711 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
563d535e
VS
2712 {
2713 if ( wxStricmp(pMsgCat->GetName(), szDomain) == 0 )
2714 return pMsgCat;
2715 }
7af89395 2716
563d535e 2717 return NULL;
c801d85f
KB
2718}
2719
cec5ffc4
VZ
2720// check if the given locale is provided by OS and C run time
2721/* static */
2722bool wxLocale::IsAvailable(int lang)
2723{
2724 const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
2725 wxCHECK_MSG( info, false, _T("invalid language") );
2726
2727#ifdef __WIN32__
2728 if ( !info->WinLang )
2729 return false;
2730
2731 if ( !::IsValidLocale
2732 (
2733 MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
2734 SORT_DEFAULT),
2735 LCID_INSTALLED
2736 ) )
2737 return false;
2738#else // !__WIN32__
2739 // TODO: test if setlocale(info->CanonicalName) works under other OS?
2740#endif // __WIN32__/!__WIN32__
2741
2742 return true;
2743}
2744
c801d85f 2745// check if the given catalog is loaded
e36e6f95 2746bool wxLocale::IsLoaded(const wxChar *szDomain) const
c801d85f
KB
2747{
2748 return FindCatalog(szDomain) != NULL;
2749}
2750
2751// add a catalog to our linked list
e36e6f95 2752bool wxLocale::AddCatalog(const wxChar *szDomain)
d721baa9
VS
2753{
2754 return AddCatalog(szDomain, wxLANGUAGE_ENGLISH, NULL);
2755}
2756
2757// add a catalog to our linked list
2758bool wxLocale::AddCatalog(const wxChar *szDomain,
2759 wxLanguage msgIdLanguage,
2760 const wxChar *msgIdCharset)
2761
c801d85f
KB
2762{
2763 wxMsgCatalog *pMsgCat = new wxMsgCatalog;
7af89395 2764
d721baa9 2765 if ( pMsgCat->Load(m_strShort, szDomain, msgIdCharset, m_bConvertEncoding) ) {
c801d85f
KB
2766 // add it to the head of the list so that in GetString it will
2767 // be searched before the catalogs added earlier
2768 pMsgCat->m_pNext = m_pMsgCat;
2769 m_pMsgCat = pMsgCat;
7af89395 2770
d721baa9 2771 return true;
c801d85f
KB
2772 }
2773 else {
2774 // don't add it because it couldn't be loaded anyway
2775 delete pMsgCat;
7af89395 2776
d721baa9
VS
2777 // It is OK to not load catalog if the msgid language and m_language match,
2778 // in which case we can directly display the texts embedded in program's
2779 // source code:
2780 if (m_language == msgIdLanguage)
2781 return true;
395a6701 2782
d721baa9
VS
2783 // If there's no exact match, we may still get partial match where the
2784 // (basic) language is same, but the country differs. For example, it's
2785 // permitted to use en_US strings from sources even if m_language is en_GB:
2786 const wxLanguageInfo *msgIdLangInfo = GetLanguageInfo(msgIdLanguage);
2787 if ( msgIdLangInfo &&
2788 msgIdLangInfo->CanonicalName.Mid(0, 2) == m_strShort.Mid(0, 2) )
2789 {
2790 return true;
2791 }
2792
2793 return false;
c801d85f
KB
2794 }
2795}
2796
cfb20656
VZ
2797// ----------------------------------------------------------------------------
2798// accessors for locale-dependent data
2799// ----------------------------------------------------------------------------
2800
2801#ifdef __WXMSW__
2802
2803/* static */
3fe73755 2804wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
cfb20656
VZ
2805{
2806 wxString str;
2807 wxChar buffer[256];
2808 size_t count;
2809 buffer[0] = wxT('\0');
2810 switch (index)
2811 {
60d876f3 2812 case wxLOCALE_DECIMAL_POINT:
cfb20656
VZ
2813 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
2814 if (!count)
1e8bd6b2 2815 str << wxT(".");
cfb20656
VZ
2816 else
2817 str << buffer;
2818 break;
60d876f3 2819#if 0
cfb20656
VZ
2820 case wxSYS_LIST_SEPARATOR:
2821 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
2822 if (!count)
1e8bd6b2 2823 str << wxT(",");
cfb20656
VZ
2824 else
2825 str << buffer;
2826 break;
2827 case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero
2828 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256);
2829 if (!count)
1e8bd6b2 2830 str << wxT("0");
cfb20656
VZ
2831 else
2832 str << buffer;
2833 break;
60d876f3 2834#endif
cfb20656 2835 default:
1e8bd6b2 2836 wxFAIL_MSG(wxT("Unknown System String !"));
cfb20656
VZ
2837 }
2838 return str;
2839}
2840
2841#else // !__WXMSW__
2842
2843/* static */
60d876f3 2844wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
cfb20656 2845{
60d876f3
SN
2846 struct lconv *locale_info = localeconv();
2847 switch (cat)
2848 {
2849 case wxLOCALE_CAT_NUMBER:
2850 switch (index)
2851 {
2852 case wxLOCALE_THOUSANDS_SEP:
3fe73755
SN
2853 return wxString(locale_info->thousands_sep,
2854 *wxConvCurrent);
60d876f3 2855 case wxLOCALE_DECIMAL_POINT:
3fe73755
SN
2856 return wxString(locale_info->decimal_point,
2857 *wxConvCurrent);
60d876f3
SN
2858 default:
2859 return wxEmptyString;
2860 }
2861 case wxLOCALE_CAT_MONEY:
2862 switch (index)
2863 {
2864 case wxLOCALE_THOUSANDS_SEP:
3fe73755
SN
2865 return wxString(locale_info->mon_thousands_sep,
2866 *wxConvCurrent);
60d876f3 2867 case wxLOCALE_DECIMAL_POINT:
3fe73755
SN
2868 return wxString(locale_info->mon_decimal_point,
2869 *wxConvCurrent);
60d876f3
SN
2870 default:
2871 return wxEmptyString;
2872 }
2873 default:
2874 return wxEmptyString;
2875 }
b7b97e77 2876}
cfb20656
VZ
2877
2878#endif // __WXMSW__/!__WXMSW__
2879
c801d85f
KB
2880// ----------------------------------------------------------------------------
2881// global functions and variables
2882// ----------------------------------------------------------------------------
2883
c801d85f
KB
2884// retrieve/change current locale
2885// ------------------------------
2886
2887// the current locale object
84c18814 2888static wxLocale *g_pLocale = NULL;
c801d85f 2889
1678ad78
GL
2890wxLocale *wxGetLocale()
2891{
7af89395 2892 return g_pLocale;
1678ad78
GL
2893}
2894
c801d85f
KB
2895wxLocale *wxSetLocale(wxLocale *pLocale)
2896{
7af89395
VZ
2897 wxLocale *pOld = g_pLocale;
2898 g_pLocale = pLocale;
2899 return pOld;
c801d85f 2900}
d427503c 2901
41780009
VS
2902
2903
2904// ----------------------------------------------------------------------------
2905// wxLocale module (for lazy destruction of languagesDB)
2906// ----------------------------------------------------------------------------
2907
2908class wxLocaleModule: public wxModule
2909{
2910 DECLARE_DYNAMIC_CLASS(wxLocaleModule)
2911 public:
2912 wxLocaleModule() {}
7beb59f3 2913 bool OnInit() { return true; }
41780009
VS
2914 void OnExit() { wxLocale::DestroyLanguagesDB(); }
2915};
2916
2917IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
2918
2919
2920
d3f3e35f
VS
2921// ----------------------------------------------------------------------------
2922// default languages table & initialization
2923// ----------------------------------------------------------------------------
2924
865a1730 2925
41780009
VS
2926
2927// --- --- --- generated code begins here --- --- ---
2928
d3f3e35f
VS
2929// This table is generated by misc/languages/genlang.py
2930// When making changes, please put them into misc/languages/langtabl.txt
2931
04ef50df 2932#if !defined(__WIN32__) || defined(__WXMICROWIN__)
63986ba6
VS
2933
2934#define SETWINLANG(info,lang,sublang)
2935
2936#else
2937
d3f3e35f
VS
2938#define SETWINLANG(info,lang,sublang) \
2939 info.WinLang = lang, info.WinSublang = sublang;
63986ba6
VS
2940
2941#ifndef LANG_AFRIKAANS
2942#define LANG_AFRIKAANS (0)
2943#endif
2944#ifndef LANG_ALBANIAN
2945#define LANG_ALBANIAN (0)
2946#endif
2947#ifndef LANG_ARABIC
2948#define LANG_ARABIC (0)
2949#endif
2950#ifndef LANG_ARMENIAN
2951#define LANG_ARMENIAN (0)
2952#endif
2953#ifndef LANG_ASSAMESE
2954#define LANG_ASSAMESE (0)
2955#endif
2956#ifndef LANG_AZERI
2957#define LANG_AZERI (0)
2958#endif
2959#ifndef LANG_BASQUE
2960#define LANG_BASQUE (0)
2961#endif
2962#ifndef LANG_BELARUSIAN
2963#define LANG_BELARUSIAN (0)
2964#endif
2965#ifndef LANG_BENGALI
2966#define LANG_BENGALI (0)
2967#endif
2968#ifndef LANG_BULGARIAN
2969#define LANG_BULGARIAN (0)
2970#endif
2971#ifndef LANG_CATALAN
2972#define LANG_CATALAN (0)
2973#endif
2974#ifndef LANG_CHINESE
2975#define LANG_CHINESE (0)
2976#endif
2977#ifndef LANG_CROATIAN
2978#define LANG_CROATIAN (0)
2979#endif
2980#ifndef LANG_CZECH
2981#define LANG_CZECH (0)
2982#endif
2983#ifndef LANG_DANISH
2984#define LANG_DANISH (0)
2985#endif
2986#ifndef LANG_DUTCH
2987#define LANG_DUTCH (0)
2988#endif
2989#ifndef LANG_ENGLISH
2990#define LANG_ENGLISH (0)
2991#endif
2992#ifndef LANG_ESTONIAN
2993#define LANG_ESTONIAN (0)
2994#endif
2995#ifndef LANG_FAEROESE
2996#define LANG_FAEROESE (0)
2997#endif
2998#ifndef LANG_FARSI
2999#define LANG_FARSI (0)
3000#endif
3001#ifndef LANG_FINNISH
3002#define LANG_FINNISH (0)
3003#endif
3004#ifndef LANG_FRENCH
3005#define LANG_FRENCH (0)
3006#endif
3007#ifndef LANG_GEORGIAN
3008#define LANG_GEORGIAN (0)
3009#endif
3010#ifndef LANG_GERMAN
3011#define LANG_GERMAN (0)
3012#endif
3013#ifndef LANG_GREEK
3014#define LANG_GREEK (0)
3015#endif
3016#ifndef LANG_GUJARATI
3017#define LANG_GUJARATI (0)
3018#endif
3019#ifndef LANG_HEBREW
3020#define LANG_HEBREW (0)
3021#endif
3022#ifndef LANG_HINDI
3023#define LANG_HINDI (0)
3024#endif
3025#ifndef LANG_HUNGARIAN
3026#define LANG_HUNGARIAN (0)
3027#endif
3028#ifndef LANG_ICELANDIC
3029#define LANG_ICELANDIC (0)
3030#endif
3031#ifndef LANG_INDONESIAN
3032#define LANG_INDONESIAN (0)
3033#endif
3034#ifndef LANG_ITALIAN
3035#define LANG_ITALIAN (0)
3036#endif
3037#ifndef LANG_JAPANESE
3038#define LANG_JAPANESE (0)
3039#endif
3040#ifndef LANG_KANNADA
3041#define LANG_KANNADA (0)
3042#endif
3043#ifndef LANG_KASHMIRI
3044#define LANG_KASHMIRI (0)
3045#endif
3046#ifndef LANG_KAZAK
3047#define LANG_KAZAK (0)
3048#endif
3049#ifndef LANG_KONKANI
3050#define LANG_KONKANI (0)
3051#endif
3052#ifndef LANG_KOREAN
3053#define LANG_KOREAN (0)
3054#endif
3055#ifndef LANG_LATVIAN
3056#define LANG_LATVIAN (0)
3057#endif
3058#ifndef LANG_LITHUANIAN
3059#define LANG_LITHUANIAN (0)
3060#endif
3061#ifndef LANG_MACEDONIAN
3062#define LANG_MACEDONIAN (0)
3063#endif
3064#ifndef LANG_MALAY
3065#define LANG_MALAY (0)
3066#endif
3067#ifndef LANG_MALAYALAM
3068#define LANG_MALAYALAM (0)
3069#endif
3070#ifndef LANG_MANIPURI
3071#define LANG_MANIPURI (0)
3072#endif
3073#ifndef LANG_MARATHI
3074#define LANG_MARATHI (0)
3075#endif
3076#ifndef LANG_NEPALI
3077#define LANG_NEPALI (0)
3078#endif
3079#ifndef LANG_NORWEGIAN
3080#define LANG_NORWEGIAN (0)
3081#endif
3082#ifndef LANG_ORIYA
3083#define LANG_ORIYA (0)
3084#endif
3085#ifndef LANG_POLISH
3086#define LANG_POLISH (0)
3087#endif
3088#ifndef LANG_PORTUGUESE
3089#define LANG_PORTUGUESE (0)
3090#endif
3091#ifndef LANG_PUNJABI
3092#define LANG_PUNJABI (0)
3093#endif
3094#ifndef LANG_ROMANIAN
3095#define LANG_ROMANIAN (0)
3096#endif
3097#ifndef LANG_RUSSIAN
3098#define LANG_RUSSIAN (0)
3099#endif
3100#ifndef LANG_SANSKRIT
3101#define LANG_SANSKRIT (0)
3102#endif
3103#ifndef LANG_SERBIAN
3104#define LANG_SERBIAN (0)
3105#endif
3106#ifndef LANG_SINDHI
3107#define LANG_SINDHI (0)
3108#endif
3109#ifndef LANG_SLOVAK
3110#define LANG_SLOVAK (0)
3111#endif
3112#ifndef LANG_SLOVENIAN
3113#define LANG_SLOVENIAN (0)
3114#endif
3115#ifndef LANG_SPANISH
3116#define LANG_SPANISH (0)
3117#endif
3118#ifndef LANG_SWAHILI
3119#define LANG_SWAHILI (0)
3120#endif
3121#ifndef LANG_SWEDISH
3122#define LANG_SWEDISH (0)
3123#endif
3124#ifndef LANG_TAMIL
3125#define LANG_TAMIL (0)
3126#endif
3127#ifndef LANG_TATAR
3128#define LANG_TATAR (0)
3129#endif
3130#ifndef LANG_TELUGU
3131#define LANG_TELUGU (0)
3132#endif
3133#ifndef LANG_THAI
3134#define LANG_THAI (0)
3135#endif
3136#ifndef LANG_TURKISH
3137#define LANG_TURKISH (0)
3138#endif
3139#ifndef LANG_UKRAINIAN
3140#define LANG_UKRAINIAN (0)
3141#endif
3142#ifndef LANG_URDU
3143#define LANG_URDU (0)
3144#endif
3145#ifndef LANG_UZBEK
3146#define LANG_UZBEK (0)
3147#endif
3148#ifndef LANG_VIETNAMESE
3149#define LANG_VIETNAMESE (0)
3150#endif
3151#ifndef SUBLANG_ARABIC_ALGERIA
3152#define SUBLANG_ARABIC_ALGERIA SUBLANG_DEFAULT
3153#endif
3154#ifndef SUBLANG_ARABIC_BAHRAIN
3155#define SUBLANG_ARABIC_BAHRAIN SUBLANG_DEFAULT
3156#endif
3157#ifndef SUBLANG_ARABIC_EGYPT
3158#define SUBLANG_ARABIC_EGYPT SUBLANG_DEFAULT
3159#endif
3160#ifndef SUBLANG_ARABIC_IRAQ
3161#define SUBLANG_ARABIC_IRAQ SUBLANG_DEFAULT
3162#endif
3163#ifndef SUBLANG_ARABIC_JORDAN
3164#define SUBLANG_ARABIC_JORDAN SUBLANG_DEFAULT
3165#endif
3166#ifndef SUBLANG_ARABIC_KUWAIT
3167#define SUBLANG_ARABIC_KUWAIT SUBLANG_DEFAULT
3168#endif
3169#ifndef SUBLANG_ARABIC_LEBANON
3170#define SUBLANG_ARABIC_LEBANON SUBLANG_DEFAULT
3171#endif
3172#ifndef SUBLANG_ARABIC_LIBYA
3173#define SUBLANG_ARABIC_LIBYA SUBLANG_DEFAULT
3174#endif
3175#ifndef SUBLANG_ARABIC_MOROCCO
3176#define SUBLANG_ARABIC_MOROCCO SUBLANG_DEFAULT
3177#endif
3178#ifndef SUBLANG_ARABIC_OMAN
3179#define SUBLANG_ARABIC_OMAN SUBLANG_DEFAULT
3180#endif
3181#ifndef SUBLANG_ARABIC_QATAR
3182#define SUBLANG_ARABIC_QATAR SUBLANG_DEFAULT
3183#endif
3184#ifndef SUBLANG_ARABIC_SAUDI_ARABIA
3185#define SUBLANG_ARABIC_SAUDI_ARABIA SUBLANG_DEFAULT
3186#endif
3187#ifndef SUBLANG_ARABIC_SYRIA
3188#define SUBLANG_ARABIC_SYRIA SUBLANG_DEFAULT
3189#endif
3190#ifndef SUBLANG_ARABIC_TUNISIA
3191#define SUBLANG_ARABIC_TUNISIA SUBLANG_DEFAULT
3192#endif
3193#ifndef SUBLANG_ARABIC_UAE
3194#define SUBLANG_ARABIC_UAE SUBLANG_DEFAULT
3195#endif
3196#ifndef SUBLANG_ARABIC_YEMEN
3197#define SUBLANG_ARABIC_YEMEN SUBLANG_DEFAULT
3198#endif
3199#ifndef SUBLANG_AZERI_CYRILLIC
3200#define SUBLANG_AZERI_CYRILLIC SUBLANG_DEFAULT
3201#endif
3202#ifndef SUBLANG_AZERI_LATIN
3203#define SUBLANG_AZERI_LATIN SUBLANG_DEFAULT
3204#endif
3205#ifndef SUBLANG_CHINESE_SIMPLIFIED
3206#define SUBLANG_CHINESE_SIMPLIFIED SUBLANG_DEFAULT
3207#endif
3208#ifndef SUBLANG_CHINESE_TRADITIONAL
3209#define SUBLANG_CHINESE_TRADITIONAL SUBLANG_DEFAULT
3210#endif
3211#ifndef SUBLANG_CHINESE_HONGKONG
3212#define SUBLANG_CHINESE_HONGKONG SUBLANG_DEFAULT
3213#endif
3214#ifndef SUBLANG_CHINESE_MACAU
3215#define SUBLANG_CHINESE_MACAU SUBLANG_DEFAULT
3216#endif
3217#ifndef SUBLANG_CHINESE_SINGAPORE
3218#define SUBLANG_CHINESE_SINGAPORE SUBLANG_DEFAULT
3219#endif
3220#ifndef SUBLANG_DUTCH
3221#define SUBLANG_DUTCH SUBLANG_DEFAULT
3222#endif
3223#ifndef SUBLANG_DUTCH_BELGIAN
3224#define SUBLANG_DUTCH_BELGIAN SUBLANG_DEFAULT
3225#endif
3226#ifndef SUBLANG_ENGLISH_UK
3227#define SUBLANG_ENGLISH_UK SUBLANG_DEFAULT
3228#endif
3229#ifndef SUBLANG_ENGLISH_US
3230#define SUBLANG_ENGLISH_US SUBLANG_DEFAULT
3231#endif
3232#ifndef SUBLANG_ENGLISH_AUS
3233#define SUBLANG_ENGLISH_AUS SUBLANG_DEFAULT
3234#endif
3235#ifndef SUBLANG_ENGLISH_BELIZE
3236#define SUBLANG_ENGLISH_BELIZE SUBLANG_DEFAULT
3237#endif
3238#ifndef SUBLANG_ENGLISH_CAN
3239#define SUBLANG_ENGLISH_CAN SUBLANG_DEFAULT
3240#endif
3241#ifndef SUBLANG_ENGLISH_CARIBBEAN
3242#define SUBLANG_ENGLISH_CARIBBEAN SUBLANG_DEFAULT
3243#endif
3244#ifndef SUBLANG_ENGLISH_EIRE
3245#define SUBLANG_ENGLISH_EIRE SUBLANG_DEFAULT
3246#endif
3247#ifndef SUBLANG_ENGLISH_JAMAICA
3248#define SUBLANG_ENGLISH_JAMAICA SUBLANG_DEFAULT
3249#endif
3250#ifndef SUBLANG_ENGLISH_NZ
3251#define SUBLANG_ENGLISH_NZ SUBLANG_DEFAULT
3252#endif
3253#ifndef SUBLANG_ENGLISH_PHILIPPINES
3254#define SUBLANG_ENGLISH_PHILIPPINES SUBLANG_DEFAULT
3255#endif
3256#ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
3257#define SUBLANG_ENGLISH_SOUTH_AFRICA SUBLANG_DEFAULT
3258#endif
3259#ifndef SUBLANG_ENGLISH_TRINIDAD
3260#define SUBLANG_ENGLISH_TRINIDAD SUBLANG_DEFAULT
3261#endif
3262#ifndef SUBLANG_ENGLISH_ZIMBABWE
3263#define SUBLANG_ENGLISH_ZIMBABWE SUBLANG_DEFAULT
3264#endif
3265#ifndef SUBLANG_FRENCH
3266#define SUBLANG_FRENCH SUBLANG_DEFAULT
3267#endif
3268#ifndef SUBLANG_FRENCH_BELGIAN
3269#define SUBLANG_FRENCH_BELGIAN SUBLANG_DEFAULT
3270#endif
3271#ifndef SUBLANG_FRENCH_CANADIAN
3272#define SUBLANG_FRENCH_CANADIAN SUBLANG_DEFAULT
3273#endif
3274#ifndef SUBLANG_FRENCH_LUXEMBOURG
3275#define SUBLANG_FRENCH_LUXEMBOURG SUBLANG_DEFAULT
3276#endif
3277#ifndef SUBLANG_FRENCH_MONACO
3278#define SUBLANG_FRENCH_MONACO SUBLANG_DEFAULT
3279#endif
3280#ifndef SUBLANG_FRENCH_SWISS
3281#define SUBLANG_FRENCH_SWISS SUBLANG_DEFAULT
3282#endif
3283#ifndef SUBLANG_GERMAN
3284#define SUBLANG_GERMAN SUBLANG_DEFAULT
3285#endif
3286#ifndef SUBLANG_GERMAN_AUSTRIAN
3287#define SUBLANG_GERMAN_AUSTRIAN SUBLANG_DEFAULT
3288#endif
3289#ifndef SUBLANG_GERMAN_LIECHTENSTEIN
3290#define SUBLANG_GERMAN_LIECHTENSTEIN SUBLANG_DEFAULT
3291#endif
3292#ifndef SUBLANG_GERMAN_LUXEMBOURG
3293#define SUBLANG_GERMAN_LUXEMBOURG SUBLANG_DEFAULT
3294#endif
3295#ifndef SUBLANG_GERMAN_SWISS
3296#define SUBLANG_GERMAN_SWISS SUBLANG_DEFAULT
3297#endif
3298#ifndef SUBLANG_ITALIAN
3299#define SUBLANG_ITALIAN SUBLANG_DEFAULT
3300#endif
3301#ifndef SUBLANG_ITALIAN_SWISS
3302#define SUBLANG_ITALIAN_SWISS SUBLANG_DEFAULT
3303#endif
3304#ifndef SUBLANG_KASHMIRI_INDIA
3305#define SUBLANG_KASHMIRI_INDIA SUBLANG_DEFAULT
3306#endif
3307#ifndef SUBLANG_KOREAN
3308#define SUBLANG_KOREAN SUBLANG_DEFAULT
3309#endif
3310#ifndef SUBLANG_LITHUANIAN
3311#define SUBLANG_LITHUANIAN SUBLANG_DEFAULT
3312#endif
3313#ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
3314#define SUBLANG_MALAY_BRUNEI_DARUSSALAM SUBLANG_DEFAULT
3315#endif
3316#ifndef SUBLANG_MALAY_MALAYSIA
3317#define SUBLANG_MALAY_MALAYSIA SUBLANG_DEFAULT
3318#endif
3319#ifndef SUBLANG_NEPALI_INDIA
3320#define SUBLANG_NEPALI_INDIA SUBLANG_DEFAULT
3321#endif
3322#ifndef SUBLANG_NORWEGIAN_BOKMAL
3323#define SUBLANG_NORWEGIAN_BOKMAL SUBLANG_DEFAULT
3324#endif
3325#ifndef SUBLANG_NORWEGIAN_NYNORSK
3326#define SUBLANG_NORWEGIAN_NYNORSK SUBLANG_DEFAULT
3327#endif
3328#ifndef SUBLANG_PORTUGUESE
3329#define SUBLANG_PORTUGUESE SUBLANG_DEFAULT
3330#endif
3331#ifndef SUBLANG_PORTUGUESE_BRAZILIAN
3332#define SUBLANG_PORTUGUESE_BRAZILIAN SUBLANG_DEFAULT
3333#endif
3334#ifndef SUBLANG_SERBIAN_CYRILLIC
3335#define SUBLANG_SERBIAN_CYRILLIC SUBLANG_DEFAULT
3336#endif
3337#ifndef SUBLANG_SERBIAN_LATIN
3338#define SUBLANG_SERBIAN_LATIN SUBLANG_DEFAULT
3339#endif
3340#ifndef SUBLANG_SPANISH
3341#define SUBLANG_SPANISH SUBLANG_DEFAULT
3342#endif
3343#ifndef SUBLANG_SPANISH_ARGENTINA
3344#define SUBLANG_SPANISH_ARGENTINA SUBLANG_DEFAULT
3345#endif
3346#ifndef SUBLANG_SPANISH_BOLIVIA
3347#define SUBLANG_SPANISH_BOLIVIA SUBLANG_DEFAULT
3348#endif
3349#ifndef SUBLANG_SPANISH_CHILE
3350#define SUBLANG_SPANISH_CHILE SUBLANG_DEFAULT
3351#endif
3352#ifndef SUBLANG_SPANISH_COLOMBIA
3353#define SUBLANG_SPANISH_COLOMBIA SUBLANG_DEFAULT
3354#endif
3355#ifndef SUBLANG_SPANISH_COSTA_RICA
3356#define SUBLANG_SPANISH_COSTA_RICA SUBLANG_DEFAULT
3357#endif
3358#ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
3359#define SUBLANG_SPANISH_DOMINICAN_REPUBLIC SUBLANG_DEFAULT
3360#endif
3361#ifndef SUBLANG_SPANISH_ECUADOR
3362#define SUBLANG_SPANISH_ECUADOR SUBLANG_DEFAULT
3363#endif
3364#ifndef SUBLANG_SPANISH_EL_SALVADOR
3365#define SUBLANG_SPANISH_EL_SALVADOR SUBLANG_DEFAULT
3366#endif
3367#ifndef SUBLANG_SPANISH_GUATEMALA
3368#define SUBLANG_SPANISH_GUATEMALA SUBLANG_DEFAULT
3369#endif
3370#ifndef SUBLANG_SPANISH_HONDURAS
3371#define SUBLANG_SPANISH_HONDURAS SUBLANG_DEFAULT
3372#endif
3373#ifndef SUBLANG_SPANISH_MEXICAN
3374#define SUBLANG_SPANISH_MEXICAN SUBLANG_DEFAULT
3375#endif
3376#ifndef SUBLANG_SPANISH_MODERN
3377#define SUBLANG_SPANISH_MODERN SUBLANG_DEFAULT
3378#endif
3379#ifndef SUBLANG_SPANISH_NICARAGUA
3380#define SUBLANG_SPANISH_NICARAGUA SUBLANG_DEFAULT
3381#endif
3382#ifndef SUBLANG_SPANISH_PANAMA
3383#define SUBLANG_SPANISH_PANAMA SUBLANG_DEFAULT
3384#endif
3385#ifndef SUBLANG_SPANISH_PARAGUAY
3386#define SUBLANG_SPANISH_PARAGUAY SUBLANG_DEFAULT
3387#endif
3388#ifndef SUBLANG_SPANISH_PERU
3389#define SUBLANG_SPANISH_PERU SUBLANG_DEFAULT
3390#endif
3391#ifndef SUBLANG_SPANISH_PUERTO_RICO
3392#define SUBLANG_SPANISH_PUERTO_RICO SUBLANG_DEFAULT
3393#endif
3394#ifndef SUBLANG_SPANISH_URUGUAY
3395#define SUBLANG_SPANISH_URUGUAY SUBLANG_DEFAULT
3396#endif
3397#ifndef SUBLANG_SPANISH_VENEZUELA
3398#define SUBLANG_SPANISH_VENEZUELA SUBLANG_DEFAULT
3399#endif
3400#ifndef SUBLANG_SWEDISH
3401#define SUBLANG_SWEDISH SUBLANG_DEFAULT
3402#endif
3403#ifndef SUBLANG_SWEDISH_FINLAND
3404#define SUBLANG_SWEDISH_FINLAND SUBLANG_DEFAULT
3405#endif
3406#ifndef SUBLANG_URDU_INDIA
3407#define SUBLANG_URDU_INDIA SUBLANG_DEFAULT
3408#endif
3409#ifndef SUBLANG_URDU_PAKISTAN
3410#define SUBLANG_URDU_PAKISTAN SUBLANG_DEFAULT
3411#endif
3412#ifndef SUBLANG_UZBEK_CYRILLIC
3413#define SUBLANG_UZBEK_CYRILLIC SUBLANG_DEFAULT
3414#endif
3415#ifndef SUBLANG_UZBEK_LATIN
3416#define SUBLANG_UZBEK_LATIN SUBLANG_DEFAULT
d3f3e35f
VS
3417#endif
3418
63986ba6
VS
3419
3420#endif // __WIN32__
3421
978af864 3422#define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
d3f3e35f
VS
3423 info.Language = wxlang; \
3424 info.CanonicalName = wxT(canonical); \
978af864 3425 info.LayoutDirection = layout; \
2b5f62a0 3426 info.Description = wxT(desc); \
d3f3e35f
VS
3427 SETWINLANG(info, winlang, winsublang) \
3428 AddLanguage(info);
3429
3430void wxLocale::InitLanguagesDB()
3431{
3432 wxLanguageInfo info;
3433 wxStringTokenizer tkn;
63986ba6 3434
978af864
VZ
3435 LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , wxLayout_LeftToRight, "Abkhazian")
3436 LNG(wxLANGUAGE_AFAR, "aa" , 0 , 0 , wxLayout_LeftToRight, "Afar")
3437 LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Afrikaans")
3438 LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Albanian")
3439 LNG(wxLANGUAGE_AMHARIC, "am" , 0 , 0 , wxLayout_LeftToRight, "Amharic")
3440 LNG(wxLANGUAGE_ARABIC, "ar" , LANG_ARABIC , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Arabic")
3441 LNG(wxLANGUAGE_ARABIC_ALGERIA, "ar_DZ", LANG_ARABIC , SUBLANG_ARABIC_ALGERIA , wxLayout_RightToLeft, "Arabic (Algeria)")
3442 LNG(wxLANGUAGE_ARABIC_BAHRAIN, "ar_BH", LANG_ARABIC , SUBLANG_ARABIC_BAHRAIN , wxLayout_RightToLeft, "Arabic (Bahrain)")
3443 LNG(wxLANGUAGE_ARABIC_EGYPT, "ar_EG", LANG_ARABIC , SUBLANG_ARABIC_EGYPT , wxLayout_RightToLeft, "Arabic (Egypt)")
3444 LNG(wxLANGUAGE_ARABIC_IRAQ, "ar_IQ", LANG_ARABIC , SUBLANG_ARABIC_IRAQ , wxLayout_RightToLeft, "Arabic (Iraq)")
3445 LNG(wxLANGUAGE_ARABIC_JORDAN, "ar_JO", LANG_ARABIC , SUBLANG_ARABIC_JORDAN , wxLayout_RightToLeft, "Arabic (Jordan)")
3446 LNG(wxLANGUAGE_ARABIC_KUWAIT, "ar_KW", LANG_ARABIC , SUBLANG_ARABIC_KUWAIT , wxLayout_RightToLeft, "Arabic (Kuwait)")
3447 LNG(wxLANGUAGE_ARABIC_LEBANON, "ar_LB", LANG_ARABIC , SUBLANG_ARABIC_LEBANON , wxLayout_RightToLeft, "Arabic (Lebanon)")
3448 LNG(wxLANGUAGE_ARABIC_LIBYA, "ar_LY", LANG_ARABIC , SUBLANG_ARABIC_LIBYA , wxLayout_RightToLeft, "Arabic (Libya)")
3449 LNG(wxLANGUAGE_ARABIC_MOROCCO, "ar_MA", LANG_ARABIC , SUBLANG_ARABIC_MOROCCO , wxLayout_RightToLeft, "Arabic (Morocco)")
3450 LNG(wxLANGUAGE_ARABIC_OMAN, "ar_OM", LANG_ARABIC , SUBLANG_ARABIC_OMAN , wxLayout_RightToLeft, "Arabic (Oman)")
3451 LNG(wxLANGUAGE_ARABIC_QATAR, "ar_QA", LANG_ARABIC , SUBLANG_ARABIC_QATAR , wxLayout_RightToLeft, "Arabic (Qatar)")
3452 LNG(wxLANGUAGE_ARABIC_SAUDI_ARABIA, "ar_SA", LANG_ARABIC , SUBLANG_ARABIC_SAUDI_ARABIA , wxLayout_RightToLeft, "Arabic (Saudi Arabia)")
3453 LNG(wxLANGUAGE_ARABIC_SUDAN, "ar_SD", 0 , 0 , wxLayout_RightToLeft, "Arabic (Sudan)")
3454 LNG(wxLANGUAGE_ARABIC_SYRIA, "ar_SY", LANG_ARABIC , SUBLANG_ARABIC_SYRIA , wxLayout_RightToLeft, "Arabic (Syria)")
3455 LNG(wxLANGUAGE_ARABIC_TUNISIA, "ar_TN", LANG_ARABIC , SUBLANG_ARABIC_TUNISIA , wxLayout_RightToLeft, "Arabic (Tunisia)")
3456 LNG(wxLANGUAGE_ARABIC_UAE, "ar_AE", LANG_ARABIC , SUBLANG_ARABIC_UAE , wxLayout_RightToLeft, "Arabic (Uae)")
3457 LNG(wxLANGUAGE_ARABIC_YEMEN, "ar_YE", LANG_ARABIC , SUBLANG_ARABIC_YEMEN , wxLayout_RightToLeft, "Arabic (Yemen)")
3458 LNG(wxLANGUAGE_ARMENIAN, "hy" , LANG_ARMENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Armenian")
3459 LNG(wxLANGUAGE_ASSAMESE, "as" , LANG_ASSAMESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Assamese")
3460 LNG(wxLANGUAGE_AYMARA, "ay" , 0 , 0 , wxLayout_LeftToRight, "Aymara")
3461 LNG(wxLANGUAGE_AZERI, "az" , LANG_AZERI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Azeri")
3462 LNG(wxLANGUAGE_AZERI_CYRILLIC, "az" , LANG_AZERI , SUBLANG_AZERI_CYRILLIC , wxLayout_LeftToRight, "Azeri (Cyrillic)")
3463 LNG(wxLANGUAGE_AZERI_LATIN, "az" , LANG_AZERI , SUBLANG_AZERI_LATIN , wxLayout_LeftToRight, "Azeri (Latin)")
3464 LNG(wxLANGUAGE_BASHKIR, "ba" , 0 , 0 , wxLayout_LeftToRight, "Bashkir")
3465 LNG(wxLANGUAGE_BASQUE, "eu_ES", LANG_BASQUE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Basque")
3466 LNG(wxLANGUAGE_BELARUSIAN, "be_BY", LANG_BELARUSIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Belarusian")
3467 LNG(wxLANGUAGE_BENGALI, "bn" , LANG_BENGALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bengali")
3468 LNG(wxLANGUAGE_BHUTANI, "dz" , 0 , 0 , wxLayout_LeftToRight, "Bhutani")
3469 LNG(wxLANGUAGE_BIHARI, "bh" , 0 , 0 , wxLayout_LeftToRight, "Bihari")
3470 LNG(wxLANGUAGE_BISLAMA, "bi" , 0 , 0 , wxLayout_LeftToRight, "Bislama")
3471 LNG(wxLANGUAGE_BRETON, "br" , 0 , 0 , wxLayout_LeftToRight, "Breton")
3472 LNG(wxLANGUAGE_BULGARIAN, "bg_BG", LANG_BULGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bulgarian")
3473 LNG(wxLANGUAGE_BURMESE, "my" , 0 , 0 , wxLayout_LeftToRight, "Burmese")
3474 LNG(wxLANGUAGE_CAMBODIAN, "km" , 0 , 0 , wxLayout_LeftToRight, "Cambodian")
3475 LNG(wxLANGUAGE_CATALAN, "ca_ES", LANG_CATALAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Catalan")
3476 LNG(wxLANGUAGE_CHINESE, "zh_TW", LANG_CHINESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Chinese")
3477 LNG(wxLANGUAGE_CHINESE_SIMPLIFIED, "zh_CN", LANG_CHINESE , SUBLANG_CHINESE_SIMPLIFIED , wxLayout_LeftToRight, "Chinese (Simplified)")
3478 LNG(wxLANGUAGE_CHINESE_TRADITIONAL, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Traditional)")
3479 LNG(wxLANGUAGE_CHINESE_HONGKONG, "zh_HK", LANG_CHINESE , SUBLANG_CHINESE_HONGKONG , wxLayout_LeftToRight, "Chinese (Hongkong)")
3480 LNG(wxLANGUAGE_CHINESE_MACAU, "zh_MO", LANG_CHINESE , SUBLANG_CHINESE_MACAU , wxLayout_LeftToRight, "Chinese (Macau)")
3481 LNG(wxLANGUAGE_CHINESE_SINGAPORE, "zh_SG", LANG_CHINESE , SUBLANG_CHINESE_SINGAPORE , wxLayout_LeftToRight, "Chinese (Singapore)")
3482 LNG(wxLANGUAGE_CHINESE_TAIWAN, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Taiwan)")
3483 LNG(wxLANGUAGE_CORSICAN, "co" , 0 , 0 , wxLayout_LeftToRight, "Corsican")
3484 LNG(wxLANGUAGE_CROATIAN, "hr_HR", LANG_CROATIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Croatian")
3485 LNG(wxLANGUAGE_CZECH, "cs_CZ", LANG_CZECH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Czech")
3486 LNG(wxLANGUAGE_DANISH, "da_DK", LANG_DANISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Danish")
3487 LNG(wxLANGUAGE_DUTCH, "nl_NL", LANG_DUTCH , SUBLANG_DUTCH , wxLayout_LeftToRight, "Dutch")
3488 LNG(wxLANGUAGE_DUTCH_BELGIAN, "nl_BE", LANG_DUTCH , SUBLANG_DUTCH_BELGIAN , wxLayout_LeftToRight, "Dutch (Belgian)")
3489 LNG(wxLANGUAGE_ENGLISH, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English")
3490 LNG(wxLANGUAGE_ENGLISH_UK, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English (U.K.)")
3491 LNG(wxLANGUAGE_ENGLISH_US, "en_US", LANG_ENGLISH , SUBLANG_ENGLISH_US , wxLayout_LeftToRight, "English (U.S.)")
3492 LNG(wxLANGUAGE_ENGLISH_AUSTRALIA, "en_AU", LANG_ENGLISH , SUBLANG_ENGLISH_AUS , wxLayout_LeftToRight, "English (Australia)")
3493 LNG(wxLANGUAGE_ENGLISH_BELIZE, "en_BZ", LANG_ENGLISH , SUBLANG_ENGLISH_BELIZE , wxLayout_LeftToRight, "English (Belize)")
3494 LNG(wxLANGUAGE_ENGLISH_BOTSWANA, "en_BW", 0 , 0 , wxLayout_LeftToRight, "English (Botswana)")
3495 LNG(wxLANGUAGE_ENGLISH_CANADA, "en_CA", LANG_ENGLISH , SUBLANG_ENGLISH_CAN , wxLayout_LeftToRight, "English (Canada)")
3496 LNG(wxLANGUAGE_ENGLISH_CARIBBEAN, "en_CB", LANG_ENGLISH , SUBLANG_ENGLISH_CARIBBEAN , wxLayout_LeftToRight, "English (Caribbean)")
3497 LNG(wxLANGUAGE_ENGLISH_DENMARK, "en_DK", 0 , 0 , wxLayout_LeftToRight, "English (Denmark)")
3498 LNG(wxLANGUAGE_ENGLISH_EIRE, "en_IE", LANG_ENGLISH , SUBLANG_ENGLISH_EIRE , wxLayout_LeftToRight, "English (Eire)")
3499 LNG(wxLANGUAGE_ENGLISH_JAMAICA, "en_JM", LANG_ENGLISH , SUBLANG_ENGLISH_JAMAICA , wxLayout_LeftToRight, "English (Jamaica)")
3500 LNG(wxLANGUAGE_ENGLISH_NEW_ZEALAND, "en_NZ", LANG_ENGLISH , SUBLANG_ENGLISH_NZ , wxLayout_LeftToRight, "English (New Zealand)")
3501 LNG(wxLANGUAGE_ENGLISH_PHILIPPINES, "en_PH", LANG_ENGLISH , SUBLANG_ENGLISH_PHILIPPINES , wxLayout_LeftToRight, "English (Philippines)")
3502 LNG(wxLANGUAGE_ENGLISH_SOUTH_AFRICA, "en_ZA", LANG_ENGLISH , SUBLANG_ENGLISH_SOUTH_AFRICA , wxLayout_LeftToRight, "English (South Africa)")
3503 LNG(wxLANGUAGE_ENGLISH_TRINIDAD, "en_TT", LANG_ENGLISH , SUBLANG_ENGLISH_TRINIDAD , wxLayout_LeftToRight, "English (Trinidad)")
3504 LNG(wxLANGUAGE_ENGLISH_ZIMBABWE, "en_ZW", LANG_ENGLISH , SUBLANG_ENGLISH_ZIMBABWE , wxLayout_LeftToRight, "English (Zimbabwe)")
3505 LNG(wxLANGUAGE_ESPERANTO, "eo" , 0 , 0 , wxLayout_LeftToRight, "Esperanto")
3506 LNG(wxLANGUAGE_ESTONIAN, "et_EE", LANG_ESTONIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Estonian")
3507 LNG(wxLANGUAGE_FAEROESE, "fo_FO", LANG_FAEROESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Faeroese")
3508 LNG(wxLANGUAGE_FARSI, "fa_IR", LANG_FARSI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Farsi")
3509 LNG(wxLANGUAGE_FIJI, "fj" , 0 , 0 , wxLayout_LeftToRight, "Fiji")
3510 LNG(wxLANGUAGE_FINNISH, "fi_FI", LANG_FINNISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Finnish")
3511 LNG(wxLANGUAGE_FRENCH, "fr_FR", LANG_FRENCH , SUBLANG_FRENCH , wxLayout_LeftToRight, "French")
3512 LNG(wxLANGUAGE_FRENCH_BELGIAN, "fr_BE", LANG_FRENCH , SUBLANG_FRENCH_BELGIAN , wxLayout_LeftToRight, "French (Belgian)")
3513 LNG(wxLANGUAGE_FRENCH_CANADIAN, "fr_CA", LANG_FRENCH , SUBLANG_FRENCH_CANADIAN , wxLayout_LeftToRight, "French (Canadian)")
3514 LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , wxLayout_LeftToRight, "French (Luxembourg)")
3515 LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , wxLayout_LeftToRight, "French (Monaco)")
3516 LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , wxLayout_LeftToRight, "French (Swiss)")
3517 LNG(wxLANGUAGE_FRISIAN, "fy" , 0 , 0 , wxLayout_LeftToRight, "Frisian")
3518 LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , wxLayout_LeftToRight, "Galician")
3519 LNG(wxLANGUAGE_GEORGIAN, "ka" , LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian")
3520 LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , wxLayout_LeftToRight, "German")
3521 LNG(wxLANGUAGE_GERMAN_AUSTRIAN, "de_AT", LANG_GERMAN , SUBLANG_GERMAN_AUSTRIAN , wxLayout_LeftToRight, "German (Austrian)")
3522 LNG(wxLANGUAGE_GERMAN_BELGIUM, "de_BE", 0 , 0 , wxLayout_LeftToRight, "German (Belgium)")
3523 LNG(wxLANGUAGE_GERMAN_LIECHTENSTEIN, "de_LI", LANG_GERMAN , SUBLANG_GERMAN_LIECHTENSTEIN , wxLayout_LeftToRight, "German (Liechtenstein)")
3524 LNG(wxLANGUAGE_GERMAN_LUXEMBOURG, "de_LU", LANG_GERMAN , SUBLANG_GERMAN_LUXEMBOURG , wxLayout_LeftToRight, "German (Luxembourg)")
3525 LNG(wxLANGUAGE_GERMAN_SWISS, "de_CH", LANG_GERMAN , SUBLANG_GERMAN_SWISS , wxLayout_LeftToRight, "German (Swiss)")
3526 LNG(wxLANGUAGE_GREEK, "el_GR", LANG_GREEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Greek")
3527 LNG(wxLANGUAGE_GREENLANDIC, "kl_GL", 0 , 0 , wxLayout_LeftToRight, "Greenlandic")
3528 LNG(wxLANGUAGE_GUARANI, "gn" , 0 , 0 , wxLayout_LeftToRight, "Guarani")
3529 LNG(wxLANGUAGE_GUJARATI, "gu" , LANG_GUJARATI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Gujarati")
3530 LNG(wxLANGUAGE_HAUSA, "ha" , 0 , 0 , wxLayout_LeftToRight, "Hausa")
3531 LNG(wxLANGUAGE_HEBREW, "he_IL", LANG_HEBREW , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Hebrew")
3532 LNG(wxLANGUAGE_HINDI, "hi_IN", LANG_HINDI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hindi")
3533 LNG(wxLANGUAGE_HUNGARIAN, "hu_HU", LANG_HUNGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hungarian")
3534 LNG(wxLANGUAGE_ICELANDIC, "is_IS", LANG_ICELANDIC , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Icelandic")
3535 LNG(wxLANGUAGE_INDONESIAN, "id_ID", LANG_INDONESIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Indonesian")
3536 LNG(wxLANGUAGE_INTERLINGUA, "ia" , 0 , 0 , wxLayout_LeftToRight, "Interlingua")
3537 LNG(wxLANGUAGE_INTERLINGUE, "ie" , 0 , 0 , wxLayout_LeftToRight, "Interlingue")
3538 LNG(wxLANGUAGE_INUKTITUT, "iu" , 0 , 0 , wxLayout_LeftToRight, "Inuktitut")
3539 LNG(wxLANGUAGE_INUPIAK, "ik" , 0 , 0 , wxLayout_LeftToRight, "Inupiak")
3540 LNG(wxLANGUAGE_IRISH, "ga_IE", 0 , 0 , wxLayout_LeftToRight, "Irish")
3541 LNG(wxLANGUAGE_ITALIAN, "it_IT", LANG_ITALIAN , SUBLANG_ITALIAN , wxLayout_LeftToRight, "Italian")
3542 LNG(wxLANGUAGE_ITALIAN_SWISS, "it_CH", LANG_ITALIAN , SUBLANG_ITALIAN_SWISS , wxLayout_LeftToRight, "Italian (Swiss)")
3543 LNG(wxLANGUAGE_JAPANESE, "ja_JP", LANG_JAPANESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Japanese")
3544 LNG(wxLANGUAGE_JAVANESE, "jw" , 0 , 0 , wxLayout_LeftToRight, "Javanese")
3545 LNG(wxLANGUAGE_KANNADA, "kn" , LANG_KANNADA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kannada")
3546 LNG(wxLANGUAGE_KASHMIRI, "ks" , LANG_KASHMIRI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kashmiri")
3547 LNG(wxLANGUAGE_KASHMIRI_INDIA, "ks_IN", LANG_KASHMIRI , SUBLANG_KASHMIRI_INDIA , wxLayout_LeftToRight, "Kashmiri (India)")
3548 LNG(wxLANGUAGE_KAZAKH, "kk" , LANG_KAZAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kazakh")
3549 LNG(wxLANGUAGE_KERNEWEK, "kw_GB", 0 , 0 , wxLayout_LeftToRight, "Kernewek")
3550 LNG(wxLANGUAGE_KINYARWANDA, "rw" , 0 , 0 , wxLayout_LeftToRight, "Kinyarwanda")
3551 LNG(wxLANGUAGE_KIRGHIZ, "ky" , 0 , 0 , wxLayout_LeftToRight, "Kirghiz")
3552 LNG(wxLANGUAGE_KIRUNDI, "rn" , 0 , 0 , wxLayout_LeftToRight, "Kirundi")
3553 LNG(wxLANGUAGE_KONKANI, "" , LANG_KONKANI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Konkani")
3554 LNG(wxLANGUAGE_KOREAN, "ko_KR", LANG_KOREAN , SUBLANG_KOREAN , wxLayout_LeftToRight, "Korean")
3555 LNG(wxLANGUAGE_KURDISH, "ku" , 0 , 0 , wxLayout_LeftToRight, "Kurdish")
3556 LNG(wxLANGUAGE_LAOTHIAN, "lo" , 0 , 0 , wxLayout_LeftToRight, "Laothian")
3557 LNG(wxLANGUAGE_LATIN, "la" , 0 , 0 , wxLayout_LeftToRight, "Latin")
3558 LNG(wxLANGUAGE_LATVIAN, "lv_LV", LANG_LATVIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Latvian")
3559 LNG(wxLANGUAGE_LINGALA, "ln" , 0 , 0 , wxLayout_LeftToRight, "Lingala")
3560 LNG(wxLANGUAGE_LITHUANIAN, "lt_LT", LANG_LITHUANIAN, SUBLANG_LITHUANIAN , wxLayout_LeftToRight, "Lithuanian")
3561 LNG(wxLANGUAGE_MACEDONIAN, "mk_MK", LANG_MACEDONIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Macedonian")
3562 LNG(wxLANGUAGE_MALAGASY, "mg" , 0 , 0 , wxLayout_LeftToRight, "Malagasy")
3563 LNG(wxLANGUAGE_MALAY, "ms_MY", LANG_MALAY , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malay")
3564 LNG(wxLANGUAGE_MALAYALAM, "ml" , LANG_MALAYALAM , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malayalam")
3565 LNG(wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, "ms_BN", LANG_MALAY , SUBLANG_MALAY_BRUNEI_DARUSSALAM , wxLayout_LeftToRight, "Malay (Brunei Darussalam)")
3566 LNG(wxLANGUAGE_MALAY_MALAYSIA, "ms_MY", LANG_MALAY , SUBLANG_MALAY_MALAYSIA , wxLayout_LeftToRight, "Malay (Malaysia)")
3567 LNG(wxLANGUAGE_MALTESE, "mt_MT", 0 , 0 , wxLayout_LeftToRight, "Maltese")
3568 LNG(wxLANGUAGE_MANIPURI, "" , LANG_MANIPURI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Manipuri")
3569 LNG(wxLANGUAGE_MAORI, "mi" , 0 , 0 , wxLayout_LeftToRight, "Maori")
3570 LNG(wxLANGUAGE_MARATHI, "mr_IN", LANG_MARATHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Marathi")
3571 LNG(wxLANGUAGE_MOLDAVIAN, "mo" , 0 , 0 , wxLayout_LeftToRight, "Moldavian")
3572 LNG(wxLANGUAGE_MONGOLIAN, "mn" , 0 , 0 , wxLayout_LeftToRight, "Mongolian")
3573 LNG(wxLANGUAGE_NAURU, "na" , 0 , 0 , wxLayout_LeftToRight, "Nauru")
3574 LNG(wxLANGUAGE_NEPALI, "ne" , LANG_NEPALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Nepali")
3575 LNG(wxLANGUAGE_NEPALI_INDIA, "ne_IN", LANG_NEPALI , SUBLANG_NEPALI_INDIA , wxLayout_LeftToRight, "Nepali (India)")
3576 LNG(wxLANGUAGE_NORWEGIAN_BOKMAL, "nb_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_BOKMAL , wxLayout_LeftToRight, "Norwegian (Bokmal)")
3577 LNG(wxLANGUAGE_NORWEGIAN_NYNORSK, "nn_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_NYNORSK , wxLayout_LeftToRight, "Norwegian (Nynorsk)")
3578 LNG(wxLANGUAGE_OCCITAN, "oc" , 0 , 0 , wxLayout_LeftToRight, "Occitan")
3579 LNG(wxLANGUAGE_ORIYA, "or" , LANG_ORIYA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Oriya")
3580 LNG(wxLANGUAGE_OROMO, "om" , 0 , 0 , wxLayout_LeftToRight, "(Afan) Oromo")
3581 LNG(wxLANGUAGE_PASHTO, "ps" , 0 , 0 , wxLayout_LeftToRight, "Pashto, Pushto")
3582 LNG(wxLANGUAGE_POLISH, "pl_PL", LANG_POLISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Polish")
3583 LNG(wxLANGUAGE_PORTUGUESE, "pt_PT", LANG_PORTUGUESE, SUBLANG_PORTUGUESE , wxLayout_LeftToRight, "Portuguese")
3584 LNG(wxLANGUAGE_PORTUGUESE_BRAZILIAN, "pt_BR", LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN , wxLayout_LeftToRight, "Portuguese (Brazilian)")
3585 LNG(wxLANGUAGE_PUNJABI, "pa" , LANG_PUNJABI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Punjabi")
3586 LNG(wxLANGUAGE_QUECHUA, "qu" , 0 , 0 , wxLayout_LeftToRight, "Quechua")
3587 LNG(wxLANGUAGE_RHAETO_ROMANCE, "rm" , 0 , 0 , wxLayout_LeftToRight, "Rhaeto-Romance")
3588 LNG(wxLANGUAGE_ROMANIAN, "ro_RO", LANG_ROMANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Romanian")
3589 LNG(wxLANGUAGE_RUSSIAN, "ru_RU", LANG_RUSSIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Russian")
3590 LNG(wxLANGUAGE_RUSSIAN_UKRAINE, "ru_UA", 0 , 0 , wxLayout_LeftToRight, "Russian (Ukraine)")
3591 LNG(wxLANGUAGE_SAMOAN, "sm" , 0 , 0 , wxLayout_LeftToRight, "Samoan")
3592 LNG(wxLANGUAGE_SANGHO, "sg" , 0 , 0 , wxLayout_LeftToRight, "Sangho")
3593 LNG(wxLANGUAGE_SANSKRIT, "sa" , LANG_SANSKRIT , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sanskrit")
3594 LNG(wxLANGUAGE_SCOTS_GAELIC, "gd" , 0 , 0 , wxLayout_LeftToRight, "Scots Gaelic")
3595 LNG(wxLANGUAGE_SERBIAN_CYRILLIC, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_CYRILLIC , wxLayout_LeftToRight, "Serbian (Cyrillic)")
3596 LNG(wxLANGUAGE_SERBIAN_LATIN, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_LATIN , wxLayout_LeftToRight, "Serbian (Latin)")
3597 LNG(wxLANGUAGE_SERBO_CROATIAN, "sh" , 0 , 0 , wxLayout_LeftToRight, "Serbo-Croatian")
3598 LNG(wxLANGUAGE_SESOTHO, "st" , 0 , 0 , wxLayout_LeftToRight, "Sesotho")
3599 LNG(wxLANGUAGE_SETSWANA, "tn" , 0 , 0 , wxLayout_LeftToRight, "Setswana")
3600 LNG(wxLANGUAGE_SHONA, "sn" , 0 , 0 , wxLayout_LeftToRight, "Shona")
3601 LNG(wxLANGUAGE_SINDHI, "sd" , LANG_SINDHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sindhi")
3602 LNG(wxLANGUAGE_SINHALESE, "si" , 0 , 0 , wxLayout_LeftToRight, "Sinhalese")
3603 LNG(wxLANGUAGE_SISWATI, "ss" , 0 , 0 , wxLayout_LeftToRight, "Siswati")
3604 LNG(wxLANGUAGE_SLOVAK, "sk_SK", LANG_SLOVAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovak")
3605 LNG(wxLANGUAGE_SLOVENIAN, "sl_SI", LANG_SLOVENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovenian")
3606 LNG(wxLANGUAGE_SOMALI, "so" , 0 , 0 , wxLayout_LeftToRight, "Somali")
3607 LNG(wxLANGUAGE_SPANISH, "es_ES", LANG_SPANISH , SUBLANG_SPANISH , wxLayout_LeftToRight, "Spanish")
3608 LNG(wxLANGUAGE_SPANISH_ARGENTINA, "es_AR", LANG_SPANISH , SUBLANG_SPANISH_ARGENTINA , wxLayout_LeftToRight, "Spanish (Argentina)")
3609 LNG(wxLANGUAGE_SPANISH_BOLIVIA, "es_BO", LANG_SPANISH , SUBLANG_SPANISH_BOLIVIA , wxLayout_LeftToRight, "Spanish (Bolivia)")
3610 LNG(wxLANGUAGE_SPANISH_CHILE, "es_CL", LANG_SPANISH , SUBLANG_SPANISH_CHILE , wxLayout_LeftToRight, "Spanish (Chile)")
3611 LNG(wxLANGUAGE_SPANISH_COLOMBIA, "es_CO", LANG_SPANISH , SUBLANG_SPANISH_COLOMBIA , wxLayout_LeftToRight, "Spanish (Colombia)")
3612 LNG(wxLANGUAGE_SPANISH_COSTA_RICA, "es_CR", LANG_SPANISH , SUBLANG_SPANISH_COSTA_RICA , wxLayout_LeftToRight, "Spanish (Costa Rica)")
3613 LNG(wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, "es_DO", LANG_SPANISH , SUBLANG_SPANISH_DOMINICAN_REPUBLIC, wxLayout_LeftToRight, "Spanish (Dominican republic)")
3614 LNG(wxLANGUAGE_SPANISH_ECUADOR, "es_EC", LANG_SPANISH , SUBLANG_SPANISH_ECUADOR , wxLayout_LeftToRight, "Spanish (Ecuador)")
3615 LNG(wxLANGUAGE_SPANISH_EL_SALVADOR, "es_SV", LANG_SPANISH , SUBLANG_SPANISH_EL_SALVADOR , wxLayout_LeftToRight, "Spanish (El Salvador)")
3616 LNG(wxLANGUAGE_SPANISH_GUATEMALA, "es_GT", LANG_SPANISH , SUBLANG_SPANISH_GUATEMALA , wxLayout_LeftToRight, "Spanish (Guatemala)")
3617 LNG(wxLANGUAGE_SPANISH_HONDURAS, "es_HN", LANG_SPANISH , SUBLANG_SPANISH_HONDURAS , wxLayout_LeftToRight, "Spanish (Honduras)")
3618 LNG(wxLANGUAGE_SPANISH_MEXICAN, "es_MX", LANG_SPANISH , SUBLANG_SPANISH_MEXICAN , wxLayout_LeftToRight, "Spanish (Mexican)")
3619 LNG(wxLANGUAGE_SPANISH_MODERN, "es_ES", LANG_SPANISH , SUBLANG_SPANISH_MODERN , wxLayout_LeftToRight, "Spanish (Modern)")
3620 LNG(wxLANGUAGE_SPANISH_NICARAGUA, "es_NI", LANG_SPANISH , SUBLANG_SPANISH_NICARAGUA , wxLayout_LeftToRight, "Spanish (Nicaragua)")
3621 LNG(wxLANGUAGE_SPANISH_PANAMA, "es_PA", LANG_SPANISH , SUBLANG_SPANISH_PANAMA , wxLayout_LeftToRight, "Spanish (Panama)")
3622 LNG(wxLANGUAGE_SPANISH_PARAGUAY, "es_PY", LANG_SPANISH , SUBLANG_SPANISH_PARAGUAY , wxLayout_LeftToRight, "Spanish (Paraguay)")
3623 LNG(wxLANGUAGE_SPANISH_PERU, "es_PE", LANG_SPANISH , SUBLANG_SPANISH_PERU , wxLayout_LeftToRight, "Spanish (Peru)")
3624 LNG(wxLANGUAGE_SPANISH_PUERTO_RICO, "es_PR", LANG_SPANISH , SUBLANG_SPANISH_PUERTO_RICO , wxLayout_LeftToRight, "Spanish (Puerto Rico)")
3625 LNG(wxLANGUAGE_SPANISH_URUGUAY, "es_UY", LANG_SPANISH , SUBLANG_SPANISH_URUGUAY , wxLayout_LeftToRight, "Spanish (Uruguay)")
3626 LNG(wxLANGUAGE_SPANISH_US, "es_US", 0 , 0 , wxLayout_LeftToRight, "Spanish (U.S.)")
3627 LNG(wxLANGUAGE_SPANISH_VENEZUELA, "es_VE", LANG_SPANISH , SUBLANG_SPANISH_VENEZUELA , wxLayout_LeftToRight, "Spanish (Venezuela)")
3628 LNG(wxLANGUAGE_SUNDANESE, "su" , 0 , 0 , wxLayout_LeftToRight, "Sundanese")
3629 LNG(wxLANGUAGE_SWAHILI, "sw_KE", LANG_SWAHILI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Swahili")
3630 LNG(wxLANGUAGE_SWEDISH, "sv_SE", LANG_SWEDISH , SUBLANG_SWEDISH , wxLayout_LeftToRight, "Swedish")
3631 LNG(wxLANGUAGE_SWEDISH_FINLAND, "sv_FI", LANG_SWEDISH , SUBLANG_SWEDISH_FINLAND , wxLayout_LeftToRight, "Swedish (Finland)")
3632 LNG(wxLANGUAGE_TAGALOG, "tl_PH", 0 , 0 , wxLayout_LeftToRight, "Tagalog")
3633 LNG(wxLANGUAGE_TAJIK, "tg" , 0 , 0 , wxLayout_LeftToRight, "Tajik")
3634 LNG(wxLANGUAGE_TAMIL, "ta" , LANG_TAMIL , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tamil")
3635 LNG(wxLANGUAGE_TATAR, "tt" , LANG_TATAR , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tatar")
3636 LNG(wxLANGUAGE_TELUGU, "te" , LANG_TELUGU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Telugu")
3637 LNG(wxLANGUAGE_THAI, "th_TH", LANG_THAI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Thai")
3638 LNG(wxLANGUAGE_TIBETAN, "bo" , 0 , 0 , wxLayout_LeftToRight, "Tibetan")
3639 LNG(wxLANGUAGE_TIGRINYA, "ti" , 0 , 0 , wxLayout_LeftToRight, "Tigrinya")
3640 LNG(wxLANGUAGE_TONGA, "to" , 0 , 0 , wxLayout_LeftToRight, "Tonga")
3641 LNG(wxLANGUAGE_TSONGA, "ts" , 0 , 0 , wxLayout_LeftToRight, "Tsonga")
3642 LNG(wxLANGUAGE_TURKISH, "tr_TR", LANG_TURKISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Turkish")
3643 LNG(wxLANGUAGE_TURKMEN, "tk" , 0 , 0 , wxLayout_LeftToRight, "Turkmen")
3644 LNG(wxLANGUAGE_TWI, "tw" , 0 , 0 , wxLayout_LeftToRight, "Twi")
3645 LNG(wxLANGUAGE_UIGHUR, "ug" , 0 , 0 , wxLayout_LeftToRight, "Uighur")
3646 LNG(wxLANGUAGE_UKRAINIAN, "uk_UA", LANG_UKRAINIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Ukrainian")
3647 LNG(wxLANGUAGE_URDU, "ur" , LANG_URDU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Urdu")
3648 LNG(wxLANGUAGE_URDU_INDIA, "ur_IN", LANG_URDU , SUBLANG_URDU_INDIA , wxLayout_LeftToRight, "Urdu (India)")
3649 LNG(wxLANGUAGE_URDU_PAKISTAN, "ur_PK", LANG_URDU , SUBLANG_URDU_PAKISTAN , wxLayout_LeftToRight, "Urdu (Pakistan)")
3650 LNG(wxLANGUAGE_UZBEK, "uz" , LANG_UZBEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Uzbek")
3651 LNG(wxLANGUAGE_UZBEK_CYRILLIC, "uz" , LANG_UZBEK , SUBLANG_UZBEK_CYRILLIC , wxLayout_LeftToRight, "Uzbek (Cyrillic)")
3652 LNG(wxLANGUAGE_UZBEK_LATIN, "uz" , LANG_UZBEK , SUBLANG_UZBEK_LATIN , wxLayout_LeftToRight, "Uzbek (Latin)")
3653 LNG(wxLANGUAGE_VIETNAMESE, "vi_VN", LANG_VIETNAMESE, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Vietnamese")
3654 LNG(wxLANGUAGE_VOLAPUK, "vo" , 0 , 0 , wxLayout_LeftToRight, "Volapuk")
3655 LNG(wxLANGUAGE_WELSH, "cy" , 0 , 0 , wxLayout_LeftToRight, "Welsh")
3656 LNG(wxLANGUAGE_WOLOF, "wo" , 0 , 0 , wxLayout_LeftToRight, "Wolof")
3657 LNG(wxLANGUAGE_XHOSA, "xh" , 0 , 0 , wxLayout_LeftToRight, "Xhosa")
3658 LNG(wxLANGUAGE_YIDDISH, "yi" , 0 , 0 , wxLayout_LeftToRight, "Yiddish")
3659 LNG(wxLANGUAGE_YORUBA, "yo" , 0 , 0 , wxLayout_LeftToRight, "Yoruba")
3660 LNG(wxLANGUAGE_ZHUANG, "za" , 0 , 0 , wxLayout_LeftToRight, "Zhuang")
3661 LNG(wxLANGUAGE_ZULU, "zu" , 0 , 0 , wxLayout_LeftToRight, "Zulu")
4115960d 3662}
d3f3e35f
VS
3663#undef LNG
3664
41780009
VS
3665// --- --- --- generated code ends here --- --- ---
3666
d427503c 3667#endif // wxUSE_INTL