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