]> git.saurik.com Git - wxWidgets.git/blob - src/common/intl.cpp
Cache user and group name as these can be expensive to get on some systems.
[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 // Search first in Unix-standard prefix/lang/LC_MESSAGES, then in
1021 // prefix/lang and finally in just prefix.
1022 //
1023 // Note that we use LC_MESSAGES on all platforms and not just Unix, because
1024 // it doesn't cost much to look into one more directory and doing it this
1025 // way has two important benefits:
1026 // a) we don't break compatibility with wx-2.6 and older by stopping to
1027 // look in a directory where the catalogs used to be and thus silently
1028 // breaking apps after they are recompiled against the latest wx
1029 // b) it makes it possible to package app's support files in the same
1030 // way on all target platforms
1031 wxString pathPrefix;
1032 pathPrefix << prefix << wxFILE_SEP_PATH << lang;
1033
1034 wxString searchPath;
1035 searchPath.reserve(4*pathPrefix.length());
1036 searchPath << pathPrefix << wxFILE_SEP_PATH << "LC_MESSAGES" << wxPATH_SEP
1037 << prefix << wxFILE_SEP_PATH << wxPATH_SEP
1038 << pathPrefix;
1039
1040 return searchPath;
1041 }
1042
1043 // construct the search path for the given language
1044 static wxString GetFullSearchPath(const wxString& lang)
1045 {
1046 // first take the entries explicitly added by the program
1047 wxArrayString paths;
1048 paths.reserve(gs_searchPrefixes.size() + 1);
1049 size_t n,
1050 count = gs_searchPrefixes.size();
1051 for ( n = 0; n < count; n++ )
1052 {
1053 paths.Add(GetMsgCatalogSubdirs(gs_searchPrefixes[n], lang));
1054 }
1055
1056
1057 #if wxUSE_STDPATHS
1058 // then look in the standard location
1059 const wxString stdp = wxStandardPaths::Get().
1060 GetLocalizedResourcesDir(lang, wxStandardPaths::ResourceCat_Messages);
1061
1062 if ( paths.Index(stdp) == wxNOT_FOUND )
1063 paths.Add(stdp);
1064 #endif // wxUSE_STDPATHS
1065
1066 // last look in default locations
1067 #ifdef __UNIX__
1068 // LC_PATH is a standard env var containing the search path for the .mo
1069 // files
1070 const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH"));
1071 if ( pszLcPath )
1072 {
1073 const wxString lcp = GetMsgCatalogSubdirs(pszLcPath, lang);
1074 if ( paths.Index(lcp) == wxNOT_FOUND )
1075 paths.Add(lcp);
1076 }
1077
1078 // also add the one from where wxWin was installed:
1079 wxString wxp = wxGetInstallPrefix();
1080 if ( !wxp.empty() )
1081 {
1082 wxp = GetMsgCatalogSubdirs(wxp + _T("/share/locale"), lang);
1083 if ( paths.Index(wxp) == wxNOT_FOUND )
1084 paths.Add(wxp);
1085 }
1086 #endif // __UNIX__
1087
1088
1089 // finally construct the full search path
1090 wxString searchPath;
1091 searchPath.reserve(500);
1092 count = paths.size();
1093 for ( n = 0; n < count; n++ )
1094 {
1095 searchPath += paths[n];
1096 if ( n != count - 1 )
1097 searchPath += wxPATH_SEP;
1098 }
1099
1100 return searchPath;
1101 }
1102
1103 // open disk file and read in it's contents
1104 bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
1105 wxPluralFormsCalculatorPtr& rPluralFormsCalculator)
1106 {
1107 wxString searchPath;
1108
1109 #if wxUSE_FONTMAP
1110 // first look for the catalog for this language and the current locale:
1111 // notice that we don't use the system name for the locale as this would
1112 // force us to install catalogs in different locations depending on the
1113 // system but always use the canonical name
1114 wxFontEncoding encSys = wxLocale::GetSystemEncoding();
1115 if ( encSys != wxFONTENCODING_SYSTEM )
1116 {
1117 wxString fullname(szDirPrefix);
1118 fullname << _T('.') << wxFontMapperBase::GetEncodingName(encSys);
1119 searchPath << GetFullSearchPath(fullname) << wxPATH_SEP;
1120 }
1121 #endif // wxUSE_FONTMAP
1122
1123
1124 searchPath += GetFullSearchPath(szDirPrefix);
1125 size_t sublocaleIndex = szDirPrefix.find(wxT('_'));
1126 if ( sublocaleIndex != wxString::npos )
1127 {
1128 // also add just base locale name: for things like "fr_BE" (belgium
1129 // french) we should use "fr" if no belgium specific message catalogs
1130 // exist
1131 searchPath << wxPATH_SEP
1132 << GetFullSearchPath(szDirPrefix.Left(sublocaleIndex));
1133 }
1134
1135 // don't give translation errors here because the wxstd catalog might
1136 // not yet be loaded (and it's normal)
1137 //
1138 // (we're using an object because we have several return paths)
1139
1140 NoTransErr noTransErr;
1141 wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
1142 szName, searchPath.c_str());
1143 wxLogTrace(TRACE_I18N, _T("Looking for \"%s.mo\" in \"%s\""),
1144 szName, searchPath.c_str());
1145
1146 wxFileName fn(szName);
1147 fn.SetExt(_T("mo"));
1148 wxString strFullName;
1149 if ( !wxFindFileInPath(&strFullName, searchPath, fn.GetFullPath()) ) {
1150 wxLogVerbose(_("catalog file for domain '%s' not found."), szName);
1151 wxLogTrace(TRACE_I18N, _T("Catalog \"%s.mo\" not found"), szName);
1152 return false;
1153 }
1154
1155 // open file
1156 wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str());
1157 wxLogTrace(TRACE_I18N, _T("Using catalog \"%s\"."), strFullName.c_str());
1158
1159 wxFile fileMsg(strFullName);
1160 if ( !fileMsg.IsOpened() )
1161 return false;
1162
1163 // get the file size (assume it is less than 4Gb...)
1164 wxFileOffset lenFile = fileMsg.Length();
1165 if ( lenFile == wxInvalidOffset )
1166 return false;
1167
1168 size_t nSize = wx_truncate_cast(size_t, lenFile);
1169 wxASSERT_MSG( nSize == lenFile + size_t(0), _T("message catalog bigger than 4GB?") );
1170
1171 // read the whole file in memory
1172 m_pData = new size_t8[nSize];
1173 if ( fileMsg.Read(m_pData, nSize) != lenFile ) {
1174 wxDELETEA(m_pData);
1175 return false;
1176 }
1177
1178 // examine header
1179 bool bValid = nSize + (size_t)0 > sizeof(wxMsgCatalogHeader);
1180
1181 wxMsgCatalogHeader *pHeader = (wxMsgCatalogHeader *)m_pData;
1182 if ( bValid ) {
1183 // we'll have to swap all the integers if it's true
1184 m_bSwapped = pHeader->magic == MSGCATALOG_MAGIC_SW;
1185
1186 // check the magic number
1187 bValid = m_bSwapped || pHeader->magic == MSGCATALOG_MAGIC;
1188 }
1189
1190 if ( !bValid ) {
1191 // it's either too short or has incorrect magic number
1192 wxLogWarning(_("'%s' is not a valid message catalog."), strFullName.c_str());
1193
1194 wxDELETEA(m_pData);
1195 return false;
1196 }
1197
1198 // initialize
1199 m_numStrings = Swap(pHeader->numStrings);
1200 m_pOrigTable = (wxMsgTableEntry *)(m_pData +
1201 Swap(pHeader->ofsOrigTable));
1202 m_pTransTable = (wxMsgTableEntry *)(m_pData +
1203 Swap(pHeader->ofsTransTable));
1204 m_nSize = (size_t32)nSize;
1205
1206 // now parse catalog's header and try to extract catalog charset and
1207 // plural forms formula from it:
1208
1209 const char* headerData = StringAtOfs(m_pOrigTable, 0);
1210 if (headerData && headerData[0] == 0)
1211 {
1212 // Extract the charset:
1213 wxString header = wxString::FromAscii(StringAtOfs(m_pTransTable, 0));
1214 int begin = header.Find(wxT("Content-Type: text/plain; charset="));
1215 if (begin != wxNOT_FOUND)
1216 {
1217 begin += 34; //strlen("Content-Type: text/plain; charset=")
1218 size_t end = header.find('\n', begin);
1219 if (end != size_t(-1))
1220 {
1221 m_charset.assign(header, begin, end - begin);
1222 if (m_charset == wxT("CHARSET"))
1223 {
1224 // "CHARSET" is not valid charset, but lazy translator
1225 m_charset.Clear();
1226 }
1227 }
1228 }
1229 // else: incorrectly filled Content-Type header
1230
1231 // Extract plural forms:
1232 begin = header.Find(wxT("Plural-Forms:"));
1233 if (begin != wxNOT_FOUND)
1234 {
1235 begin += 13;
1236 size_t end = header.find('\n', begin);
1237 if (end != size_t(-1))
1238 {
1239 wxString pfs(header, begin, end - begin);
1240 wxPluralFormsCalculator* pCalculator = wxPluralFormsCalculator
1241 ::make(pfs.ToAscii());
1242 if (pCalculator != 0)
1243 {
1244 rPluralFormsCalculator.reset(pCalculator);
1245 }
1246 else
1247 {
1248 wxLogVerbose(_("Cannot parse Plural-Forms:'%s'"), pfs.c_str());
1249 }
1250 }
1251 }
1252 if (rPluralFormsCalculator.get() == NULL)
1253 {
1254 rPluralFormsCalculator.reset(wxPluralFormsCalculator::make());
1255 }
1256 }
1257
1258 // everything is fine
1259 return true;
1260 }
1261
1262 void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
1263 const wxString& msgIdCharset,
1264 bool convertEncoding) const
1265 {
1266 #if wxUSE_UNICODE
1267 // this parameter doesn't make sense, we always must convert encoding in
1268 // Unicode build
1269 convertEncoding = true;
1270 #elif wxUSE_FONTMAP
1271 if ( convertEncoding )
1272 {
1273 // determine if we need any conversion at all
1274 wxFontEncoding encCat = wxFontMapperBase::GetEncodingFromName(m_charset);
1275 if ( encCat == wxLocale::GetSystemEncoding() )
1276 {
1277 // no need to convert
1278 convertEncoding = false;
1279 }
1280 }
1281 #endif // wxUSE_UNICODE/wxUSE_FONTMAP
1282
1283 #if wxUSE_WCHAR_T
1284 // conversion to use to convert catalog strings to the GUI encoding
1285 wxMBConv *inputConv,
1286 *inputConvPtr = NULL; // same as inputConv but safely deleteable
1287 if ( convertEncoding && !m_charset.empty() )
1288 {
1289 inputConvPtr =
1290 inputConv = new wxCSConv(m_charset);
1291 }
1292 else // no need or not possible to convert the encoding
1293 {
1294 #if wxUSE_UNICODE
1295 // we must somehow convert the narrow strings in the message catalog to
1296 // wide strings, so use the default conversion if we have no charset
1297 inputConv = wxConvCurrent;
1298 #else // !wxUSE_UNICODE
1299 inputConv = NULL;
1300 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
1301 }
1302
1303 // conversion to apply to msgid strings before looking them up: we only
1304 // need it if the msgids are neither in 7 bit ASCII nor in the same
1305 // encoding as the catalog
1306 wxCSConv *sourceConv = msgIdCharset.empty() || (msgIdCharset == m_charset)
1307 ? NULL
1308 : new wxCSConv(msgIdCharset);
1309
1310 #elif wxUSE_FONTMAP
1311 wxASSERT_MSG( msgIdCharset.empty(),
1312 _T("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
1313
1314 wxEncodingConverter converter;
1315 if ( convertEncoding )
1316 {
1317 wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM;
1318 wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(m_charset, false);
1319 if ( enc == wxFONTENCODING_SYSTEM )
1320 {
1321 convertEncoding = false; // unknown encoding
1322 }
1323 else
1324 {
1325 targetEnc = wxLocale::GetSystemEncoding();
1326 if (targetEnc == wxFONTENCODING_SYSTEM)
1327 {
1328 wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc);
1329 if (a[0] == enc)
1330 // no conversion needed, locale uses native encoding
1331 convertEncoding = false;
1332 if (a.GetCount() == 0)
1333 // we don't know common equiv. under this platform
1334 convertEncoding = false;
1335 targetEnc = a[0];
1336 }
1337 }
1338
1339 if ( convertEncoding )
1340 {
1341 converter.Init(enc, targetEnc);
1342 }
1343 }
1344 #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
1345 (void)convertEncoding; // get rid of warnings about unused parameter
1346
1347 for (size_t32 i = 0; i < m_numStrings; i++)
1348 {
1349 const char *data = StringAtOfs(m_pOrigTable, i);
1350
1351 wxString msgid;
1352 #if wxUSE_UNICODE
1353 msgid = wxString(data, *inputConv);
1354 #else // ASCII
1355 #if wxUSE_WCHAR_T
1356 if ( inputConv && sourceConv )
1357 msgid = wxString(inputConv->cMB2WC(data), *sourceConv);
1358 else
1359 #endif
1360 msgid = data;
1361 #endif // wxUSE_UNICODE
1362
1363 data = StringAtOfs(m_pTransTable, i);
1364 size_t length = Swap(m_pTransTable[i].nLen);
1365 size_t offset = 0;
1366 size_t index = 0;
1367 while (offset < length)
1368 {
1369 const char * const str = data + offset;
1370
1371 wxString msgstr;
1372 #if wxUSE_UNICODE
1373 msgstr = wxString(str, *inputConv);
1374 #elif wxUSE_WCHAR_T
1375 if ( inputConv )
1376 msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI);
1377 else
1378 msgstr = str;
1379 #else // !wxUSE_WCHAR_T
1380 #if wxUSE_FONTMAP
1381 if ( bConvertEncoding )
1382 msgstr = wxString(converter.Convert(str));
1383 else
1384 #endif
1385 msgstr = str;
1386 #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
1387
1388 if ( !msgstr.empty() )
1389 {
1390 hash[index == 0 ? msgid : msgid + wxChar(index)] = msgstr;
1391 }
1392
1393 // skip this string
1394 offset += strlen(str) + 1;
1395 ++index;
1396 }
1397 }
1398
1399 #if wxUSE_WCHAR_T
1400 delete sourceConv;
1401 delete inputConvPtr;
1402 #endif // wxUSE_WCHAR_T
1403 }
1404
1405
1406 // ----------------------------------------------------------------------------
1407 // wxMsgCatalog class
1408 // ----------------------------------------------------------------------------
1409
1410 wxMsgCatalog::~wxMsgCatalog()
1411 {
1412 if ( m_conv )
1413 {
1414 if ( wxConvUI == m_conv )
1415 {
1416 // we only change wxConvUI if it points to wxConvLocal so we reset
1417 // it back to it too
1418 wxConvUI = &wxConvLocal;
1419 }
1420
1421 delete m_conv;
1422 }
1423 }
1424
1425 bool wxMsgCatalog::Load(const wxString& dirPrefix, const wxString& name,
1426 const wxString& msgIdCharset, bool bConvertEncoding)
1427 {
1428 wxMsgCatalogFile file;
1429
1430 m_name = name;
1431
1432 if ( !file.Load(dirPrefix, name, m_pluralFormsCalculator) )
1433 return false;
1434
1435 file.FillHash(m_messages, msgIdCharset, bConvertEncoding);
1436
1437 // we should use a conversion compatible with the message catalog encoding
1438 // in the GUI if we don't convert the strings to the current conversion but
1439 // as the encoding is global, only change it once, otherwise we could get
1440 // into trouble if we use several message catalogs with different encodings
1441 //
1442 // this is, of course, a hack but it at least allows the program to use
1443 // message catalogs in any encodings without asking the user to change his
1444 // locale
1445 if ( !bConvertEncoding &&
1446 !file.GetCharset().empty() &&
1447 wxConvUI == &wxConvLocal )
1448 {
1449 wxConvUI =
1450 m_conv = new wxCSConv(file.GetCharset());
1451 }
1452
1453 return true;
1454 }
1455
1456 const wxString *wxMsgCatalog::GetString(const wxString& str, size_t n) const
1457 {
1458 int index = 0;
1459 if (n != size_t(-1))
1460 {
1461 index = m_pluralFormsCalculator->evaluate(n);
1462 }
1463 wxMessagesHash::const_iterator i;
1464 if (index != 0)
1465 {
1466 i = m_messages.find(wxString(str) + wxChar(index)); // plural
1467 }
1468 else
1469 {
1470 i = m_messages.find(str);
1471 }
1472
1473 if ( i != m_messages.end() )
1474 {
1475 return &i->second;
1476 }
1477 else
1478 return NULL;
1479 }
1480
1481 // ----------------------------------------------------------------------------
1482 // wxLocale
1483 // ----------------------------------------------------------------------------
1484
1485 #include "wx/arrimpl.cpp"
1486 WX_DECLARE_EXPORTED_OBJARRAY(wxLanguageInfo, wxLanguageInfoArray);
1487 WX_DEFINE_OBJARRAY(wxLanguageInfoArray)
1488
1489 wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL;
1490
1491 /*static*/ void wxLocale::CreateLanguagesDB()
1492 {
1493 if (ms_languagesDB == NULL)
1494 {
1495 ms_languagesDB = new wxLanguageInfoArray;
1496 InitLanguagesDB();
1497 }
1498 }
1499
1500 /*static*/ void wxLocale::DestroyLanguagesDB()
1501 {
1502 delete ms_languagesDB;
1503 ms_languagesDB = NULL;
1504 }
1505
1506
1507 void wxLocale::DoCommonInit()
1508 {
1509 m_pszOldLocale = NULL;
1510
1511 m_pOldLocale = wxSetLocale(this);
1512
1513 m_pMsgCat = NULL;
1514 m_language = wxLANGUAGE_UNKNOWN;
1515 m_initialized = false;
1516 }
1517
1518 // NB: this function has (desired) side effect of changing current locale
1519 bool wxLocale::Init(const wxString& name,
1520 const wxString& shortName,
1521 const wxString& locale,
1522 bool bLoadDefault,
1523 bool bConvertEncoding)
1524 {
1525 wxASSERT_MSG( !m_initialized,
1526 _T("you can't call wxLocale::Init more than once") );
1527
1528 m_initialized = true;
1529 m_strLocale = name;
1530 m_strShort = shortName;
1531 m_bConvertEncoding = bConvertEncoding;
1532 m_language = wxLANGUAGE_UNKNOWN;
1533
1534 // change current locale (default: same as long name)
1535 wxString szLocale(locale);
1536 if ( szLocale.empty() )
1537 {
1538 // the argument to setlocale()
1539 szLocale = shortName;
1540
1541 wxCHECK_MSG( !szLocale.empty(), false,
1542 _T("no locale to set in wxLocale::Init()") );
1543 }
1544
1545 #ifdef __WXWINCE__
1546 // FIXME: I'm guessing here
1547 wxChar localeName[256];
1548 int ret = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, localeName,
1549 256);
1550 if (ret != 0)
1551 {
1552 m_pszOldLocale = wxStrdup(wxConvLibc.cWC2MB(localeName));
1553 }
1554 else
1555 m_pszOldLocale = NULL;
1556
1557 // TODO: how to find languageId
1558 // SetLocaleInfo(languageId, SORT_DEFAULT, localeName);
1559 #else
1560 const char *oldLocale = wxSetlocale(LC_ALL, szLocale);
1561 if ( oldLocale )
1562 m_pszOldLocale = wxStrdup(oldLocale);
1563 else
1564 m_pszOldLocale = NULL;
1565 #endif
1566
1567 if ( m_pszOldLocale == NULL )
1568 wxLogError(_("locale '%s' can not be set."), szLocale);
1569
1570 // the short name will be used to look for catalog files as well,
1571 // so we need something here
1572 if ( m_strShort.empty() ) {
1573 // FIXME I don't know how these 2 letter abbreviations are formed,
1574 // this wild guess is surely wrong
1575 if ( !szLocale.empty() )
1576 {
1577 m_strShort += (wxChar)wxTolower(szLocale[0]);
1578 if ( szLocale.length() > 1 )
1579 m_strShort += (wxChar)wxTolower(szLocale[1]);
1580 }
1581 }
1582
1583 // load the default catalog with wxWidgets standard messages
1584 m_pMsgCat = NULL;
1585 bool bOk = true;
1586 if ( bLoadDefault )
1587 {
1588 bOk = AddCatalog(wxT("wxstd"));
1589
1590 // there may be a catalog with toolkit specific overrides, it is not
1591 // an error if this does not exist
1592 if ( bOk )
1593 {
1594 wxString port(wxPlatformInfo::Get().GetPortIdName());
1595 if ( !port.empty() )
1596 {
1597 AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
1598 }
1599 }
1600 }
1601
1602 return bOk;
1603 }
1604
1605
1606 #if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WXMAC__)
1607 static const char *wxSetlocaleTryUTF8(int c, const wxString& lc)
1608 {
1609 const char *l = NULL;
1610
1611 // NB: We prefer to set UTF-8 locale if it's possible and only fall back to
1612 // non-UTF-8 locale if it fails
1613
1614 if ( !lc.empty() )
1615 {
1616 wxString buf(lc);
1617 wxString buf2;
1618 buf2 = buf + wxT(".UTF-8");
1619 l = wxSetlocale(c, buf2);
1620 if ( !l )
1621 {
1622 buf2 = buf + wxT(".utf-8");
1623 l = wxSetlocale(c, buf2);
1624 }
1625 if ( !l )
1626 {
1627 buf2 = buf + wxT(".UTF8");
1628 l = wxSetlocale(c, buf2);
1629 }
1630 if ( !l )
1631 {
1632 buf2 = buf + wxT(".utf8");
1633 l = wxSetlocale(c, buf2);
1634 }
1635 }
1636
1637 // if we can't set UTF-8 locale, try non-UTF-8 one:
1638 if ( !l )
1639 l = wxSetlocale(c, lc);
1640
1641 return l;
1642 }
1643 #else
1644 #define wxSetlocaleTryUTF8(c, lc) wxSetlocale(c, lc)
1645 #endif
1646
1647 bool wxLocale::Init(int language, int flags)
1648 {
1649 bool ret = true;
1650
1651 int lang = language;
1652 if (lang == wxLANGUAGE_DEFAULT)
1653 {
1654 // auto detect the language
1655 lang = GetSystemLanguage();
1656 }
1657
1658 // We failed to detect system language, so we will use English:
1659 if (lang == wxLANGUAGE_UNKNOWN)
1660 {
1661 return false;
1662 }
1663
1664 const wxLanguageInfo *info = GetLanguageInfo(lang);
1665
1666 // Unknown language:
1667 if (info == NULL)
1668 {
1669 wxLogError(wxT("Unknown language %i."), lang);
1670 return false;
1671 }
1672
1673 wxString name = info->Description;
1674 wxString canonical = info->CanonicalName;
1675 wxString locale;
1676
1677 // Set the locale:
1678 #if defined(__OS2__)
1679 const char *retloc = wxSetlocale(LC_ALL , wxEmptyString);
1680 #elif defined(__UNIX__) && !defined(__WXMAC__)
1681 if (language != wxLANGUAGE_DEFAULT)
1682 locale = info->CanonicalName;
1683
1684 const char *retloc = wxSetlocaleTryUTF8(LC_ALL, locale);
1685
1686 const wxString langOnly = locale.Left(2);
1687 if ( !retloc )
1688 {
1689 // Some C libraries don't like xx_YY form and require xx only
1690 retloc = wxSetlocaleTryUTF8(LC_ALL, langOnly);
1691 }
1692
1693 #if wxUSE_FONTMAP
1694 // some systems (e.g. FreeBSD and HP-UX) don't have xx_YY aliases but
1695 // require the full xx_YY.encoding form, so try using UTF-8 because this is
1696 // the only thing we can do generically
1697 //
1698 // TODO: add encodings applicable to each language to the lang DB and try
1699 // them all in turn here
1700 if ( !retloc )
1701 {
1702 const wxChar **names =
1703 wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8);
1704 while ( *names )
1705 {
1706 retloc = wxSetlocale(LC_ALL, locale + _T('.') + *names++);
1707 if ( retloc )
1708 break;
1709 }
1710 }
1711 #endif // wxUSE_FONTMAP
1712
1713 if ( !retloc )
1714 {
1715 // Some C libraries (namely glibc) still use old ISO 639,
1716 // so will translate the abbrev for them
1717 wxString localeAlt;
1718 if ( langOnly == wxT("he") )
1719 localeAlt = wxT("iw") + locale.Mid(3);
1720 else if ( langOnly == wxT("id") )
1721 localeAlt = wxT("in") + locale.Mid(3);
1722 else if ( langOnly == wxT("yi") )
1723 localeAlt = wxT("ji") + locale.Mid(3);
1724 else if ( langOnly == wxT("nb") )
1725 localeAlt = wxT("no_NO");
1726 else if ( langOnly == wxT("nn") )
1727 localeAlt = wxT("no_NY");
1728
1729 if ( !localeAlt.empty() )
1730 {
1731 retloc = wxSetlocaleTryUTF8(LC_ALL, localeAlt);
1732 if ( !retloc )
1733 retloc = wxSetlocaleTryUTF8(LC_ALL, localeAlt.Left(2));
1734 }
1735 }
1736
1737 if ( !retloc )
1738 ret = false;
1739
1740 #ifdef __AIX__
1741 // at least in AIX 5.2 libc is buggy and the string returned from
1742 // setlocale(LC_ALL) can't be passed back to it because it returns 6
1743 // strings (one for each locale category), i.e. for C locale we get back
1744 // "C C C C C C"
1745 //
1746 // this contradicts IBM own docs but this is not of much help, so just work
1747 // around it in the crudest possible manner
1748 char* p = const_cast<char*>(wxStrchr(retloc, ' '));
1749 if ( p )
1750 *p = '\0';
1751 #endif // __AIX__
1752
1753 #elif defined(__WIN32__)
1754
1755 #if wxUSE_UNICODE && (defined(__VISUALC__) || defined(__MINGW32__))
1756 // NB: setlocale() from msvcrt.dll (used by VC++ and Mingw)
1757 // can't set locale to language that can only be written using
1758 // Unicode. Therefore wxSetlocale call failed, but we don't want
1759 // to report it as an error -- so that at least message catalogs
1760 // can be used. Watch for code marked with
1761 // #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS bellow.
1762 #define SETLOCALE_FAILS_ON_UNICODE_LANGS
1763 #endif
1764
1765 const char *retloc = "C";
1766 if (language != wxLANGUAGE_DEFAULT)
1767 {
1768 if (info->WinLang == 0)
1769 {
1770 wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str());
1771 // retloc already set to "C"
1772 }
1773 else
1774 {
1775 int codepage
1776 #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1777 = -1
1778 #endif
1779 ;
1780 wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
1781 SORT_DEFAULT);
1782 // FIXME
1783 #ifndef __WXWINCE__
1784 SetThreadLocale(lcid);
1785 #endif
1786 // NB: we must translate LCID to CRT's setlocale string ourselves,
1787 // because SetThreadLocale does not modify change the
1788 // interpretation of setlocale(LC_ALL, "") call:
1789 wxChar buffer[256];
1790 buffer[0] = wxT('\0');
1791 GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
1792 locale << buffer;
1793 if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
1794 locale << wxT("_") << buffer;
1795 if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0)
1796 {
1797 codepage = wxAtoi(buffer);
1798 if (codepage != 0)
1799 locale << wxT(".") << buffer;
1800 }
1801 if (locale.empty())
1802 {
1803 wxLogLastError(wxT("SetThreadLocale"));
1804 ret = false;
1805 }
1806 else
1807 {
1808 // FIXME
1809 #ifndef __WXWINCE__
1810 retloc = wxSetlocale(LC_ALL, locale);
1811 #endif
1812 #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1813 if (codepage == 0 && retloc == NULL)
1814 {
1815 retloc = "C";
1816 }
1817 #endif
1818 }
1819 }
1820 }
1821 else
1822 {
1823 // FIXME
1824 #ifndef __WXWINCE__
1825 retloc = wxSetlocale(LC_ALL, wxEmptyString);
1826 #else
1827 retloc = NULL;
1828 #endif
1829 #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
1830 if (retloc == NULL)
1831 {
1832 wxChar buffer[16];
1833 if (GetLocaleInfo(LOCALE_USER_DEFAULT,
1834 LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
1835 wxStrcmp(buffer, wxT("0")) == 0)
1836 {
1837 retloc = "C";
1838 }
1839 }
1840 #endif
1841 }
1842
1843 if ( !retloc )
1844 ret = false;
1845 #elif defined(__WXMAC__)
1846 if (lang == wxLANGUAGE_DEFAULT)
1847 locale = wxEmptyString;
1848 else
1849 locale = info->CanonicalName;
1850
1851 const char *retloc = wxSetlocale(LC_ALL, locale);
1852
1853 if ( !retloc )
1854 {
1855 // Some C libraries don't like xx_YY form and require xx only
1856 retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
1857 }
1858 #else
1859 wxUnusedVar(flags);
1860 return false;
1861 #define WX_NO_LOCALE_SUPPORT
1862 #endif
1863
1864 #ifndef WX_NO_LOCALE_SUPPORT
1865 if ( !ret )
1866 {
1867 wxLogWarning(_("Cannot set locale to language \"%s\"."), name.c_str());
1868
1869 // continue nevertheless and try to load at least the translations for
1870 // this language
1871 }
1872
1873 if ( !Init(name, canonical, retloc,
1874 (flags & wxLOCALE_LOAD_DEFAULT) != 0,
1875 (flags & wxLOCALE_CONV_ENCODING) != 0) )
1876 {
1877 ret = false;
1878 }
1879
1880 if (IsOk()) // setlocale() succeeded
1881 m_language = lang;
1882
1883 return ret;
1884 #endif // !WX_NO_LOCALE_SUPPORT
1885 }
1886
1887
1888
1889 void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
1890 {
1891 if ( gs_searchPrefixes.Index(prefix) == wxNOT_FOUND )
1892 {
1893 gs_searchPrefixes.Add(prefix);
1894 }
1895 //else: already have it
1896 }
1897
1898 /*static*/ int wxLocale::GetSystemLanguage()
1899 {
1900 CreateLanguagesDB();
1901
1902 // init i to avoid compiler warning
1903 size_t i = 0,
1904 count = ms_languagesDB->GetCount();
1905
1906 #if defined(__UNIX__) && !defined(__WXMAC__)
1907 // first get the string identifying the language from the environment
1908 wxString langFull;
1909 if (!wxGetEnv(wxT("LC_ALL"), &langFull) &&
1910 !wxGetEnv(wxT("LC_MESSAGES"), &langFull) &&
1911 !wxGetEnv(wxT("LANG"), &langFull))
1912 {
1913 // no language specified, treat it as English
1914 return wxLANGUAGE_ENGLISH_US;
1915 }
1916
1917 if ( langFull == _T("C") || langFull == _T("POSIX") )
1918 {
1919 // default C locale is English too
1920 return wxLANGUAGE_ENGLISH_US;
1921 }
1922
1923 // the language string has the following form
1924 //
1925 // lang[_LANG][.encoding][@modifier]
1926 //
1927 // (see environ(5) in the Open Unix specification)
1928 //
1929 // where lang is the primary language, LANG is a sublang/territory,
1930 // encoding is the charset to use and modifier "allows the user to select
1931 // a specific instance of localization data within a single category"
1932 //
1933 // for example, the following strings are valid:
1934 // fr
1935 // fr_FR
1936 // de_DE.iso88591
1937 // de_DE@euro
1938 // de_DE.iso88591@euro
1939
1940 // for now we don't use the encoding, although we probably should (doing
1941 // translations of the msg catalogs on the fly as required) (TODO)
1942 //
1943 // we don't use the modifiers neither but we probably should translate
1944 // "euro" into iso885915
1945 size_t posEndLang = langFull.find_first_of(_T("@."));
1946 if ( posEndLang != wxString::npos )
1947 {
1948 langFull.Truncate(posEndLang);
1949 }
1950
1951 // in addition to the format above, we also can have full language names
1952 // in LANG env var - for example, SuSE is known to use LANG="german" - so
1953 // check for this
1954
1955 // do we have just the language (or sublang too)?
1956 bool justLang = langFull.length() == LEN_LANG;
1957 if ( justLang ||
1958 (langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxT('_')) )
1959 {
1960 // 0. Make sure the lang is according to latest ISO 639
1961 // (this is necessary because glibc uses iw and in instead
1962 // of he and id respectively).
1963
1964 // the language itself (second part is the dialect/sublang)
1965 wxString langOrig = ExtractLang(langFull);
1966
1967 wxString lang;
1968 if ( langOrig == wxT("iw"))
1969 lang = _T("he");
1970 else if (langOrig == wxT("in"))
1971 lang = wxT("id");
1972 else if (langOrig == wxT("ji"))
1973 lang = wxT("yi");
1974 else if (langOrig == wxT("no_NO"))
1975 lang = wxT("nb_NO");
1976 else if (langOrig == wxT("no_NY"))
1977 lang = wxT("nn_NO");
1978 else if (langOrig == wxT("no"))
1979 lang = wxT("nb_NO");
1980 else
1981 lang = langOrig;
1982
1983 // did we change it?
1984 if ( lang != langOrig )
1985 {
1986 langFull = lang + ExtractNotLang(langFull);
1987 }
1988
1989 // 1. Try to find the language either as is:
1990 for ( i = 0; i < count; i++ )
1991 {
1992 if ( ms_languagesDB->Item(i).CanonicalName == langFull )
1993 {
1994 break;
1995 }
1996 }
1997
1998 // 2. If langFull is of the form xx_YY, try to find xx:
1999 if ( i == count && !justLang )
2000 {
2001 for ( i = 0; i < count; i++ )
2002 {
2003 if ( ms_languagesDB->Item(i).CanonicalName == lang )
2004 {
2005 break;
2006 }
2007 }
2008 }
2009
2010 // 3. If langFull is of the form xx, try to find any xx_YY record:
2011 if ( i == count && justLang )
2012 {
2013 for ( i = 0; i < count; i++ )
2014 {
2015 if ( ExtractLang(ms_languagesDB->Item(i).CanonicalName)
2016 == langFull )
2017 {
2018 break;
2019 }
2020 }
2021 }
2022 }
2023 else // not standard format
2024 {
2025 // try to find the name in verbose description
2026 for ( i = 0; i < count; i++ )
2027 {
2028 if (ms_languagesDB->Item(i).Description.CmpNoCase(langFull) == 0)
2029 {
2030 break;
2031 }
2032 }
2033 }
2034 #elif defined(__WXMAC__)
2035 const wxChar * lc = NULL ;
2036 long lang = GetScriptVariable( smSystemScript, smScriptLang) ;
2037 switch( GetScriptManagerVariable( smRegionCode ) ) {
2038 case verUS :
2039 lc = wxT("en_US") ;
2040 break ;
2041 case verFrance :
2042 lc = wxT("fr_FR") ;
2043 break ;
2044 case verBritain :
2045 lc = wxT("en_GB") ;
2046 break ;
2047 case verGermany :
2048 lc = wxT("de_DE") ;
2049 break ;
2050 case verItaly :
2051 lc = wxT("it_IT") ;
2052 break ;
2053 case verNetherlands :
2054 lc = wxT("nl_NL") ;
2055 break ;
2056 case verFlemish :
2057 lc = wxT("nl_BE") ;
2058 break ;
2059 case verSweden :
2060 lc = wxT("sv_SE" );
2061 break ;
2062 case verSpain :
2063 lc = wxT("es_ES" );
2064 break ;
2065 case verDenmark :
2066 lc = wxT("da_DK") ;
2067 break ;
2068 case verPortugal :
2069 lc = wxT("pt_PT") ;
2070 break ;
2071 case verFrCanada:
2072 lc = wxT("fr_CA") ;
2073 break ;
2074 case verNorway:
2075 lc = wxT("nb_NO") ;
2076 break ;
2077 case verIsrael:
2078 lc = wxT("iw_IL") ;
2079 break ;
2080 case verJapan:
2081 lc = wxT("ja_JP") ;
2082 break ;
2083 case verAustralia:
2084 lc = wxT("en_AU") ;
2085 break ;
2086 case verArabic:
2087 lc = wxT("ar") ;
2088 break ;
2089 case verFinland:
2090 lc = wxT("fi_FI") ;
2091 break ;
2092 case verFrSwiss:
2093 lc = wxT("fr_CH") ;
2094 break ;
2095 case verGrSwiss:
2096 lc = wxT("de_CH") ;
2097 break ;
2098 case verGreece:
2099 lc = wxT("el_GR") ;
2100 break ;
2101 case verIceland:
2102 lc = wxT("is_IS") ;
2103 break ;
2104 case verMalta:
2105 lc = wxT("mt_MT") ;
2106 break ;
2107 case verCyprus:
2108 // _CY is not part of wx, so we have to translate according to the system language
2109 if ( lang == langGreek ) {
2110 lc = wxT("el_GR") ;
2111 }
2112 else if ( lang == langTurkish ) {
2113 lc = wxT("tr_TR") ;
2114 }
2115 break ;
2116 case verTurkey:
2117 lc = wxT("tr_TR") ;
2118 break ;
2119 case verYugoCroatian:
2120 lc = wxT("hr_HR") ;
2121 break ;
2122 case verIndiaHindi:
2123 lc = wxT("hi_IN") ;
2124 break ;
2125 case verPakistanUrdu:
2126 lc = wxT("ur_PK") ;
2127 break ;
2128 case verTurkishModified:
2129 lc = wxT("tr_TR") ;
2130 break ;
2131 case verItalianSwiss:
2132 lc = wxT("it_CH") ;
2133 break ;
2134 case verInternational:
2135 lc = wxT("en") ;
2136 break ;
2137 case verRomania:
2138 lc = wxT("ro_RO") ;
2139 break ;
2140 case verGreecePoly:
2141 lc = wxT("el_GR") ;
2142 break ;
2143 case verLithuania:
2144 lc = wxT("lt_LT") ;
2145 break ;
2146 case verPoland:
2147 lc = wxT("pl_PL") ;
2148 break ;
2149 case verMagyar :
2150 case verHungary:
2151 lc = wxT("hu_HU") ;
2152 break ;
2153 case verEstonia:
2154 lc = wxT("et_EE") ;
2155 break ;
2156 case verLatvia:
2157 lc = wxT("lv_LV") ;
2158 break ;
2159 case verSami:
2160 // not known
2161 break ;
2162 case verFaroeIsl:
2163 lc = wxT("fo_FO") ;
2164 break ;
2165 case verIran:
2166 lc = wxT("fa_IR") ;
2167 break ;
2168 case verRussia:
2169 lc = wxT("ru_RU") ;
2170 break ;
2171 case verIreland:
2172 lc = wxT("ga_IE") ;
2173 break ;
2174 case verKorea:
2175 lc = wxT("ko_KR") ;
2176 break ;
2177 case verChina:
2178 lc = wxT("zh_CN") ;
2179 break ;
2180 case verTaiwan:
2181 lc = wxT("zh_TW") ;
2182 break ;
2183 case verThailand:
2184 lc = wxT("th_TH") ;
2185 break ;
2186 case verCzech:
2187 lc = wxT("cs_CZ") ;
2188 break ;
2189 case verSlovak:
2190 lc = wxT("sk_SK") ;
2191 break ;
2192 case verBengali:
2193 lc = wxT("bn") ;
2194 break ;
2195 case verByeloRussian:
2196 lc = wxT("be_BY") ;
2197 break ;
2198 case verUkraine:
2199 lc = wxT("uk_UA") ;
2200 break ;
2201 case verGreeceAlt:
2202 lc = wxT("el_GR") ;
2203 break ;
2204 case verSerbian:
2205 lc = wxT("sr_YU") ;
2206 break ;
2207 case verSlovenian:
2208 lc = wxT("sl_SI") ;
2209 break ;
2210 case verMacedonian:
2211 lc = wxT("mk_MK") ;
2212 break ;
2213 case verCroatia:
2214 lc = wxT("hr_HR") ;
2215 break ;
2216 case verBrazil:
2217 lc = wxT("pt_BR ") ;
2218 break ;
2219 case verBulgaria:
2220 lc = wxT("bg_BG") ;
2221 break ;
2222 case verCatalonia:
2223 lc = wxT("ca_ES") ;
2224 break ;
2225 case verScottishGaelic:
2226 lc = wxT("gd") ;
2227 break ;
2228 case verManxGaelic:
2229 lc = wxT("gv") ;
2230 break ;
2231 case verBreton:
2232 lc = wxT("br") ;
2233 break ;
2234 case verNunavut:
2235 lc = wxT("iu_CA") ;
2236 break ;
2237 case verWelsh:
2238 lc = wxT("cy") ;
2239 break ;
2240 case verIrishGaelicScript:
2241 lc = wxT("ga_IE") ;
2242 break ;
2243 case verEngCanada:
2244 lc = wxT("en_CA") ;
2245 break ;
2246 case verBhutan:
2247 lc = wxT("dz_BT") ;
2248 break ;
2249 case verArmenian:
2250 lc = wxT("hy_AM") ;
2251 break ;
2252 case verGeorgian:
2253 lc = wxT("ka_GE") ;
2254 break ;
2255 case verSpLatinAmerica:
2256 lc = wxT("es_AR") ;
2257 break ;
2258 case verTonga:
2259 lc = wxT("to_TO" );
2260 break ;
2261 case verFrenchUniversal:
2262 lc = wxT("fr_FR") ;
2263 break ;
2264 case verAustria:
2265 lc = wxT("de_AT") ;
2266 break ;
2267 case verGujarati:
2268 lc = wxT("gu_IN") ;
2269 break ;
2270 case verPunjabi:
2271 lc = wxT("pa") ;
2272 break ;
2273 case verIndiaUrdu:
2274 lc = wxT("ur_IN") ;
2275 break ;
2276 case verVietnam:
2277 lc = wxT("vi_VN") ;
2278 break ;
2279 case verFrBelgium:
2280 lc = wxT("fr_BE") ;
2281 break ;
2282 case verUzbek:
2283 lc = wxT("uz_UZ") ;
2284 break ;
2285 case verSingapore:
2286 lc = wxT("zh_SG") ;
2287 break ;
2288 case verNynorsk:
2289 lc = wxT("nn_NO") ;
2290 break ;
2291 case verAfrikaans:
2292 lc = wxT("af_ZA") ;
2293 break ;
2294 case verEsperanto:
2295 lc = wxT("eo") ;
2296 break ;
2297 case verMarathi:
2298 lc = wxT("mr_IN") ;
2299 break ;
2300 case verTibetan:
2301 lc = wxT("bo") ;
2302 break ;
2303 case verNepal:
2304 lc = wxT("ne_NP") ;
2305 break ;
2306 case verGreenland:
2307 lc = wxT("kl_GL") ;
2308 break ;
2309 default :
2310 break ;
2311 }
2312 for ( i = 0; i < count; i++ )
2313 {
2314 if ( ms_languagesDB->Item(i).CanonicalName == lc )
2315 {
2316 break;
2317 }
2318 }
2319
2320 #elif defined(__WIN32__)
2321 LCID lcid = GetUserDefaultLCID();
2322 if ( lcid != 0 )
2323 {
2324 wxUint32 lang = PRIMARYLANGID(LANGIDFROMLCID(lcid));
2325 wxUint32 sublang = SUBLANGID(LANGIDFROMLCID(lcid));
2326
2327 for ( i = 0; i < count; i++ )
2328 {
2329 if (ms_languagesDB->Item(i).WinLang == lang &&
2330 ms_languagesDB->Item(i).WinSublang == sublang)
2331 {
2332 break;
2333 }
2334 }
2335 }
2336 //else: leave wxlang == wxLANGUAGE_UNKNOWN
2337 #endif // Unix/Win32
2338
2339 if ( i < count )
2340 {
2341 // we did find a matching entry, use it
2342 return ms_languagesDB->Item(i).Language;
2343 }
2344
2345 // no info about this language in the database
2346 return wxLANGUAGE_UNKNOWN;
2347 }
2348
2349 // ----------------------------------------------------------------------------
2350 // encoding stuff
2351 // ----------------------------------------------------------------------------
2352
2353 // this is a bit strange as under Windows we get the encoding name using its
2354 // numeric value and under Unix we do it the other way round, but this just
2355 // reflects the way different systems provide the encoding info
2356
2357 /* static */
2358 wxString wxLocale::GetSystemEncodingName()
2359 {
2360 wxString encname;
2361
2362 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
2363 // FIXME: what is the error return value for GetACP()?
2364 UINT codepage = ::GetACP();
2365 encname.Printf(_T("windows-%u"), codepage);
2366 #elif defined(__WXMAC__)
2367 // default is just empty string, this resolves to the default system
2368 // encoding later
2369 #elif defined(__UNIX_LIKE__)
2370
2371 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
2372 // GNU libc provides current character set this way (this conforms
2373 // to Unix98)
2374 char *oldLocale = strdup(setlocale(LC_CTYPE, NULL));
2375 setlocale(LC_CTYPE, "");
2376 const char *alang = nl_langinfo(CODESET);
2377 setlocale(LC_CTYPE, oldLocale);
2378 free(oldLocale);
2379
2380 if ( alang )
2381 {
2382 encname = wxString::FromAscii( alang );
2383 }
2384 else // nl_langinfo() failed
2385 #endif // HAVE_LANGINFO_H
2386 {
2387 // if we can't get at the character set directly, try to see if it's in
2388 // the environment variables (in most cases this won't work, but I was
2389 // out of ideas)
2390 char *lang = getenv( "LC_ALL");
2391 char *dot = lang ? strchr(lang, '.') : (char *)NULL;
2392 if (!dot)
2393 {
2394 lang = getenv( "LC_CTYPE" );
2395 if ( lang )
2396 dot = strchr(lang, '.' );
2397 }
2398 if (!dot)
2399 {
2400 lang = getenv( "LANG");
2401 if ( lang )
2402 dot = strchr(lang, '.');
2403 }
2404
2405 if ( dot )
2406 {
2407 encname = wxString::FromAscii( dot+1 );
2408 }
2409 }
2410 #endif // Win32/Unix
2411
2412 return encname;
2413 }
2414
2415 /* static */
2416 wxFontEncoding wxLocale::GetSystemEncoding()
2417 {
2418 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
2419 UINT codepage = ::GetACP();
2420
2421 // wxWidgets only knows about CP1250-1257, 874, 932, 936, 949, 950
2422 if ( codepage >= 1250 && codepage <= 1257 )
2423 {
2424 return (wxFontEncoding)(wxFONTENCODING_CP1250 + codepage - 1250);
2425 }
2426
2427 if ( codepage == 874 )
2428 {
2429 return wxFONTENCODING_CP874;
2430 }
2431
2432 if ( codepage == 932 )
2433 {
2434 return wxFONTENCODING_CP932;
2435 }
2436
2437 if ( codepage == 936 )
2438 {
2439 return wxFONTENCODING_CP936;
2440 }
2441
2442 if ( codepage == 949 )
2443 {
2444 return wxFONTENCODING_CP949;
2445 }
2446
2447 if ( codepage == 950 )
2448 {
2449 return wxFONTENCODING_CP950;
2450 }
2451 #elif defined(__WXMAC__)
2452 TextEncoding encoding = 0 ;
2453 #if TARGET_CARBON
2454 encoding = CFStringGetSystemEncoding() ;
2455 #else
2456 UpgradeScriptInfoToTextEncoding ( smSystemScript , kTextLanguageDontCare , kTextRegionDontCare , NULL , &encoding ) ;
2457 #endif
2458 return wxMacGetFontEncFromSystemEnc( encoding ) ;
2459 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
2460 const wxString encname = GetSystemEncodingName();
2461 if ( !encname.empty() )
2462 {
2463 wxFontEncoding enc = wxFontMapperBase::GetEncodingFromName(encname);
2464
2465 // on some modern Linux systems (RedHat 8) the default system locale
2466 // is UTF8 -- but it isn't supported by wxGTK1 in ANSI build at all so
2467 // don't even try to use it in this case
2468 #if !wxUSE_UNICODE && \
2469 ((defined(__WXGTK__) && !defined(__WXGTK20__)) || defined(__WXMOTIF__))
2470 if ( enc == wxFONTENCODING_UTF8 )
2471 {
2472 // the most similar supported encoding...
2473 enc = wxFONTENCODING_ISO8859_1;
2474 }
2475 #endif // !wxUSE_UNICODE
2476
2477 // GetEncodingFromName() returns wxFONTENCODING_DEFAULT for C locale
2478 // (a.k.a. US-ASCII) which is arguably a bug but keep it like this for
2479 // backwards compatibility and just take care to not return
2480 // wxFONTENCODING_DEFAULT from here as this surely doesn't make sense
2481 if ( enc == wxFONTENCODING_DEFAULT )
2482 {
2483 // we don't have wxFONTENCODING_ASCII, so use the closest one
2484 return wxFONTENCODING_ISO8859_1;
2485 }
2486
2487 if ( enc != wxFONTENCODING_MAX )
2488 {
2489 return enc;
2490 }
2491 //else: return wxFONTENCODING_SYSTEM below
2492 }
2493 #endif // Win32/Unix
2494
2495 return wxFONTENCODING_SYSTEM;
2496 }
2497
2498 /* static */
2499 void wxLocale::AddLanguage(const wxLanguageInfo& info)
2500 {
2501 CreateLanguagesDB();
2502 ms_languagesDB->Add(info);
2503 }
2504
2505 /* static */
2506 const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang)
2507 {
2508 CreateLanguagesDB();
2509
2510 // calling GetLanguageInfo(wxLANGUAGE_DEFAULT) is a natural thing to do, so
2511 // make it work
2512 if ( lang == wxLANGUAGE_DEFAULT )
2513 lang = GetSystemLanguage();
2514
2515 const size_t count = ms_languagesDB->GetCount();
2516 for ( size_t i = 0; i < count; i++ )
2517 {
2518 if ( ms_languagesDB->Item(i).Language == lang )
2519 {
2520 // We need to create a temporary here in order to make this work with BCC in final build mode
2521 wxLanguageInfo *ptr = &ms_languagesDB->Item(i);
2522 return ptr;
2523 }
2524 }
2525
2526 return NULL;
2527 }
2528
2529 /* static */
2530 wxString wxLocale::GetLanguageName(int lang)
2531 {
2532 const wxLanguageInfo *info = GetLanguageInfo(lang);
2533 if ( !info )
2534 return wxEmptyString;
2535 else
2536 return info->Description;
2537 }
2538
2539 /* static */
2540 const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale)
2541 {
2542 CreateLanguagesDB();
2543
2544 const wxLanguageInfo *infoRet = NULL;
2545
2546 const size_t count = ms_languagesDB->GetCount();
2547 for ( size_t i = 0; i < count; i++ )
2548 {
2549 const wxLanguageInfo *info = &ms_languagesDB->Item(i);
2550
2551 if ( wxStricmp(locale, info->CanonicalName) == 0 ||
2552 wxStricmp(locale, info->Description) == 0 )
2553 {
2554 // exact match, stop searching
2555 infoRet = info;
2556 break;
2557 }
2558
2559 if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(_T('_'))) == 0 )
2560 {
2561 // a match -- but maybe we'll find an exact one later, so continue
2562 // looking
2563 //
2564 // OTOH, maybe we had already found a language match and in this
2565 // case don't overwrite it because the entry for the default
2566 // country always appears first in ms_languagesDB
2567 if ( !infoRet )
2568 infoRet = info;
2569 }
2570 }
2571
2572 return infoRet;
2573 }
2574
2575 wxString wxLocale::GetSysName() const
2576 {
2577 // FIXME
2578 #ifndef __WXWINCE__
2579 return wxSetlocale(LC_ALL, NULL);
2580 #else
2581 return wxEmptyString;
2582 #endif
2583 }
2584
2585 // clean up
2586 wxLocale::~wxLocale()
2587 {
2588 // free memory
2589 wxMsgCatalog *pTmpCat;
2590 while ( m_pMsgCat != NULL ) {
2591 pTmpCat = m_pMsgCat;
2592 m_pMsgCat = m_pMsgCat->m_pNext;
2593 delete pTmpCat;
2594 }
2595
2596 // restore old locale pointer
2597 wxSetLocale(m_pOldLocale);
2598
2599 // FIXME
2600 #ifndef __WXWINCE__
2601 wxSetlocale(LC_ALL, m_pszOldLocale);
2602 #endif
2603 free((wxChar *)m_pszOldLocale); // const_cast
2604 }
2605
2606 // get the translation of given string in current locale
2607 const wxString& wxLocale::GetString(const wxString& origString,
2608 const wxString& domain) const
2609 {
2610 return GetString(origString, origString, size_t(-1), domain);
2611 }
2612
2613 const wxString& wxLocale::GetString(const wxString& origString,
2614 const wxString& origString2,
2615 size_t n,
2616 const wxString& domain) const
2617 {
2618 if ( origString.empty() )
2619 return GetUntranslatedString(origString);
2620
2621 const wxString *trans = NULL;
2622 wxMsgCatalog *pMsgCat;
2623
2624 if ( !domain.empty() )
2625 {
2626 pMsgCat = FindCatalog(domain);
2627
2628 // does the catalog exist?
2629 if ( pMsgCat != NULL )
2630 trans = pMsgCat->GetString(origString, n);
2631 }
2632 else
2633 {
2634 // search in all domains
2635 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2636 {
2637 trans = pMsgCat->GetString(origString, n);
2638 if ( trans != NULL ) // take the first found
2639 break;
2640 }
2641 }
2642
2643 if ( trans == NULL )
2644 {
2645 #ifdef __WXDEBUG__
2646 if ( !NoTransErr::Suppress() )
2647 {
2648 NoTransErr noTransErr;
2649
2650 wxLogTrace(TRACE_I18N,
2651 _T("string \"%s\"[%ld] not found in %slocale '%s'."),
2652 origString, (long)n,
2653 domain.empty()
2654 ? (const wxChar*)wxString::Format(_T("domain '%s' "), domain).c_str()
2655 : _T(""),
2656 m_strLocale.c_str());
2657 }
2658 #endif // __WXDEBUG__
2659
2660 if (n == size_t(-1))
2661 return GetUntranslatedString(origString);
2662 else
2663 return GetUntranslatedString(n == 1 ? origString : origString2);
2664 }
2665
2666 return *trans;
2667 }
2668
2669 WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual,
2670 wxLocaleUntranslatedStrings);
2671
2672 /* static */
2673 const wxString& wxLocale::GetUntranslatedString(const wxString& str)
2674 {
2675 static wxLocaleUntranslatedStrings s_strings;
2676
2677 wxLocaleUntranslatedStrings::iterator i = s_strings.find(str);
2678 if ( i == s_strings.end() )
2679 return *s_strings.insert(str).first;
2680
2681 return *i;
2682 }
2683
2684 wxString wxLocale::GetHeaderValue(const wxString& header,
2685 const wxString& domain) const
2686 {
2687 if ( header.empty() )
2688 return wxEmptyString;
2689
2690 const wxString *trans = NULL;
2691 wxMsgCatalog *pMsgCat;
2692
2693 if ( !domain.empty() )
2694 {
2695 pMsgCat = FindCatalog(domain);
2696
2697 // does the catalog exist?
2698 if ( pMsgCat == NULL )
2699 return wxEmptyString;
2700
2701 trans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
2702 }
2703 else
2704 {
2705 // search in all domains
2706 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2707 {
2708 trans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
2709 if ( trans != NULL ) // take the first found
2710 break;
2711 }
2712 }
2713
2714 if ( !trans || trans->empty() )
2715 return wxEmptyString;
2716
2717 size_t found = trans->find(header);
2718 if ( found == wxString::npos )
2719 return wxEmptyString;
2720
2721 found += header.length() + 2 /* ': ' */;
2722
2723 // Every header is separated by \n
2724
2725 size_t endLine = trans->find(wxT('\n'), found);
2726 size_t len = (endLine == wxString::npos) ?
2727 wxString::npos : (endLine - found);
2728
2729 return trans->substr(found, len);
2730 }
2731
2732
2733 // find catalog by name in a linked list, return NULL if !found
2734 wxMsgCatalog *wxLocale::FindCatalog(const wxString& domain) const
2735 {
2736 // linear search in the linked list
2737 wxMsgCatalog *pMsgCat;
2738 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2739 {
2740 if ( pMsgCat->GetName() == domain )
2741 return pMsgCat;
2742 }
2743
2744 return NULL;
2745 }
2746
2747 // check if the given locale is provided by OS and C run time
2748 /* static */
2749 bool wxLocale::IsAvailable(int lang)
2750 {
2751 const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
2752 wxCHECK_MSG( info, false, _T("invalid language") );
2753
2754 #if defined(__WIN32__)
2755 if ( !info->WinLang )
2756 return false;
2757
2758 if ( !::IsValidLocale
2759 (
2760 MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
2761 SORT_DEFAULT),
2762 LCID_INSTALLED
2763 ) )
2764 return false;
2765
2766 #elif defined(__UNIX__)
2767
2768 // Test if setting the locale works, then set it back.
2769 const char *oldLocale = wxSetlocale(LC_ALL, "");
2770 const char *tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName);
2771 if ( !tmp )
2772 {
2773 // Some C libraries don't like xx_YY form and require xx only
2774 tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName.Left(2));
2775 if ( !tmp )
2776 return false;
2777 }
2778 // restore the original locale
2779 wxSetlocale(LC_ALL, oldLocale);
2780 #endif
2781
2782 return true;
2783 }
2784
2785 // check if the given catalog is loaded
2786 bool wxLocale::IsLoaded(const wxString& szDomain) const
2787 {
2788 return FindCatalog(szDomain) != NULL;
2789 }
2790
2791 // add a catalog to our linked list
2792 bool wxLocale::AddCatalog(const wxString& szDomain)
2793 {
2794 return AddCatalog(szDomain, wxLANGUAGE_ENGLISH_US, wxEmptyString);
2795 }
2796
2797 // add a catalog to our linked list
2798 bool wxLocale::AddCatalog(const wxString& szDomain,
2799 wxLanguage msgIdLanguage,
2800 const wxString& msgIdCharset)
2801
2802 {
2803 wxMsgCatalog *pMsgCat = new wxMsgCatalog;
2804
2805 if ( pMsgCat->Load(m_strShort, szDomain, msgIdCharset, m_bConvertEncoding) ) {
2806 // add it to the head of the list so that in GetString it will
2807 // be searched before the catalogs added earlier
2808 pMsgCat->m_pNext = m_pMsgCat;
2809 m_pMsgCat = pMsgCat;
2810
2811 return true;
2812 }
2813 else {
2814 // don't add it because it couldn't be loaded anyway
2815 delete pMsgCat;
2816
2817 // It is OK to not load catalog if the msgid language and m_language match,
2818 // in which case we can directly display the texts embedded in program's
2819 // source code:
2820 if (m_language == msgIdLanguage)
2821 return true;
2822
2823 // If there's no exact match, we may still get partial match where the
2824 // (basic) language is same, but the country differs. For example, it's
2825 // permitted to use en_US strings from sources even if m_language is en_GB:
2826 const wxLanguageInfo *msgIdLangInfo = GetLanguageInfo(msgIdLanguage);
2827 if ( msgIdLangInfo &&
2828 msgIdLangInfo->CanonicalName.Mid(0, 2) == m_strShort.Mid(0, 2) )
2829 {
2830 return true;
2831 }
2832
2833 return false;
2834 }
2835 }
2836
2837 // ----------------------------------------------------------------------------
2838 // accessors for locale-dependent data
2839 // ----------------------------------------------------------------------------
2840
2841 #ifdef __WXMSW__
2842
2843 /* static */
2844 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
2845 {
2846 wxString str;
2847 wxChar buffer[256];
2848 size_t count;
2849 buffer[0] = wxT('\0');
2850 switch (index)
2851 {
2852 case wxLOCALE_DECIMAL_POINT:
2853 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
2854 if (!count)
2855 str << wxT(".");
2856 else
2857 str << buffer;
2858 break;
2859 #if 0
2860 case wxSYS_LIST_SEPARATOR:
2861 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
2862 if (!count)
2863 str << wxT(",");
2864 else
2865 str << buffer;
2866 break;
2867 case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero
2868 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256);
2869 if (!count)
2870 str << wxT("0");
2871 else
2872 str << buffer;
2873 break;
2874 #endif
2875 default:
2876 wxFAIL_MSG(wxT("Unknown System String !"));
2877 }
2878 return str;
2879 }
2880
2881 #else // !__WXMSW__
2882
2883 /* static */
2884 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
2885 {
2886 struct lconv *locale_info = localeconv();
2887 switch (cat)
2888 {
2889 case wxLOCALE_CAT_NUMBER:
2890 switch (index)
2891 {
2892 case wxLOCALE_THOUSANDS_SEP:
2893 return wxString(locale_info->thousands_sep,
2894 *wxConvCurrent);
2895 case wxLOCALE_DECIMAL_POINT:
2896 return wxString(locale_info->decimal_point,
2897 *wxConvCurrent);
2898 default:
2899 return wxEmptyString;
2900 }
2901 case wxLOCALE_CAT_MONEY:
2902 switch (index)
2903 {
2904 case wxLOCALE_THOUSANDS_SEP:
2905 return wxString(locale_info->mon_thousands_sep,
2906 *wxConvCurrent);
2907 case wxLOCALE_DECIMAL_POINT:
2908 return wxString(locale_info->mon_decimal_point,
2909 *wxConvCurrent);
2910 default:
2911 return wxEmptyString;
2912 }
2913 default:
2914 return wxEmptyString;
2915 }
2916 }
2917
2918 #endif // __WXMSW__/!__WXMSW__
2919
2920 // ----------------------------------------------------------------------------
2921 // global functions and variables
2922 // ----------------------------------------------------------------------------
2923
2924 // retrieve/change current locale
2925 // ------------------------------
2926
2927 // the current locale object
2928 static wxLocale *g_pLocale = NULL;
2929
2930 wxLocale *wxGetLocale()
2931 {
2932 return g_pLocale;
2933 }
2934
2935 wxLocale *wxSetLocale(wxLocale *pLocale)
2936 {
2937 wxLocale *pOld = g_pLocale;
2938 g_pLocale = pLocale;
2939 return pOld;
2940 }
2941
2942
2943
2944 // ----------------------------------------------------------------------------
2945 // wxLocale module (for lazy destruction of languagesDB)
2946 // ----------------------------------------------------------------------------
2947
2948 class wxLocaleModule: public wxModule
2949 {
2950 DECLARE_DYNAMIC_CLASS(wxLocaleModule)
2951 public:
2952 wxLocaleModule() {}
2953 bool OnInit() { return true; }
2954 void OnExit() { wxLocale::DestroyLanguagesDB(); }
2955 };
2956
2957 IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
2958
2959
2960
2961 // ----------------------------------------------------------------------------
2962 // default languages table & initialization
2963 // ----------------------------------------------------------------------------
2964
2965
2966
2967 // --- --- --- generated code begins here --- --- ---
2968
2969 // This table is generated by misc/languages/genlang.py
2970 // When making changes, please put them into misc/languages/langtabl.txt
2971
2972 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
2973
2974 #define SETWINLANG(info,lang,sublang)
2975
2976 #else
2977
2978 #define SETWINLANG(info,lang,sublang) \
2979 info.WinLang = lang, info.WinSublang = sublang;
2980
2981 #ifndef LANG_AFRIKAANS
2982 #define LANG_AFRIKAANS (0)
2983 #endif
2984 #ifndef LANG_ALBANIAN
2985 #define LANG_ALBANIAN (0)
2986 #endif
2987 #ifndef LANG_ARABIC
2988 #define LANG_ARABIC (0)
2989 #endif
2990 #ifndef LANG_ARMENIAN
2991 #define LANG_ARMENIAN (0)
2992 #endif
2993 #ifndef LANG_ASSAMESE
2994 #define LANG_ASSAMESE (0)
2995 #endif
2996 #ifndef LANG_AZERI
2997 #define LANG_AZERI (0)
2998 #endif
2999 #ifndef LANG_BASQUE
3000 #define LANG_BASQUE (0)
3001 #endif
3002 #ifndef LANG_BELARUSIAN
3003 #define LANG_BELARUSIAN (0)
3004 #endif
3005 #ifndef LANG_BENGALI
3006 #define LANG_BENGALI (0)
3007 #endif
3008 #ifndef LANG_BULGARIAN
3009 #define LANG_BULGARIAN (0)
3010 #endif
3011 #ifndef LANG_CATALAN
3012 #define LANG_CATALAN (0)
3013 #endif
3014 #ifndef LANG_CHINESE
3015 #define LANG_CHINESE (0)
3016 #endif
3017 #ifndef LANG_CROATIAN
3018 #define LANG_CROATIAN (0)
3019 #endif
3020 #ifndef LANG_CZECH
3021 #define LANG_CZECH (0)
3022 #endif
3023 #ifndef LANG_DANISH
3024 #define LANG_DANISH (0)
3025 #endif
3026 #ifndef LANG_DUTCH
3027 #define LANG_DUTCH (0)
3028 #endif
3029 #ifndef LANG_ENGLISH
3030 #define LANG_ENGLISH (0)
3031 #endif
3032 #ifndef LANG_ESTONIAN
3033 #define LANG_ESTONIAN (0)
3034 #endif
3035 #ifndef LANG_FAEROESE
3036 #define LANG_FAEROESE (0)
3037 #endif
3038 #ifndef LANG_FARSI
3039 #define LANG_FARSI (0)
3040 #endif
3041 #ifndef LANG_FINNISH
3042 #define LANG_FINNISH (0)
3043 #endif
3044 #ifndef LANG_FRENCH
3045 #define LANG_FRENCH (0)
3046 #endif
3047 #ifndef LANG_GEORGIAN
3048 #define LANG_GEORGIAN (0)
3049 #endif
3050 #ifndef LANG_GERMAN
3051 #define LANG_GERMAN (0)
3052 #endif
3053 #ifndef LANG_GREEK
3054 #define LANG_GREEK (0)
3055 #endif
3056 #ifndef LANG_GUJARATI
3057 #define LANG_GUJARATI (0)
3058 #endif
3059 #ifndef LANG_HEBREW
3060 #define LANG_HEBREW (0)
3061 #endif
3062 #ifndef LANG_HINDI
3063 #define LANG_HINDI (0)
3064 #endif
3065 #ifndef LANG_HUNGARIAN
3066 #define LANG_HUNGARIAN (0)
3067 #endif
3068 #ifndef LANG_ICELANDIC
3069 #define LANG_ICELANDIC (0)
3070 #endif
3071 #ifndef LANG_INDONESIAN
3072 #define LANG_INDONESIAN (0)
3073 #endif
3074 #ifndef LANG_ITALIAN
3075 #define LANG_ITALIAN (0)
3076 #endif
3077 #ifndef LANG_JAPANESE
3078 #define LANG_JAPANESE (0)
3079 #endif
3080 #ifndef LANG_KANNADA
3081 #define LANG_KANNADA (0)
3082 #endif
3083 #ifndef LANG_KASHMIRI
3084 #define LANG_KASHMIRI (0)
3085 #endif
3086 #ifndef LANG_KAZAK
3087 #define LANG_KAZAK (0)
3088 #endif
3089 #ifndef LANG_KONKANI
3090 #define LANG_KONKANI (0)
3091 #endif
3092 #ifndef LANG_KOREAN
3093 #define LANG_KOREAN (0)
3094 #endif
3095 #ifndef LANG_LATVIAN
3096 #define LANG_LATVIAN (0)
3097 #endif
3098 #ifndef LANG_LITHUANIAN
3099 #define LANG_LITHUANIAN (0)
3100 #endif
3101 #ifndef LANG_MACEDONIAN
3102 #define LANG_MACEDONIAN (0)
3103 #endif
3104 #ifndef LANG_MALAY
3105 #define LANG_MALAY (0)
3106 #endif
3107 #ifndef LANG_MALAYALAM
3108 #define LANG_MALAYALAM (0)
3109 #endif
3110 #ifndef LANG_MANIPURI
3111 #define LANG_MANIPURI (0)
3112 #endif
3113 #ifndef LANG_MARATHI
3114 #define LANG_MARATHI (0)
3115 #endif
3116 #ifndef LANG_NEPALI
3117 #define LANG_NEPALI (0)
3118 #endif
3119 #ifndef LANG_NORWEGIAN
3120 #define LANG_NORWEGIAN (0)
3121 #endif
3122 #ifndef LANG_ORIYA
3123 #define LANG_ORIYA (0)
3124 #endif
3125 #ifndef LANG_POLISH
3126 #define LANG_POLISH (0)
3127 #endif
3128 #ifndef LANG_PORTUGUESE
3129 #define LANG_PORTUGUESE (0)
3130 #endif
3131 #ifndef LANG_PUNJABI
3132 #define LANG_PUNJABI (0)
3133 #endif
3134 #ifndef LANG_ROMANIAN
3135 #define LANG_ROMANIAN (0)
3136 #endif
3137 #ifndef LANG_RUSSIAN
3138 #define LANG_RUSSIAN (0)
3139 #endif
3140 #ifndef LANG_SANSKRIT
3141 #define LANG_SANSKRIT (0)
3142 #endif
3143 #ifndef LANG_SERBIAN
3144 #define LANG_SERBIAN (0)
3145 #endif
3146 #ifndef LANG_SINDHI
3147 #define LANG_SINDHI (0)
3148 #endif
3149 #ifndef LANG_SLOVAK
3150 #define LANG_SLOVAK (0)
3151 #endif
3152 #ifndef LANG_SLOVENIAN
3153 #define LANG_SLOVENIAN (0)
3154 #endif
3155 #ifndef LANG_SPANISH
3156 #define LANG_SPANISH (0)
3157 #endif
3158 #ifndef LANG_SWAHILI
3159 #define LANG_SWAHILI (0)
3160 #endif
3161 #ifndef LANG_SWEDISH
3162 #define LANG_SWEDISH (0)
3163 #endif
3164 #ifndef LANG_TAMIL
3165 #define LANG_TAMIL (0)
3166 #endif
3167 #ifndef LANG_TATAR
3168 #define LANG_TATAR (0)
3169 #endif
3170 #ifndef LANG_TELUGU
3171 #define LANG_TELUGU (0)
3172 #endif
3173 #ifndef LANG_THAI
3174 #define LANG_THAI (0)
3175 #endif
3176 #ifndef LANG_TURKISH
3177 #define LANG_TURKISH (0)
3178 #endif
3179 #ifndef LANG_UKRAINIAN
3180 #define LANG_UKRAINIAN (0)
3181 #endif
3182 #ifndef LANG_URDU
3183 #define LANG_URDU (0)
3184 #endif
3185 #ifndef LANG_UZBEK
3186 #define LANG_UZBEK (0)
3187 #endif
3188 #ifndef LANG_VIETNAMESE
3189 #define LANG_VIETNAMESE (0)
3190 #endif
3191 #ifndef SUBLANG_ARABIC_ALGERIA
3192 #define SUBLANG_ARABIC_ALGERIA SUBLANG_DEFAULT
3193 #endif
3194 #ifndef SUBLANG_ARABIC_BAHRAIN
3195 #define SUBLANG_ARABIC_BAHRAIN SUBLANG_DEFAULT
3196 #endif
3197 #ifndef SUBLANG_ARABIC_EGYPT
3198 #define SUBLANG_ARABIC_EGYPT SUBLANG_DEFAULT
3199 #endif
3200 #ifndef SUBLANG_ARABIC_IRAQ
3201 #define SUBLANG_ARABIC_IRAQ SUBLANG_DEFAULT
3202 #endif
3203 #ifndef SUBLANG_ARABIC_JORDAN
3204 #define SUBLANG_ARABIC_JORDAN SUBLANG_DEFAULT
3205 #endif
3206 #ifndef SUBLANG_ARABIC_KUWAIT
3207 #define SUBLANG_ARABIC_KUWAIT SUBLANG_DEFAULT
3208 #endif
3209 #ifndef SUBLANG_ARABIC_LEBANON
3210 #define SUBLANG_ARABIC_LEBANON SUBLANG_DEFAULT
3211 #endif
3212 #ifndef SUBLANG_ARABIC_LIBYA
3213 #define SUBLANG_ARABIC_LIBYA SUBLANG_DEFAULT
3214 #endif
3215 #ifndef SUBLANG_ARABIC_MOROCCO
3216 #define SUBLANG_ARABIC_MOROCCO SUBLANG_DEFAULT
3217 #endif
3218 #ifndef SUBLANG_ARABIC_OMAN
3219 #define SUBLANG_ARABIC_OMAN SUBLANG_DEFAULT
3220 #endif
3221 #ifndef SUBLANG_ARABIC_QATAR
3222 #define SUBLANG_ARABIC_QATAR SUBLANG_DEFAULT
3223 #endif
3224 #ifndef SUBLANG_ARABIC_SAUDI_ARABIA
3225 #define SUBLANG_ARABIC_SAUDI_ARABIA SUBLANG_DEFAULT
3226 #endif
3227 #ifndef SUBLANG_ARABIC_SYRIA
3228 #define SUBLANG_ARABIC_SYRIA SUBLANG_DEFAULT
3229 #endif
3230 #ifndef SUBLANG_ARABIC_TUNISIA
3231 #define SUBLANG_ARABIC_TUNISIA SUBLANG_DEFAULT
3232 #endif
3233 #ifndef SUBLANG_ARABIC_UAE
3234 #define SUBLANG_ARABIC_UAE SUBLANG_DEFAULT
3235 #endif
3236 #ifndef SUBLANG_ARABIC_YEMEN
3237 #define SUBLANG_ARABIC_YEMEN SUBLANG_DEFAULT
3238 #endif
3239 #ifndef SUBLANG_AZERI_CYRILLIC
3240 #define SUBLANG_AZERI_CYRILLIC SUBLANG_DEFAULT
3241 #endif
3242 #ifndef SUBLANG_AZERI_LATIN
3243 #define SUBLANG_AZERI_LATIN SUBLANG_DEFAULT
3244 #endif
3245 #ifndef SUBLANG_CHINESE_SIMPLIFIED
3246 #define SUBLANG_CHINESE_SIMPLIFIED SUBLANG_DEFAULT
3247 #endif
3248 #ifndef SUBLANG_CHINESE_TRADITIONAL
3249 #define SUBLANG_CHINESE_TRADITIONAL SUBLANG_DEFAULT
3250 #endif
3251 #ifndef SUBLANG_CHINESE_HONGKONG
3252 #define SUBLANG_CHINESE_HONGKONG SUBLANG_DEFAULT
3253 #endif
3254 #ifndef SUBLANG_CHINESE_MACAU
3255 #define SUBLANG_CHINESE_MACAU SUBLANG_DEFAULT
3256 #endif
3257 #ifndef SUBLANG_CHINESE_SINGAPORE
3258 #define SUBLANG_CHINESE_SINGAPORE SUBLANG_DEFAULT
3259 #endif
3260 #ifndef SUBLANG_DUTCH
3261 #define SUBLANG_DUTCH SUBLANG_DEFAULT
3262 #endif
3263 #ifndef SUBLANG_DUTCH_BELGIAN
3264 #define SUBLANG_DUTCH_BELGIAN SUBLANG_DEFAULT
3265 #endif
3266 #ifndef SUBLANG_ENGLISH_UK
3267 #define SUBLANG_ENGLISH_UK SUBLANG_DEFAULT
3268 #endif
3269 #ifndef SUBLANG_ENGLISH_US
3270 #define SUBLANG_ENGLISH_US SUBLANG_DEFAULT
3271 #endif
3272 #ifndef SUBLANG_ENGLISH_AUS
3273 #define SUBLANG_ENGLISH_AUS SUBLANG_DEFAULT
3274 #endif
3275 #ifndef SUBLANG_ENGLISH_BELIZE
3276 #define SUBLANG_ENGLISH_BELIZE SUBLANG_DEFAULT
3277 #endif
3278 #ifndef SUBLANG_ENGLISH_CAN
3279 #define SUBLANG_ENGLISH_CAN SUBLANG_DEFAULT
3280 #endif
3281 #ifndef SUBLANG_ENGLISH_CARIBBEAN
3282 #define SUBLANG_ENGLISH_CARIBBEAN SUBLANG_DEFAULT
3283 #endif
3284 #ifndef SUBLANG_ENGLISH_EIRE
3285 #define SUBLANG_ENGLISH_EIRE SUBLANG_DEFAULT
3286 #endif
3287 #ifndef SUBLANG_ENGLISH_JAMAICA
3288 #define SUBLANG_ENGLISH_JAMAICA SUBLANG_DEFAULT
3289 #endif
3290 #ifndef SUBLANG_ENGLISH_NZ
3291 #define SUBLANG_ENGLISH_NZ SUBLANG_DEFAULT
3292 #endif
3293 #ifndef SUBLANG_ENGLISH_PHILIPPINES
3294 #define SUBLANG_ENGLISH_PHILIPPINES SUBLANG_DEFAULT
3295 #endif
3296 #ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
3297 #define SUBLANG_ENGLISH_SOUTH_AFRICA SUBLANG_DEFAULT
3298 #endif
3299 #ifndef SUBLANG_ENGLISH_TRINIDAD
3300 #define SUBLANG_ENGLISH_TRINIDAD SUBLANG_DEFAULT
3301 #endif
3302 #ifndef SUBLANG_ENGLISH_ZIMBABWE
3303 #define SUBLANG_ENGLISH_ZIMBABWE SUBLANG_DEFAULT
3304 #endif
3305 #ifndef SUBLANG_FRENCH
3306 #define SUBLANG_FRENCH SUBLANG_DEFAULT
3307 #endif
3308 #ifndef SUBLANG_FRENCH_BELGIAN
3309 #define SUBLANG_FRENCH_BELGIAN SUBLANG_DEFAULT
3310 #endif
3311 #ifndef SUBLANG_FRENCH_CANADIAN
3312 #define SUBLANG_FRENCH_CANADIAN SUBLANG_DEFAULT
3313 #endif
3314 #ifndef SUBLANG_FRENCH_LUXEMBOURG
3315 #define SUBLANG_FRENCH_LUXEMBOURG SUBLANG_DEFAULT
3316 #endif
3317 #ifndef SUBLANG_FRENCH_MONACO
3318 #define SUBLANG_FRENCH_MONACO SUBLANG_DEFAULT
3319 #endif
3320 #ifndef SUBLANG_FRENCH_SWISS
3321 #define SUBLANG_FRENCH_SWISS SUBLANG_DEFAULT
3322 #endif
3323 #ifndef SUBLANG_GERMAN
3324 #define SUBLANG_GERMAN SUBLANG_DEFAULT
3325 #endif
3326 #ifndef SUBLANG_GERMAN_AUSTRIAN
3327 #define SUBLANG_GERMAN_AUSTRIAN SUBLANG_DEFAULT
3328 #endif
3329 #ifndef SUBLANG_GERMAN_LIECHTENSTEIN
3330 #define SUBLANG_GERMAN_LIECHTENSTEIN SUBLANG_DEFAULT
3331 #endif
3332 #ifndef SUBLANG_GERMAN_LUXEMBOURG
3333 #define SUBLANG_GERMAN_LUXEMBOURG SUBLANG_DEFAULT
3334 #endif
3335 #ifndef SUBLANG_GERMAN_SWISS
3336 #define SUBLANG_GERMAN_SWISS SUBLANG_DEFAULT
3337 #endif
3338 #ifndef SUBLANG_ITALIAN
3339 #define SUBLANG_ITALIAN SUBLANG_DEFAULT
3340 #endif
3341 #ifndef SUBLANG_ITALIAN_SWISS
3342 #define SUBLANG_ITALIAN_SWISS SUBLANG_DEFAULT
3343 #endif
3344 #ifndef SUBLANG_KASHMIRI_INDIA
3345 #define SUBLANG_KASHMIRI_INDIA SUBLANG_DEFAULT
3346 #endif
3347 #ifndef SUBLANG_KOREAN
3348 #define SUBLANG_KOREAN SUBLANG_DEFAULT
3349 #endif
3350 #ifndef SUBLANG_LITHUANIAN
3351 #define SUBLANG_LITHUANIAN SUBLANG_DEFAULT
3352 #endif
3353 #ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
3354 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM SUBLANG_DEFAULT
3355 #endif
3356 #ifndef SUBLANG_MALAY_MALAYSIA
3357 #define SUBLANG_MALAY_MALAYSIA SUBLANG_DEFAULT
3358 #endif
3359 #ifndef SUBLANG_NEPALI_INDIA
3360 #define SUBLANG_NEPALI_INDIA SUBLANG_DEFAULT
3361 #endif
3362 #ifndef SUBLANG_NORWEGIAN_BOKMAL
3363 #define SUBLANG_NORWEGIAN_BOKMAL SUBLANG_DEFAULT
3364 #endif
3365 #ifndef SUBLANG_NORWEGIAN_NYNORSK
3366 #define SUBLANG_NORWEGIAN_NYNORSK SUBLANG_DEFAULT
3367 #endif
3368 #ifndef SUBLANG_PORTUGUESE
3369 #define SUBLANG_PORTUGUESE SUBLANG_DEFAULT
3370 #endif
3371 #ifndef SUBLANG_PORTUGUESE_BRAZILIAN
3372 #define SUBLANG_PORTUGUESE_BRAZILIAN SUBLANG_DEFAULT
3373 #endif
3374 #ifndef SUBLANG_SERBIAN_CYRILLIC
3375 #define SUBLANG_SERBIAN_CYRILLIC SUBLANG_DEFAULT
3376 #endif
3377 #ifndef SUBLANG_SERBIAN_LATIN
3378 #define SUBLANG_SERBIAN_LATIN SUBLANG_DEFAULT
3379 #endif
3380 #ifndef SUBLANG_SPANISH
3381 #define SUBLANG_SPANISH SUBLANG_DEFAULT
3382 #endif
3383 #ifndef SUBLANG_SPANISH_ARGENTINA
3384 #define SUBLANG_SPANISH_ARGENTINA SUBLANG_DEFAULT
3385 #endif
3386 #ifndef SUBLANG_SPANISH_BOLIVIA
3387 #define SUBLANG_SPANISH_BOLIVIA SUBLANG_DEFAULT
3388 #endif
3389 #ifndef SUBLANG_SPANISH_CHILE
3390 #define SUBLANG_SPANISH_CHILE SUBLANG_DEFAULT
3391 #endif
3392 #ifndef SUBLANG_SPANISH_COLOMBIA
3393 #define SUBLANG_SPANISH_COLOMBIA SUBLANG_DEFAULT
3394 #endif
3395 #ifndef SUBLANG_SPANISH_COSTA_RICA
3396 #define SUBLANG_SPANISH_COSTA_RICA SUBLANG_DEFAULT
3397 #endif
3398 #ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
3399 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC SUBLANG_DEFAULT
3400 #endif
3401 #ifndef SUBLANG_SPANISH_ECUADOR
3402 #define SUBLANG_SPANISH_ECUADOR SUBLANG_DEFAULT
3403 #endif
3404 #ifndef SUBLANG_SPANISH_EL_SALVADOR
3405 #define SUBLANG_SPANISH_EL_SALVADOR SUBLANG_DEFAULT
3406 #endif
3407 #ifndef SUBLANG_SPANISH_GUATEMALA
3408 #define SUBLANG_SPANISH_GUATEMALA SUBLANG_DEFAULT
3409 #endif
3410 #ifndef SUBLANG_SPANISH_HONDURAS
3411 #define SUBLANG_SPANISH_HONDURAS SUBLANG_DEFAULT
3412 #endif
3413 #ifndef SUBLANG_SPANISH_MEXICAN
3414 #define SUBLANG_SPANISH_MEXICAN SUBLANG_DEFAULT
3415 #endif
3416 #ifndef SUBLANG_SPANISH_MODERN
3417 #define SUBLANG_SPANISH_MODERN SUBLANG_DEFAULT
3418 #endif
3419 #ifndef SUBLANG_SPANISH_NICARAGUA
3420 #define SUBLANG_SPANISH_NICARAGUA SUBLANG_DEFAULT
3421 #endif
3422 #ifndef SUBLANG_SPANISH_PANAMA
3423 #define SUBLANG_SPANISH_PANAMA SUBLANG_DEFAULT
3424 #endif
3425 #ifndef SUBLANG_SPANISH_PARAGUAY
3426 #define SUBLANG_SPANISH_PARAGUAY SUBLANG_DEFAULT
3427 #endif
3428 #ifndef SUBLANG_SPANISH_PERU
3429 #define SUBLANG_SPANISH_PERU SUBLANG_DEFAULT
3430 #endif
3431 #ifndef SUBLANG_SPANISH_PUERTO_RICO
3432 #define SUBLANG_SPANISH_PUERTO_RICO SUBLANG_DEFAULT
3433 #endif
3434 #ifndef SUBLANG_SPANISH_URUGUAY
3435 #define SUBLANG_SPANISH_URUGUAY SUBLANG_DEFAULT
3436 #endif
3437 #ifndef SUBLANG_SPANISH_VENEZUELA
3438 #define SUBLANG_SPANISH_VENEZUELA SUBLANG_DEFAULT
3439 #endif
3440 #ifndef SUBLANG_SWEDISH
3441 #define SUBLANG_SWEDISH SUBLANG_DEFAULT
3442 #endif
3443 #ifndef SUBLANG_SWEDISH_FINLAND
3444 #define SUBLANG_SWEDISH_FINLAND SUBLANG_DEFAULT
3445 #endif
3446 #ifndef SUBLANG_URDU_INDIA
3447 #define SUBLANG_URDU_INDIA SUBLANG_DEFAULT
3448 #endif
3449 #ifndef SUBLANG_URDU_PAKISTAN
3450 #define SUBLANG_URDU_PAKISTAN SUBLANG_DEFAULT
3451 #endif
3452 #ifndef SUBLANG_UZBEK_CYRILLIC
3453 #define SUBLANG_UZBEK_CYRILLIC SUBLANG_DEFAULT
3454 #endif
3455 #ifndef SUBLANG_UZBEK_LATIN
3456 #define SUBLANG_UZBEK_LATIN SUBLANG_DEFAULT
3457 #endif
3458
3459
3460 #endif // __WIN32__
3461
3462 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
3463 info.Language = wxlang; \
3464 info.CanonicalName = wxT(canonical); \
3465 info.LayoutDirection = layout; \
3466 info.Description = wxT(desc); \
3467 SETWINLANG(info, winlang, winsublang) \
3468 AddLanguage(info);
3469
3470 void wxLocale::InitLanguagesDB()
3471 {
3472 wxLanguageInfo info;
3473 wxStringTokenizer tkn;
3474
3475 LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , wxLayout_LeftToRight, "Abkhazian")
3476 LNG(wxLANGUAGE_AFAR, "aa" , 0 , 0 , wxLayout_LeftToRight, "Afar")
3477 LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Afrikaans")
3478 LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Albanian")
3479 LNG(wxLANGUAGE_AMHARIC, "am" , 0 , 0 , wxLayout_LeftToRight, "Amharic")
3480 LNG(wxLANGUAGE_ARABIC, "ar" , LANG_ARABIC , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Arabic")
3481 LNG(wxLANGUAGE_ARABIC_ALGERIA, "ar_DZ", LANG_ARABIC , SUBLANG_ARABIC_ALGERIA , wxLayout_RightToLeft, "Arabic (Algeria)")
3482 LNG(wxLANGUAGE_ARABIC_BAHRAIN, "ar_BH", LANG_ARABIC , SUBLANG_ARABIC_BAHRAIN , wxLayout_RightToLeft, "Arabic (Bahrain)")
3483 LNG(wxLANGUAGE_ARABIC_EGYPT, "ar_EG", LANG_ARABIC , SUBLANG_ARABIC_EGYPT , wxLayout_RightToLeft, "Arabic (Egypt)")
3484 LNG(wxLANGUAGE_ARABIC_IRAQ, "ar_IQ", LANG_ARABIC , SUBLANG_ARABIC_IRAQ , wxLayout_RightToLeft, "Arabic (Iraq)")
3485 LNG(wxLANGUAGE_ARABIC_JORDAN, "ar_JO", LANG_ARABIC , SUBLANG_ARABIC_JORDAN , wxLayout_RightToLeft, "Arabic (Jordan)")
3486 LNG(wxLANGUAGE_ARABIC_KUWAIT, "ar_KW", LANG_ARABIC , SUBLANG_ARABIC_KUWAIT , wxLayout_RightToLeft, "Arabic (Kuwait)")
3487 LNG(wxLANGUAGE_ARABIC_LEBANON, "ar_LB", LANG_ARABIC , SUBLANG_ARABIC_LEBANON , wxLayout_RightToLeft, "Arabic (Lebanon)")
3488 LNG(wxLANGUAGE_ARABIC_LIBYA, "ar_LY", LANG_ARABIC , SUBLANG_ARABIC_LIBYA , wxLayout_RightToLeft, "Arabic (Libya)")
3489 LNG(wxLANGUAGE_ARABIC_MOROCCO, "ar_MA", LANG_ARABIC , SUBLANG_ARABIC_MOROCCO , wxLayout_RightToLeft, "Arabic (Morocco)")
3490 LNG(wxLANGUAGE_ARABIC_OMAN, "ar_OM", LANG_ARABIC , SUBLANG_ARABIC_OMAN , wxLayout_RightToLeft, "Arabic (Oman)")
3491 LNG(wxLANGUAGE_ARABIC_QATAR, "ar_QA", LANG_ARABIC , SUBLANG_ARABIC_QATAR , wxLayout_RightToLeft, "Arabic (Qatar)")
3492 LNG(wxLANGUAGE_ARABIC_SAUDI_ARABIA, "ar_SA", LANG_ARABIC , SUBLANG_ARABIC_SAUDI_ARABIA , wxLayout_RightToLeft, "Arabic (Saudi Arabia)")
3493 LNG(wxLANGUAGE_ARABIC_SUDAN, "ar_SD", 0 , 0 , wxLayout_RightToLeft, "Arabic (Sudan)")
3494 LNG(wxLANGUAGE_ARABIC_SYRIA, "ar_SY", LANG_ARABIC , SUBLANG_ARABIC_SYRIA , wxLayout_RightToLeft, "Arabic (Syria)")
3495 LNG(wxLANGUAGE_ARABIC_TUNISIA, "ar_TN", LANG_ARABIC , SUBLANG_ARABIC_TUNISIA , wxLayout_RightToLeft, "Arabic (Tunisia)")
3496 LNG(wxLANGUAGE_ARABIC_UAE, "ar_AE", LANG_ARABIC , SUBLANG_ARABIC_UAE , wxLayout_RightToLeft, "Arabic (Uae)")
3497 LNG(wxLANGUAGE_ARABIC_YEMEN, "ar_YE", LANG_ARABIC , SUBLANG_ARABIC_YEMEN , wxLayout_RightToLeft, "Arabic (Yemen)")
3498 LNG(wxLANGUAGE_ARMENIAN, "hy" , LANG_ARMENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Armenian")
3499 LNG(wxLANGUAGE_ASSAMESE, "as" , LANG_ASSAMESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Assamese")
3500 LNG(wxLANGUAGE_AYMARA, "ay" , 0 , 0 , wxLayout_LeftToRight, "Aymara")
3501 LNG(wxLANGUAGE_AZERI, "az" , LANG_AZERI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Azeri")
3502 LNG(wxLANGUAGE_AZERI_CYRILLIC, "az" , LANG_AZERI , SUBLANG_AZERI_CYRILLIC , wxLayout_LeftToRight, "Azeri (Cyrillic)")
3503 LNG(wxLANGUAGE_AZERI_LATIN, "az" , LANG_AZERI , SUBLANG_AZERI_LATIN , wxLayout_LeftToRight, "Azeri (Latin)")
3504 LNG(wxLANGUAGE_BASHKIR, "ba" , 0 , 0 , wxLayout_LeftToRight, "Bashkir")
3505 LNG(wxLANGUAGE_BASQUE, "eu_ES", LANG_BASQUE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Basque")
3506 LNG(wxLANGUAGE_BELARUSIAN, "be_BY", LANG_BELARUSIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Belarusian")
3507 LNG(wxLANGUAGE_BENGALI, "bn" , LANG_BENGALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bengali")
3508 LNG(wxLANGUAGE_BHUTANI, "dz" , 0 , 0 , wxLayout_LeftToRight, "Bhutani")
3509 LNG(wxLANGUAGE_BIHARI, "bh" , 0 , 0 , wxLayout_LeftToRight, "Bihari")
3510 LNG(wxLANGUAGE_BISLAMA, "bi" , 0 , 0 , wxLayout_LeftToRight, "Bislama")
3511 LNG(wxLANGUAGE_BRETON, "br" , 0 , 0 , wxLayout_LeftToRight, "Breton")
3512 LNG(wxLANGUAGE_BULGARIAN, "bg_BG", LANG_BULGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bulgarian")
3513 LNG(wxLANGUAGE_BURMESE, "my" , 0 , 0 , wxLayout_LeftToRight, "Burmese")
3514 LNG(wxLANGUAGE_CAMBODIAN, "km" , 0 , 0 , wxLayout_LeftToRight, "Cambodian")
3515 LNG(wxLANGUAGE_CATALAN, "ca_ES", LANG_CATALAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Catalan")
3516 LNG(wxLANGUAGE_CHINESE, "zh_TW", LANG_CHINESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Chinese")
3517 LNG(wxLANGUAGE_CHINESE_SIMPLIFIED, "zh_CN", LANG_CHINESE , SUBLANG_CHINESE_SIMPLIFIED , wxLayout_LeftToRight, "Chinese (Simplified)")
3518 LNG(wxLANGUAGE_CHINESE_TRADITIONAL, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Traditional)")
3519 LNG(wxLANGUAGE_CHINESE_HONGKONG, "zh_HK", LANG_CHINESE , SUBLANG_CHINESE_HONGKONG , wxLayout_LeftToRight, "Chinese (Hongkong)")
3520 LNG(wxLANGUAGE_CHINESE_MACAU, "zh_MO", LANG_CHINESE , SUBLANG_CHINESE_MACAU , wxLayout_LeftToRight, "Chinese (Macau)")
3521 LNG(wxLANGUAGE_CHINESE_SINGAPORE, "zh_SG", LANG_CHINESE , SUBLANG_CHINESE_SINGAPORE , wxLayout_LeftToRight, "Chinese (Singapore)")
3522 LNG(wxLANGUAGE_CHINESE_TAIWAN, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Taiwan)")
3523 LNG(wxLANGUAGE_CORSICAN, "co" , 0 , 0 , wxLayout_LeftToRight, "Corsican")
3524 LNG(wxLANGUAGE_CROATIAN, "hr_HR", LANG_CROATIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Croatian")
3525 LNG(wxLANGUAGE_CZECH, "cs_CZ", LANG_CZECH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Czech")
3526 LNG(wxLANGUAGE_DANISH, "da_DK", LANG_DANISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Danish")
3527 LNG(wxLANGUAGE_DUTCH, "nl_NL", LANG_DUTCH , SUBLANG_DUTCH , wxLayout_LeftToRight, "Dutch")
3528 LNG(wxLANGUAGE_DUTCH_BELGIAN, "nl_BE", LANG_DUTCH , SUBLANG_DUTCH_BELGIAN , wxLayout_LeftToRight, "Dutch (Belgian)")
3529 LNG(wxLANGUAGE_ENGLISH, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English")
3530 LNG(wxLANGUAGE_ENGLISH_UK, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English (U.K.)")
3531 LNG(wxLANGUAGE_ENGLISH_US, "en_US", LANG_ENGLISH , SUBLANG_ENGLISH_US , wxLayout_LeftToRight, "English (U.S.)")
3532 LNG(wxLANGUAGE_ENGLISH_AUSTRALIA, "en_AU", LANG_ENGLISH , SUBLANG_ENGLISH_AUS , wxLayout_LeftToRight, "English (Australia)")
3533 LNG(wxLANGUAGE_ENGLISH_BELIZE, "en_BZ", LANG_ENGLISH , SUBLANG_ENGLISH_BELIZE , wxLayout_LeftToRight, "English (Belize)")
3534 LNG(wxLANGUAGE_ENGLISH_BOTSWANA, "en_BW", 0 , 0 , wxLayout_LeftToRight, "English (Botswana)")
3535 LNG(wxLANGUAGE_ENGLISH_CANADA, "en_CA", LANG_ENGLISH , SUBLANG_ENGLISH_CAN , wxLayout_LeftToRight, "English (Canada)")
3536 LNG(wxLANGUAGE_ENGLISH_CARIBBEAN, "en_CB", LANG_ENGLISH , SUBLANG_ENGLISH_CARIBBEAN , wxLayout_LeftToRight, "English (Caribbean)")
3537 LNG(wxLANGUAGE_ENGLISH_DENMARK, "en_DK", 0 , 0 , wxLayout_LeftToRight, "English (Denmark)")
3538 LNG(wxLANGUAGE_ENGLISH_EIRE, "en_IE", LANG_ENGLISH , SUBLANG_ENGLISH_EIRE , wxLayout_LeftToRight, "English (Eire)")
3539 LNG(wxLANGUAGE_ENGLISH_JAMAICA, "en_JM", LANG_ENGLISH , SUBLANG_ENGLISH_JAMAICA , wxLayout_LeftToRight, "English (Jamaica)")
3540 LNG(wxLANGUAGE_ENGLISH_NEW_ZEALAND, "en_NZ", LANG_ENGLISH , SUBLANG_ENGLISH_NZ , wxLayout_LeftToRight, "English (New Zealand)")
3541 LNG(wxLANGUAGE_ENGLISH_PHILIPPINES, "en_PH", LANG_ENGLISH , SUBLANG_ENGLISH_PHILIPPINES , wxLayout_LeftToRight, "English (Philippines)")
3542 LNG(wxLANGUAGE_ENGLISH_SOUTH_AFRICA, "en_ZA", LANG_ENGLISH , SUBLANG_ENGLISH_SOUTH_AFRICA , wxLayout_LeftToRight, "English (South Africa)")
3543 LNG(wxLANGUAGE_ENGLISH_TRINIDAD, "en_TT", LANG_ENGLISH , SUBLANG_ENGLISH_TRINIDAD , wxLayout_LeftToRight, "English (Trinidad)")
3544 LNG(wxLANGUAGE_ENGLISH_ZIMBABWE, "en_ZW", LANG_ENGLISH , SUBLANG_ENGLISH_ZIMBABWE , wxLayout_LeftToRight, "English (Zimbabwe)")
3545 LNG(wxLANGUAGE_ESPERANTO, "eo" , 0 , 0 , wxLayout_LeftToRight, "Esperanto")
3546 LNG(wxLANGUAGE_ESTONIAN, "et_EE", LANG_ESTONIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Estonian")
3547 LNG(wxLANGUAGE_FAEROESE, "fo_FO", LANG_FAEROESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Faeroese")
3548 LNG(wxLANGUAGE_FARSI, "fa_IR", LANG_FARSI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Farsi")
3549 LNG(wxLANGUAGE_FIJI, "fj" , 0 , 0 , wxLayout_LeftToRight, "Fiji")
3550 LNG(wxLANGUAGE_FINNISH, "fi_FI", LANG_FINNISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Finnish")
3551 LNG(wxLANGUAGE_FRENCH, "fr_FR", LANG_FRENCH , SUBLANG_FRENCH , wxLayout_LeftToRight, "French")
3552 LNG(wxLANGUAGE_FRENCH_BELGIAN, "fr_BE", LANG_FRENCH , SUBLANG_FRENCH_BELGIAN , wxLayout_LeftToRight, "French (Belgian)")
3553 LNG(wxLANGUAGE_FRENCH_CANADIAN, "fr_CA", LANG_FRENCH , SUBLANG_FRENCH_CANADIAN , wxLayout_LeftToRight, "French (Canadian)")
3554 LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , wxLayout_LeftToRight, "French (Luxembourg)")
3555 LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , wxLayout_LeftToRight, "French (Monaco)")
3556 LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , wxLayout_LeftToRight, "French (Swiss)")
3557 LNG(wxLANGUAGE_FRISIAN, "fy" , 0 , 0 , wxLayout_LeftToRight, "Frisian")
3558 LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , wxLayout_LeftToRight, "Galician")
3559 LNG(wxLANGUAGE_GEORGIAN, "ka" , LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian")
3560 LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , wxLayout_LeftToRight, "German")
3561 LNG(wxLANGUAGE_GERMAN_AUSTRIAN, "de_AT", LANG_GERMAN , SUBLANG_GERMAN_AUSTRIAN , wxLayout_LeftToRight, "German (Austrian)")
3562 LNG(wxLANGUAGE_GERMAN_BELGIUM, "de_BE", 0 , 0 , wxLayout_LeftToRight, "German (Belgium)")
3563 LNG(wxLANGUAGE_GERMAN_LIECHTENSTEIN, "de_LI", LANG_GERMAN , SUBLANG_GERMAN_LIECHTENSTEIN , wxLayout_LeftToRight, "German (Liechtenstein)")
3564 LNG(wxLANGUAGE_GERMAN_LUXEMBOURG, "de_LU", LANG_GERMAN , SUBLANG_GERMAN_LUXEMBOURG , wxLayout_LeftToRight, "German (Luxembourg)")
3565 LNG(wxLANGUAGE_GERMAN_SWISS, "de_CH", LANG_GERMAN , SUBLANG_GERMAN_SWISS , wxLayout_LeftToRight, "German (Swiss)")
3566 LNG(wxLANGUAGE_GREEK, "el_GR", LANG_GREEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Greek")
3567 LNG(wxLANGUAGE_GREENLANDIC, "kl_GL", 0 , 0 , wxLayout_LeftToRight, "Greenlandic")
3568 LNG(wxLANGUAGE_GUARANI, "gn" , 0 , 0 , wxLayout_LeftToRight, "Guarani")
3569 LNG(wxLANGUAGE_GUJARATI, "gu" , LANG_GUJARATI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Gujarati")
3570 LNG(wxLANGUAGE_HAUSA, "ha" , 0 , 0 , wxLayout_LeftToRight, "Hausa")
3571 LNG(wxLANGUAGE_HEBREW, "he_IL", LANG_HEBREW , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Hebrew")
3572 LNG(wxLANGUAGE_HINDI, "hi_IN", LANG_HINDI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hindi")
3573 LNG(wxLANGUAGE_HUNGARIAN, "hu_HU", LANG_HUNGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hungarian")
3574 LNG(wxLANGUAGE_ICELANDIC, "is_IS", LANG_ICELANDIC , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Icelandic")
3575 LNG(wxLANGUAGE_INDONESIAN, "id_ID", LANG_INDONESIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Indonesian")
3576 LNG(wxLANGUAGE_INTERLINGUA, "ia" , 0 , 0 , wxLayout_LeftToRight, "Interlingua")
3577 LNG(wxLANGUAGE_INTERLINGUE, "ie" , 0 , 0 , wxLayout_LeftToRight, "Interlingue")
3578 LNG(wxLANGUAGE_INUKTITUT, "iu" , 0 , 0 , wxLayout_LeftToRight, "Inuktitut")
3579 LNG(wxLANGUAGE_INUPIAK, "ik" , 0 , 0 , wxLayout_LeftToRight, "Inupiak")
3580 LNG(wxLANGUAGE_IRISH, "ga_IE", 0 , 0 , wxLayout_LeftToRight, "Irish")
3581 LNG(wxLANGUAGE_ITALIAN, "it_IT", LANG_ITALIAN , SUBLANG_ITALIAN , wxLayout_LeftToRight, "Italian")
3582 LNG(wxLANGUAGE_ITALIAN_SWISS, "it_CH", LANG_ITALIAN , SUBLANG_ITALIAN_SWISS , wxLayout_LeftToRight, "Italian (Swiss)")
3583 LNG(wxLANGUAGE_JAPANESE, "ja_JP", LANG_JAPANESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Japanese")
3584 LNG(wxLANGUAGE_JAVANESE, "jw" , 0 , 0 , wxLayout_LeftToRight, "Javanese")
3585 LNG(wxLANGUAGE_KANNADA, "kn" , LANG_KANNADA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kannada")
3586 LNG(wxLANGUAGE_KASHMIRI, "ks" , LANG_KASHMIRI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kashmiri")
3587 LNG(wxLANGUAGE_KASHMIRI_INDIA, "ks_IN", LANG_KASHMIRI , SUBLANG_KASHMIRI_INDIA , wxLayout_LeftToRight, "Kashmiri (India)")
3588 LNG(wxLANGUAGE_KAZAKH, "kk" , LANG_KAZAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kazakh")
3589 LNG(wxLANGUAGE_KERNEWEK, "kw_GB", 0 , 0 , wxLayout_LeftToRight, "Kernewek")
3590 LNG(wxLANGUAGE_KINYARWANDA, "rw" , 0 , 0 , wxLayout_LeftToRight, "Kinyarwanda")
3591 LNG(wxLANGUAGE_KIRGHIZ, "ky" , 0 , 0 , wxLayout_LeftToRight, "Kirghiz")
3592 LNG(wxLANGUAGE_KIRUNDI, "rn" , 0 , 0 , wxLayout_LeftToRight, "Kirundi")
3593 LNG(wxLANGUAGE_KONKANI, "" , LANG_KONKANI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Konkani")
3594 LNG(wxLANGUAGE_KOREAN, "ko_KR", LANG_KOREAN , SUBLANG_KOREAN , wxLayout_LeftToRight, "Korean")
3595 LNG(wxLANGUAGE_KURDISH, "ku" , 0 , 0 , wxLayout_LeftToRight, "Kurdish")
3596 LNG(wxLANGUAGE_LAOTHIAN, "lo" , 0 , 0 , wxLayout_LeftToRight, "Laothian")
3597 LNG(wxLANGUAGE_LATIN, "la" , 0 , 0 , wxLayout_LeftToRight, "Latin")
3598 LNG(wxLANGUAGE_LATVIAN, "lv_LV", LANG_LATVIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Latvian")
3599 LNG(wxLANGUAGE_LINGALA, "ln" , 0 , 0 , wxLayout_LeftToRight, "Lingala")
3600 LNG(wxLANGUAGE_LITHUANIAN, "lt_LT", LANG_LITHUANIAN, SUBLANG_LITHUANIAN , wxLayout_LeftToRight, "Lithuanian")
3601 LNG(wxLANGUAGE_MACEDONIAN, "mk_MK", LANG_MACEDONIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Macedonian")
3602 LNG(wxLANGUAGE_MALAGASY, "mg" , 0 , 0 , wxLayout_LeftToRight, "Malagasy")
3603 LNG(wxLANGUAGE_MALAY, "ms_MY", LANG_MALAY , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malay")
3604 LNG(wxLANGUAGE_MALAYALAM, "ml" , LANG_MALAYALAM , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malayalam")
3605 LNG(wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, "ms_BN", LANG_MALAY , SUBLANG_MALAY_BRUNEI_DARUSSALAM , wxLayout_LeftToRight, "Malay (Brunei Darussalam)")
3606 LNG(wxLANGUAGE_MALAY_MALAYSIA, "ms_MY", LANG_MALAY , SUBLANG_MALAY_MALAYSIA , wxLayout_LeftToRight, "Malay (Malaysia)")
3607 LNG(wxLANGUAGE_MALTESE, "mt_MT", 0 , 0 , wxLayout_LeftToRight, "Maltese")
3608 LNG(wxLANGUAGE_MANIPURI, "" , LANG_MANIPURI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Manipuri")
3609 LNG(wxLANGUAGE_MAORI, "mi" , 0 , 0 , wxLayout_LeftToRight, "Maori")
3610 LNG(wxLANGUAGE_MARATHI, "mr_IN", LANG_MARATHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Marathi")
3611 LNG(wxLANGUAGE_MOLDAVIAN, "mo" , 0 , 0 , wxLayout_LeftToRight, "Moldavian")
3612 LNG(wxLANGUAGE_MONGOLIAN, "mn" , 0 , 0 , wxLayout_LeftToRight, "Mongolian")
3613 LNG(wxLANGUAGE_NAURU, "na" , 0 , 0 , wxLayout_LeftToRight, "Nauru")
3614 LNG(wxLANGUAGE_NEPALI, "ne" , LANG_NEPALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Nepali")
3615 LNG(wxLANGUAGE_NEPALI_INDIA, "ne_IN", LANG_NEPALI , SUBLANG_NEPALI_INDIA , wxLayout_LeftToRight, "Nepali (India)")
3616 LNG(wxLANGUAGE_NORWEGIAN_BOKMAL, "nb_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_BOKMAL , wxLayout_LeftToRight, "Norwegian (Bokmal)")
3617 LNG(wxLANGUAGE_NORWEGIAN_NYNORSK, "nn_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_NYNORSK , wxLayout_LeftToRight, "Norwegian (Nynorsk)")
3618 LNG(wxLANGUAGE_OCCITAN, "oc" , 0 , 0 , wxLayout_LeftToRight, "Occitan")
3619 LNG(wxLANGUAGE_ORIYA, "or" , LANG_ORIYA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Oriya")
3620 LNG(wxLANGUAGE_OROMO, "om" , 0 , 0 , wxLayout_LeftToRight, "(Afan) Oromo")
3621 LNG(wxLANGUAGE_PASHTO, "ps" , 0 , 0 , wxLayout_LeftToRight, "Pashto, Pushto")
3622 LNG(wxLANGUAGE_POLISH, "pl_PL", LANG_POLISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Polish")
3623 LNG(wxLANGUAGE_PORTUGUESE, "pt_PT", LANG_PORTUGUESE, SUBLANG_PORTUGUESE , wxLayout_LeftToRight, "Portuguese")
3624 LNG(wxLANGUAGE_PORTUGUESE_BRAZILIAN, "pt_BR", LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN , wxLayout_LeftToRight, "Portuguese (Brazilian)")
3625 LNG(wxLANGUAGE_PUNJABI, "pa" , LANG_PUNJABI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Punjabi")
3626 LNG(wxLANGUAGE_QUECHUA, "qu" , 0 , 0 , wxLayout_LeftToRight, "Quechua")
3627 LNG(wxLANGUAGE_RHAETO_ROMANCE, "rm" , 0 , 0 , wxLayout_LeftToRight, "Rhaeto-Romance")
3628 LNG(wxLANGUAGE_ROMANIAN, "ro_RO", LANG_ROMANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Romanian")
3629 LNG(wxLANGUAGE_RUSSIAN, "ru_RU", LANG_RUSSIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Russian")
3630 LNG(wxLANGUAGE_RUSSIAN_UKRAINE, "ru_UA", 0 , 0 , wxLayout_LeftToRight, "Russian (Ukraine)")
3631 LNG(wxLANGUAGE_SAMOAN, "sm" , 0 , 0 , wxLayout_LeftToRight, "Samoan")
3632 LNG(wxLANGUAGE_SANGHO, "sg" , 0 , 0 , wxLayout_LeftToRight, "Sangho")
3633 LNG(wxLANGUAGE_SANSKRIT, "sa" , LANG_SANSKRIT , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sanskrit")
3634 LNG(wxLANGUAGE_SCOTS_GAELIC, "gd" , 0 , 0 , wxLayout_LeftToRight, "Scots Gaelic")
3635 LNG(wxLANGUAGE_SERBIAN_CYRILLIC, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_CYRILLIC , wxLayout_LeftToRight, "Serbian (Cyrillic)")
3636 LNG(wxLANGUAGE_SERBIAN_LATIN, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_LATIN , wxLayout_LeftToRight, "Serbian (Latin)")
3637 LNG(wxLANGUAGE_SERBO_CROATIAN, "sh" , 0 , 0 , wxLayout_LeftToRight, "Serbo-Croatian")
3638 LNG(wxLANGUAGE_SESOTHO, "st" , 0 , 0 , wxLayout_LeftToRight, "Sesotho")
3639 LNG(wxLANGUAGE_SETSWANA, "tn" , 0 , 0 , wxLayout_LeftToRight, "Setswana")
3640 LNG(wxLANGUAGE_SHONA, "sn" , 0 , 0 , wxLayout_LeftToRight, "Shona")
3641 LNG(wxLANGUAGE_SINDHI, "sd" , LANG_SINDHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sindhi")
3642 LNG(wxLANGUAGE_SINHALESE, "si" , 0 , 0 , wxLayout_LeftToRight, "Sinhalese")
3643 LNG(wxLANGUAGE_SISWATI, "ss" , 0 , 0 , wxLayout_LeftToRight, "Siswati")
3644 LNG(wxLANGUAGE_SLOVAK, "sk_SK", LANG_SLOVAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovak")
3645 LNG(wxLANGUAGE_SLOVENIAN, "sl_SI", LANG_SLOVENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovenian")
3646 LNG(wxLANGUAGE_SOMALI, "so" , 0 , 0 , wxLayout_LeftToRight, "Somali")
3647 LNG(wxLANGUAGE_SPANISH, "es_ES", LANG_SPANISH , SUBLANG_SPANISH , wxLayout_LeftToRight, "Spanish")
3648 LNG(wxLANGUAGE_SPANISH_ARGENTINA, "es_AR", LANG_SPANISH , SUBLANG_SPANISH_ARGENTINA , wxLayout_LeftToRight, "Spanish (Argentina)")
3649 LNG(wxLANGUAGE_SPANISH_BOLIVIA, "es_BO", LANG_SPANISH , SUBLANG_SPANISH_BOLIVIA , wxLayout_LeftToRight, "Spanish (Bolivia)")
3650 LNG(wxLANGUAGE_SPANISH_CHILE, "es_CL", LANG_SPANISH , SUBLANG_SPANISH_CHILE , wxLayout_LeftToRight, "Spanish (Chile)")
3651 LNG(wxLANGUAGE_SPANISH_COLOMBIA, "es_CO", LANG_SPANISH , SUBLANG_SPANISH_COLOMBIA , wxLayout_LeftToRight, "Spanish (Colombia)")
3652 LNG(wxLANGUAGE_SPANISH_COSTA_RICA, "es_CR", LANG_SPANISH , SUBLANG_SPANISH_COSTA_RICA , wxLayout_LeftToRight, "Spanish (Costa Rica)")
3653 LNG(wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, "es_DO", LANG_SPANISH , SUBLANG_SPANISH_DOMINICAN_REPUBLIC, wxLayout_LeftToRight, "Spanish (Dominican republic)")
3654 LNG(wxLANGUAGE_SPANISH_ECUADOR, "es_EC", LANG_SPANISH , SUBLANG_SPANISH_ECUADOR , wxLayout_LeftToRight, "Spanish (Ecuador)")
3655 LNG(wxLANGUAGE_SPANISH_EL_SALVADOR, "es_SV", LANG_SPANISH , SUBLANG_SPANISH_EL_SALVADOR , wxLayout_LeftToRight, "Spanish (El Salvador)")
3656 LNG(wxLANGUAGE_SPANISH_GUATEMALA, "es_GT", LANG_SPANISH , SUBLANG_SPANISH_GUATEMALA , wxLayout_LeftToRight, "Spanish (Guatemala)")
3657 LNG(wxLANGUAGE_SPANISH_HONDURAS, "es_HN", LANG_SPANISH , SUBLANG_SPANISH_HONDURAS , wxLayout_LeftToRight, "Spanish (Honduras)")
3658 LNG(wxLANGUAGE_SPANISH_MEXICAN, "es_MX", LANG_SPANISH , SUBLANG_SPANISH_MEXICAN , wxLayout_LeftToRight, "Spanish (Mexican)")
3659 LNG(wxLANGUAGE_SPANISH_MODERN, "es_ES", LANG_SPANISH , SUBLANG_SPANISH_MODERN , wxLayout_LeftToRight, "Spanish (Modern)")
3660 LNG(wxLANGUAGE_SPANISH_NICARAGUA, "es_NI", LANG_SPANISH , SUBLANG_SPANISH_NICARAGUA , wxLayout_LeftToRight, "Spanish (Nicaragua)")
3661 LNG(wxLANGUAGE_SPANISH_PANAMA, "es_PA", LANG_SPANISH , SUBLANG_SPANISH_PANAMA , wxLayout_LeftToRight, "Spanish (Panama)")
3662 LNG(wxLANGUAGE_SPANISH_PARAGUAY, "es_PY", LANG_SPANISH , SUBLANG_SPANISH_PARAGUAY , wxLayout_LeftToRight, "Spanish (Paraguay)")
3663 LNG(wxLANGUAGE_SPANISH_PERU, "es_PE", LANG_SPANISH , SUBLANG_SPANISH_PERU , wxLayout_LeftToRight, "Spanish (Peru)")
3664 LNG(wxLANGUAGE_SPANISH_PUERTO_RICO, "es_PR", LANG_SPANISH , SUBLANG_SPANISH_PUERTO_RICO , wxLayout_LeftToRight, "Spanish (Puerto Rico)")
3665 LNG(wxLANGUAGE_SPANISH_URUGUAY, "es_UY", LANG_SPANISH , SUBLANG_SPANISH_URUGUAY , wxLayout_LeftToRight, "Spanish (Uruguay)")
3666 LNG(wxLANGUAGE_SPANISH_US, "es_US", 0 , 0 , wxLayout_LeftToRight, "Spanish (U.S.)")
3667 LNG(wxLANGUAGE_SPANISH_VENEZUELA, "es_VE", LANG_SPANISH , SUBLANG_SPANISH_VENEZUELA , wxLayout_LeftToRight, "Spanish (Venezuela)")
3668 LNG(wxLANGUAGE_SUNDANESE, "su" , 0 , 0 , wxLayout_LeftToRight, "Sundanese")
3669 LNG(wxLANGUAGE_SWAHILI, "sw_KE", LANG_SWAHILI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Swahili")
3670 LNG(wxLANGUAGE_SWEDISH, "sv_SE", LANG_SWEDISH , SUBLANG_SWEDISH , wxLayout_LeftToRight, "Swedish")
3671 LNG(wxLANGUAGE_SWEDISH_FINLAND, "sv_FI", LANG_SWEDISH , SUBLANG_SWEDISH_FINLAND , wxLayout_LeftToRight, "Swedish (Finland)")
3672 LNG(wxLANGUAGE_TAGALOG, "tl_PH", 0 , 0 , wxLayout_LeftToRight, "Tagalog")
3673 LNG(wxLANGUAGE_TAJIK, "tg" , 0 , 0 , wxLayout_LeftToRight, "Tajik")
3674 LNG(wxLANGUAGE_TAMIL, "ta" , LANG_TAMIL , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tamil")
3675 LNG(wxLANGUAGE_TATAR, "tt" , LANG_TATAR , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tatar")
3676 LNG(wxLANGUAGE_TELUGU, "te" , LANG_TELUGU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Telugu")
3677 LNG(wxLANGUAGE_THAI, "th_TH", LANG_THAI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Thai")
3678 LNG(wxLANGUAGE_TIBETAN, "bo" , 0 , 0 , wxLayout_LeftToRight, "Tibetan")
3679 LNG(wxLANGUAGE_TIGRINYA, "ti" , 0 , 0 , wxLayout_LeftToRight, "Tigrinya")
3680 LNG(wxLANGUAGE_TONGA, "to" , 0 , 0 , wxLayout_LeftToRight, "Tonga")
3681 LNG(wxLANGUAGE_TSONGA, "ts" , 0 , 0 , wxLayout_LeftToRight, "Tsonga")
3682 LNG(wxLANGUAGE_TURKISH, "tr_TR", LANG_TURKISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Turkish")
3683 LNG(wxLANGUAGE_TURKMEN, "tk" , 0 , 0 , wxLayout_LeftToRight, "Turkmen")
3684 LNG(wxLANGUAGE_TWI, "tw" , 0 , 0 , wxLayout_LeftToRight, "Twi")
3685 LNG(wxLANGUAGE_UIGHUR, "ug" , 0 , 0 , wxLayout_LeftToRight, "Uighur")
3686 LNG(wxLANGUAGE_UKRAINIAN, "uk_UA", LANG_UKRAINIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Ukrainian")
3687 LNG(wxLANGUAGE_URDU, "ur" , LANG_URDU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Urdu")
3688 LNG(wxLANGUAGE_URDU_INDIA, "ur_IN", LANG_URDU , SUBLANG_URDU_INDIA , wxLayout_LeftToRight, "Urdu (India)")
3689 LNG(wxLANGUAGE_URDU_PAKISTAN, "ur_PK", LANG_URDU , SUBLANG_URDU_PAKISTAN , wxLayout_LeftToRight, "Urdu (Pakistan)")
3690 LNG(wxLANGUAGE_UZBEK, "uz" , LANG_UZBEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Uzbek")
3691 LNG(wxLANGUAGE_UZBEK_CYRILLIC, "uz" , LANG_UZBEK , SUBLANG_UZBEK_CYRILLIC , wxLayout_LeftToRight, "Uzbek (Cyrillic)")
3692 LNG(wxLANGUAGE_UZBEK_LATIN, "uz" , LANG_UZBEK , SUBLANG_UZBEK_LATIN , wxLayout_LeftToRight, "Uzbek (Latin)")
3693 LNG(wxLANGUAGE_VIETNAMESE, "vi_VN", LANG_VIETNAMESE, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Vietnamese")
3694 LNG(wxLANGUAGE_VOLAPUK, "vo" , 0 , 0 , wxLayout_LeftToRight, "Volapuk")
3695 LNG(wxLANGUAGE_WELSH, "cy" , 0 , 0 , wxLayout_LeftToRight, "Welsh")
3696 LNG(wxLANGUAGE_WOLOF, "wo" , 0 , 0 , wxLayout_LeftToRight, "Wolof")
3697 LNG(wxLANGUAGE_XHOSA, "xh" , 0 , 0 , wxLayout_LeftToRight, "Xhosa")
3698 LNG(wxLANGUAGE_YIDDISH, "yi" , 0 , 0 , wxLayout_LeftToRight, "Yiddish")
3699 LNG(wxLANGUAGE_YORUBA, "yo" , 0 , 0 , wxLayout_LeftToRight, "Yoruba")
3700 LNG(wxLANGUAGE_ZHUANG, "za" , 0 , 0 , wxLayout_LeftToRight, "Zhuang")
3701 LNG(wxLANGUAGE_ZULU, "zu" , 0 , 0 , wxLayout_LeftToRight, "Zulu")
3702 }
3703 #undef LNG
3704
3705 // --- --- --- generated code ends here --- --- ---
3706
3707 #endif // wxUSE_INTL