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