]> git.saurik.com Git - wxWidgets.git/blob - src/common/intl.cpp
added vendor display name (for consistency with app display name &c) (patch 1831303)
[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 encoding = CFStringGetSystemEncoding() ;
2476 return wxMacGetFontEncFromSystemEnc( encoding ) ;
2477 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
2478 const wxString encname = GetSystemEncodingName();
2479 if ( !encname.empty() )
2480 {
2481 wxFontEncoding enc = wxFontMapperBase::GetEncodingFromName(encname);
2482
2483 // on some modern Linux systems (RedHat 8) the default system locale
2484 // is UTF8 -- but it isn't supported by wxGTK1 in ANSI build at all so
2485 // don't even try to use it in this case
2486 #if !wxUSE_UNICODE && \
2487 ((defined(__WXGTK__) && !defined(__WXGTK20__)) || defined(__WXMOTIF__))
2488 if ( enc == wxFONTENCODING_UTF8 )
2489 {
2490 // the most similar supported encoding...
2491 enc = wxFONTENCODING_ISO8859_1;
2492 }
2493 #endif // !wxUSE_UNICODE
2494
2495 // GetEncodingFromName() returns wxFONTENCODING_DEFAULT for C locale
2496 // (a.k.a. US-ASCII) which is arguably a bug but keep it like this for
2497 // backwards compatibility and just take care to not return
2498 // wxFONTENCODING_DEFAULT from here as this surely doesn't make sense
2499 if ( enc == wxFONTENCODING_DEFAULT )
2500 {
2501 // we don't have wxFONTENCODING_ASCII, so use the closest one
2502 return wxFONTENCODING_ISO8859_1;
2503 }
2504
2505 if ( enc != wxFONTENCODING_MAX )
2506 {
2507 return enc;
2508 }
2509 //else: return wxFONTENCODING_SYSTEM below
2510 }
2511 #endif // Win32/Unix
2512
2513 return wxFONTENCODING_SYSTEM;
2514 }
2515
2516 /* static */
2517 void wxLocale::AddLanguage(const wxLanguageInfo& info)
2518 {
2519 CreateLanguagesDB();
2520 ms_languagesDB->Add(info);
2521 }
2522
2523 /* static */
2524 const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang)
2525 {
2526 CreateLanguagesDB();
2527
2528 // calling GetLanguageInfo(wxLANGUAGE_DEFAULT) is a natural thing to do, so
2529 // make it work
2530 if ( lang == wxLANGUAGE_DEFAULT )
2531 lang = GetSystemLanguage();
2532
2533 const size_t count = ms_languagesDB->GetCount();
2534 for ( size_t i = 0; i < count; i++ )
2535 {
2536 if ( ms_languagesDB->Item(i).Language == lang )
2537 {
2538 // We need to create a temporary here in order to make this work with BCC in final build mode
2539 wxLanguageInfo *ptr = &ms_languagesDB->Item(i);
2540 return ptr;
2541 }
2542 }
2543
2544 return NULL;
2545 }
2546
2547 /* static */
2548 wxString wxLocale::GetLanguageName(int lang)
2549 {
2550 const wxLanguageInfo *info = GetLanguageInfo(lang);
2551 if ( !info )
2552 return wxEmptyString;
2553 else
2554 return info->Description;
2555 }
2556
2557 /* static */
2558 const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale)
2559 {
2560 CreateLanguagesDB();
2561
2562 const wxLanguageInfo *infoRet = NULL;
2563
2564 const size_t count = ms_languagesDB->GetCount();
2565 for ( size_t i = 0; i < count; i++ )
2566 {
2567 const wxLanguageInfo *info = &ms_languagesDB->Item(i);
2568
2569 if ( wxStricmp(locale, info->CanonicalName) == 0 ||
2570 wxStricmp(locale, info->Description) == 0 )
2571 {
2572 // exact match, stop searching
2573 infoRet = info;
2574 break;
2575 }
2576
2577 if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(_T('_'))) == 0 )
2578 {
2579 // a match -- but maybe we'll find an exact one later, so continue
2580 // looking
2581 //
2582 // OTOH, maybe we had already found a language match and in this
2583 // case don't overwrite it because the entry for the default
2584 // country always appears first in ms_languagesDB
2585 if ( !infoRet )
2586 infoRet = info;
2587 }
2588 }
2589
2590 return infoRet;
2591 }
2592
2593 wxString wxLocale::GetSysName() const
2594 {
2595 // FIXME
2596 #ifndef __WXWINCE__
2597 return wxSetlocale(LC_ALL, NULL);
2598 #else
2599 return wxEmptyString;
2600 #endif
2601 }
2602
2603 // clean up
2604 wxLocale::~wxLocale()
2605 {
2606 // free memory
2607 wxMsgCatalog *pTmpCat;
2608 while ( m_pMsgCat != NULL ) {
2609 pTmpCat = m_pMsgCat;
2610 m_pMsgCat = m_pMsgCat->m_pNext;
2611 delete pTmpCat;
2612 }
2613
2614 // restore old locale pointer
2615 wxSetLocale(m_pOldLocale);
2616
2617 // FIXME
2618 #ifndef __WXWINCE__
2619 wxSetlocale(LC_ALL, m_pszOldLocale);
2620 #endif
2621 free((wxChar *)m_pszOldLocale); // const_cast
2622 }
2623
2624 // get the translation of given string in current locale
2625 const wxString& wxLocale::GetString(const wxString& origString,
2626 const wxString& domain) const
2627 {
2628 return GetString(origString, origString, size_t(-1), domain);
2629 }
2630
2631 const wxString& wxLocale::GetString(const wxString& origString,
2632 const wxString& origString2,
2633 size_t n,
2634 const wxString& domain) const
2635 {
2636 if ( origString.empty() )
2637 return GetUntranslatedString(origString);
2638
2639 const wxString *trans = NULL;
2640 wxMsgCatalog *pMsgCat;
2641
2642 if ( !domain.empty() )
2643 {
2644 pMsgCat = FindCatalog(domain);
2645
2646 // does the catalog exist?
2647 if ( pMsgCat != NULL )
2648 trans = pMsgCat->GetString(origString, n);
2649 }
2650 else
2651 {
2652 // search in all domains
2653 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2654 {
2655 trans = pMsgCat->GetString(origString, n);
2656 if ( trans != NULL ) // take the first found
2657 break;
2658 }
2659 }
2660
2661 if ( trans == NULL )
2662 {
2663 #ifdef __WXDEBUG__
2664 if ( !NoTransErr::Suppress() )
2665 {
2666 NoTransErr noTransErr;
2667
2668 wxLogTrace(TRACE_I18N,
2669 _T("string \"%s\"[%ld] not found in %slocale '%s'."),
2670 origString, (long)n,
2671 domain.empty()
2672 ? (const wxChar*)wxString::Format(_T("domain '%s' "), domain).c_str()
2673 : _T(""),
2674 m_strLocale.c_str());
2675 }
2676 #endif // __WXDEBUG__
2677
2678 if (n == size_t(-1))
2679 return GetUntranslatedString(origString);
2680 else
2681 return GetUntranslatedString(n == 1 ? origString : origString2);
2682 }
2683
2684 return *trans;
2685 }
2686
2687 WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual,
2688 wxLocaleUntranslatedStrings);
2689
2690 /* static */
2691 const wxString& wxLocale::GetUntranslatedString(const wxString& str)
2692 {
2693 static wxLocaleUntranslatedStrings s_strings;
2694
2695 wxLocaleUntranslatedStrings::iterator i = s_strings.find(str);
2696 if ( i == s_strings.end() )
2697 return *s_strings.insert(str).first;
2698
2699 return *i;
2700 }
2701
2702 wxString wxLocale::GetHeaderValue(const wxString& header,
2703 const wxString& domain) const
2704 {
2705 if ( header.empty() )
2706 return wxEmptyString;
2707
2708 const wxString *trans = NULL;
2709 wxMsgCatalog *pMsgCat;
2710
2711 if ( !domain.empty() )
2712 {
2713 pMsgCat = FindCatalog(domain);
2714
2715 // does the catalog exist?
2716 if ( pMsgCat == NULL )
2717 return wxEmptyString;
2718
2719 trans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
2720 }
2721 else
2722 {
2723 // search in all domains
2724 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2725 {
2726 trans = pMsgCat->GetString(wxEmptyString, (size_t)-1);
2727 if ( trans != NULL ) // take the first found
2728 break;
2729 }
2730 }
2731
2732 if ( !trans || trans->empty() )
2733 return wxEmptyString;
2734
2735 size_t found = trans->find(header);
2736 if ( found == wxString::npos )
2737 return wxEmptyString;
2738
2739 found += header.length() + 2 /* ': ' */;
2740
2741 // Every header is separated by \n
2742
2743 size_t endLine = trans->find(wxT('\n'), found);
2744 size_t len = (endLine == wxString::npos) ?
2745 wxString::npos : (endLine - found);
2746
2747 return trans->substr(found, len);
2748 }
2749
2750
2751 // find catalog by name in a linked list, return NULL if !found
2752 wxMsgCatalog *wxLocale::FindCatalog(const wxString& domain) const
2753 {
2754 // linear search in the linked list
2755 wxMsgCatalog *pMsgCat;
2756 for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
2757 {
2758 if ( pMsgCat->GetName() == domain )
2759 return pMsgCat;
2760 }
2761
2762 return NULL;
2763 }
2764
2765 // check if the given locale is provided by OS and C run time
2766 /* static */
2767 bool wxLocale::IsAvailable(int lang)
2768 {
2769 const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
2770 wxCHECK_MSG( info, false, _T("invalid language") );
2771
2772 #if defined(__WIN32__)
2773 if ( !info->WinLang )
2774 return false;
2775
2776 if ( !::IsValidLocale
2777 (
2778 MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
2779 SORT_DEFAULT),
2780 LCID_INSTALLED
2781 ) )
2782 return false;
2783
2784 #elif defined(__UNIX__)
2785
2786 // Test if setting the locale works, then set it back.
2787 const char *oldLocale = wxSetlocale(LC_ALL, "");
2788 const char *tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName);
2789 if ( !tmp )
2790 {
2791 // Some C libraries don't like xx_YY form and require xx only
2792 tmp = wxSetlocaleTryUTF8(LC_ALL, info->CanonicalName.Left(2));
2793 if ( !tmp )
2794 return false;
2795 }
2796 // restore the original locale
2797 wxSetlocale(LC_ALL, oldLocale);
2798 #endif
2799
2800 return true;
2801 }
2802
2803 // check if the given catalog is loaded
2804 bool wxLocale::IsLoaded(const wxString& szDomain) const
2805 {
2806 return FindCatalog(szDomain) != NULL;
2807 }
2808
2809 // add a catalog to our linked list
2810 bool wxLocale::AddCatalog(const wxString& szDomain)
2811 {
2812 return AddCatalog(szDomain, wxLANGUAGE_ENGLISH_US, wxEmptyString);
2813 }
2814
2815 // add a catalog to our linked list
2816 bool wxLocale::AddCatalog(const wxString& szDomain,
2817 wxLanguage msgIdLanguage,
2818 const wxString& msgIdCharset)
2819
2820 {
2821 wxMsgCatalog *pMsgCat = new wxMsgCatalog;
2822
2823 if ( pMsgCat->Load(m_strShort, szDomain, msgIdCharset, m_bConvertEncoding) ) {
2824 // add it to the head of the list so that in GetString it will
2825 // be searched before the catalogs added earlier
2826 pMsgCat->m_pNext = m_pMsgCat;
2827 m_pMsgCat = pMsgCat;
2828
2829 return true;
2830 }
2831 else {
2832 // don't add it because it couldn't be loaded anyway
2833 delete pMsgCat;
2834
2835 // It is OK to not load catalog if the msgid language and m_language match,
2836 // in which case we can directly display the texts embedded in program's
2837 // source code:
2838 if (m_language == msgIdLanguage)
2839 return true;
2840
2841 // If there's no exact match, we may still get partial match where the
2842 // (basic) language is same, but the country differs. For example, it's
2843 // permitted to use en_US strings from sources even if m_language is en_GB:
2844 const wxLanguageInfo *msgIdLangInfo = GetLanguageInfo(msgIdLanguage);
2845 if ( msgIdLangInfo &&
2846 msgIdLangInfo->CanonicalName.Mid(0, 2) == m_strShort.Mid(0, 2) )
2847 {
2848 return true;
2849 }
2850
2851 return false;
2852 }
2853 }
2854
2855 // ----------------------------------------------------------------------------
2856 // accessors for locale-dependent data
2857 // ----------------------------------------------------------------------------
2858
2859 #if defined(__WXMSW__)
2860
2861 /* static */
2862 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
2863 {
2864 wxString str;
2865 wxChar buffer[256];
2866 size_t count;
2867 buffer[0] = wxT('\0');
2868 switch (index)
2869 {
2870 case wxLOCALE_DECIMAL_POINT:
2871 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
2872 if (!count)
2873 str << wxT(".");
2874 else
2875 str << buffer;
2876 break;
2877 #if 0
2878 case wxSYS_LIST_SEPARATOR:
2879 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
2880 if (!count)
2881 str << wxT(",");
2882 else
2883 str << buffer;
2884 break;
2885 case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero
2886 count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256);
2887 if (!count)
2888 str << wxT("0");
2889 else
2890 str << buffer;
2891 break;
2892 #endif
2893 default:
2894 wxFAIL_MSG(wxT("Unknown System String !"));
2895 }
2896 return str;
2897 }
2898
2899 #elif defined(__WXOSX__)
2900
2901 /* static */
2902 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
2903 {
2904 wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
2905 CFTypeRef cfstr;
2906 switch ( index )
2907 {
2908 case wxLOCALE_THOUSANDS_SEP:
2909 cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleGroupingSeparator);
2910 break;
2911
2912 case wxLOCALE_DECIMAL_POINT:
2913 cfstr = CFLocaleGetValue(userLocaleRef, kCFLocaleDecimalSeparator);
2914 break;
2915
2916 default:
2917 wxFAIL_MSG( "Unknown locale info" );
2918 }
2919
2920 wxMacCFStringHolder
2921 str(CFStringCreateCopy(NULL, static_cast<CFStringRef>(cfstr)));
2922 return str.AsString();
2923 }
2924
2925 #else // !__WXMSW__ && !__WXMAC__
2926
2927 /* static */
2928 wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
2929 {
2930 struct lconv *locale_info = localeconv();
2931 switch (cat)
2932 {
2933 case wxLOCALE_CAT_NUMBER:
2934 switch (index)
2935 {
2936 case wxLOCALE_THOUSANDS_SEP:
2937 return wxString(locale_info->thousands_sep,
2938 *wxConvCurrent);
2939 case wxLOCALE_DECIMAL_POINT:
2940 return wxString(locale_info->decimal_point,
2941 *wxConvCurrent);
2942 default:
2943 return wxEmptyString;
2944 }
2945 case wxLOCALE_CAT_MONEY:
2946 switch (index)
2947 {
2948 case wxLOCALE_THOUSANDS_SEP:
2949 return wxString(locale_info->mon_thousands_sep,
2950 *wxConvCurrent);
2951 case wxLOCALE_DECIMAL_POINT:
2952 return wxString(locale_info->mon_decimal_point,
2953 *wxConvCurrent);
2954 default:
2955 return wxEmptyString;
2956 }
2957 default:
2958 return wxEmptyString;
2959 }
2960 }
2961
2962 #endif // platform
2963
2964 // ----------------------------------------------------------------------------
2965 // global functions and variables
2966 // ----------------------------------------------------------------------------
2967
2968 // retrieve/change current locale
2969 // ------------------------------
2970
2971 // the current locale object
2972 static wxLocale *g_pLocale = NULL;
2973
2974 wxLocale *wxGetLocale()
2975 {
2976 return g_pLocale;
2977 }
2978
2979 wxLocale *wxSetLocale(wxLocale *pLocale)
2980 {
2981 wxLocale *pOld = g_pLocale;
2982 g_pLocale = pLocale;
2983 return pOld;
2984 }
2985
2986
2987
2988 // ----------------------------------------------------------------------------
2989 // wxLocale module (for lazy destruction of languagesDB)
2990 // ----------------------------------------------------------------------------
2991
2992 class wxLocaleModule: public wxModule
2993 {
2994 DECLARE_DYNAMIC_CLASS(wxLocaleModule)
2995 public:
2996 wxLocaleModule() {}
2997 bool OnInit() { return true; }
2998 void OnExit() { wxLocale::DestroyLanguagesDB(); }
2999 };
3000
3001 IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
3002
3003
3004
3005 // ----------------------------------------------------------------------------
3006 // default languages table & initialization
3007 // ----------------------------------------------------------------------------
3008
3009
3010
3011 // --- --- --- generated code begins here --- --- ---
3012
3013 // This table is generated by misc/languages/genlang.py
3014 // When making changes, please put them into misc/languages/langtabl.txt
3015
3016 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
3017
3018 #define SETWINLANG(info,lang,sublang)
3019
3020 #else
3021
3022 #define SETWINLANG(info,lang,sublang) \
3023 info.WinLang = lang, info.WinSublang = sublang;
3024
3025 #ifndef LANG_AFRIKAANS
3026 #define LANG_AFRIKAANS (0)
3027 #endif
3028 #ifndef LANG_ALBANIAN
3029 #define LANG_ALBANIAN (0)
3030 #endif
3031 #ifndef LANG_ARABIC
3032 #define LANG_ARABIC (0)
3033 #endif
3034 #ifndef LANG_ARMENIAN
3035 #define LANG_ARMENIAN (0)
3036 #endif
3037 #ifndef LANG_ASSAMESE
3038 #define LANG_ASSAMESE (0)
3039 #endif
3040 #ifndef LANG_AZERI
3041 #define LANG_AZERI (0)
3042 #endif
3043 #ifndef LANG_BASQUE
3044 #define LANG_BASQUE (0)
3045 #endif
3046 #ifndef LANG_BELARUSIAN
3047 #define LANG_BELARUSIAN (0)
3048 #endif
3049 #ifndef LANG_BENGALI
3050 #define LANG_BENGALI (0)
3051 #endif
3052 #ifndef LANG_BULGARIAN
3053 #define LANG_BULGARIAN (0)
3054 #endif
3055 #ifndef LANG_CATALAN
3056 #define LANG_CATALAN (0)
3057 #endif
3058 #ifndef LANG_CHINESE
3059 #define LANG_CHINESE (0)
3060 #endif
3061 #ifndef LANG_CROATIAN
3062 #define LANG_CROATIAN (0)
3063 #endif
3064 #ifndef LANG_CZECH
3065 #define LANG_CZECH (0)
3066 #endif
3067 #ifndef LANG_DANISH
3068 #define LANG_DANISH (0)
3069 #endif
3070 #ifndef LANG_DUTCH
3071 #define LANG_DUTCH (0)
3072 #endif
3073 #ifndef LANG_ENGLISH
3074 #define LANG_ENGLISH (0)
3075 #endif
3076 #ifndef LANG_ESTONIAN
3077 #define LANG_ESTONIAN (0)
3078 #endif
3079 #ifndef LANG_FAEROESE
3080 #define LANG_FAEROESE (0)
3081 #endif
3082 #ifndef LANG_FARSI
3083 #define LANG_FARSI (0)
3084 #endif
3085 #ifndef LANG_FINNISH
3086 #define LANG_FINNISH (0)
3087 #endif
3088 #ifndef LANG_FRENCH
3089 #define LANG_FRENCH (0)
3090 #endif
3091 #ifndef LANG_GEORGIAN
3092 #define LANG_GEORGIAN (0)
3093 #endif
3094 #ifndef LANG_GERMAN
3095 #define LANG_GERMAN (0)
3096 #endif
3097 #ifndef LANG_GREEK
3098 #define LANG_GREEK (0)
3099 #endif
3100 #ifndef LANG_GUJARATI
3101 #define LANG_GUJARATI (0)
3102 #endif
3103 #ifndef LANG_HEBREW
3104 #define LANG_HEBREW (0)
3105 #endif
3106 #ifndef LANG_HINDI
3107 #define LANG_HINDI (0)
3108 #endif
3109 #ifndef LANG_HUNGARIAN
3110 #define LANG_HUNGARIAN (0)
3111 #endif
3112 #ifndef LANG_ICELANDIC
3113 #define LANG_ICELANDIC (0)
3114 #endif
3115 #ifndef LANG_INDONESIAN
3116 #define LANG_INDONESIAN (0)
3117 #endif
3118 #ifndef LANG_ITALIAN
3119 #define LANG_ITALIAN (0)
3120 #endif
3121 #ifndef LANG_JAPANESE
3122 #define LANG_JAPANESE (0)
3123 #endif
3124 #ifndef LANG_KANNADA
3125 #define LANG_KANNADA (0)
3126 #endif
3127 #ifndef LANG_KASHMIRI
3128 #define LANG_KASHMIRI (0)
3129 #endif
3130 #ifndef LANG_KAZAK
3131 #define LANG_KAZAK (0)
3132 #endif
3133 #ifndef LANG_KONKANI
3134 #define LANG_KONKANI (0)
3135 #endif
3136 #ifndef LANG_KOREAN
3137 #define LANG_KOREAN (0)
3138 #endif
3139 #ifndef LANG_LATVIAN
3140 #define LANG_LATVIAN (0)
3141 #endif
3142 #ifndef LANG_LITHUANIAN
3143 #define LANG_LITHUANIAN (0)
3144 #endif
3145 #ifndef LANG_MACEDONIAN
3146 #define LANG_MACEDONIAN (0)
3147 #endif
3148 #ifndef LANG_MALAY
3149 #define LANG_MALAY (0)
3150 #endif
3151 #ifndef LANG_MALAYALAM
3152 #define LANG_MALAYALAM (0)
3153 #endif
3154 #ifndef LANG_MANIPURI
3155 #define LANG_MANIPURI (0)
3156 #endif
3157 #ifndef LANG_MARATHI
3158 #define LANG_MARATHI (0)
3159 #endif
3160 #ifndef LANG_NEPALI
3161 #define LANG_NEPALI (0)
3162 #endif
3163 #ifndef LANG_NORWEGIAN
3164 #define LANG_NORWEGIAN (0)
3165 #endif
3166 #ifndef LANG_ORIYA
3167 #define LANG_ORIYA (0)
3168 #endif
3169 #ifndef LANG_POLISH
3170 #define LANG_POLISH (0)
3171 #endif
3172 #ifndef LANG_PORTUGUESE
3173 #define LANG_PORTUGUESE (0)
3174 #endif
3175 #ifndef LANG_PUNJABI
3176 #define LANG_PUNJABI (0)
3177 #endif
3178 #ifndef LANG_ROMANIAN
3179 #define LANG_ROMANIAN (0)
3180 #endif
3181 #ifndef LANG_RUSSIAN
3182 #define LANG_RUSSIAN (0)
3183 #endif
3184 #ifndef LANG_SANSKRIT
3185 #define LANG_SANSKRIT (0)
3186 #endif
3187 #ifndef LANG_SERBIAN
3188 #define LANG_SERBIAN (0)
3189 #endif
3190 #ifndef LANG_SINDHI
3191 #define LANG_SINDHI (0)
3192 #endif
3193 #ifndef LANG_SLOVAK
3194 #define LANG_SLOVAK (0)
3195 #endif
3196 #ifndef LANG_SLOVENIAN
3197 #define LANG_SLOVENIAN (0)
3198 #endif
3199 #ifndef LANG_SPANISH
3200 #define LANG_SPANISH (0)
3201 #endif
3202 #ifndef LANG_SWAHILI
3203 #define LANG_SWAHILI (0)
3204 #endif
3205 #ifndef LANG_SWEDISH
3206 #define LANG_SWEDISH (0)
3207 #endif
3208 #ifndef LANG_TAMIL
3209 #define LANG_TAMIL (0)
3210 #endif
3211 #ifndef LANG_TATAR
3212 #define LANG_TATAR (0)
3213 #endif
3214 #ifndef LANG_TELUGU
3215 #define LANG_TELUGU (0)
3216 #endif
3217 #ifndef LANG_THAI
3218 #define LANG_THAI (0)
3219 #endif
3220 #ifndef LANG_TURKISH
3221 #define LANG_TURKISH (0)
3222 #endif
3223 #ifndef LANG_UKRAINIAN
3224 #define LANG_UKRAINIAN (0)
3225 #endif
3226 #ifndef LANG_URDU
3227 #define LANG_URDU (0)
3228 #endif
3229 #ifndef LANG_UZBEK
3230 #define LANG_UZBEK (0)
3231 #endif
3232 #ifndef LANG_VIETNAMESE
3233 #define LANG_VIETNAMESE (0)
3234 #endif
3235 #ifndef SUBLANG_ARABIC_ALGERIA
3236 #define SUBLANG_ARABIC_ALGERIA SUBLANG_DEFAULT
3237 #endif
3238 #ifndef SUBLANG_ARABIC_BAHRAIN
3239 #define SUBLANG_ARABIC_BAHRAIN SUBLANG_DEFAULT
3240 #endif
3241 #ifndef SUBLANG_ARABIC_EGYPT
3242 #define SUBLANG_ARABIC_EGYPT SUBLANG_DEFAULT
3243 #endif
3244 #ifndef SUBLANG_ARABIC_IRAQ
3245 #define SUBLANG_ARABIC_IRAQ SUBLANG_DEFAULT
3246 #endif
3247 #ifndef SUBLANG_ARABIC_JORDAN
3248 #define SUBLANG_ARABIC_JORDAN SUBLANG_DEFAULT
3249 #endif
3250 #ifndef SUBLANG_ARABIC_KUWAIT
3251 #define SUBLANG_ARABIC_KUWAIT SUBLANG_DEFAULT
3252 #endif
3253 #ifndef SUBLANG_ARABIC_LEBANON
3254 #define SUBLANG_ARABIC_LEBANON SUBLANG_DEFAULT
3255 #endif
3256 #ifndef SUBLANG_ARABIC_LIBYA
3257 #define SUBLANG_ARABIC_LIBYA SUBLANG_DEFAULT
3258 #endif
3259 #ifndef SUBLANG_ARABIC_MOROCCO
3260 #define SUBLANG_ARABIC_MOROCCO SUBLANG_DEFAULT
3261 #endif
3262 #ifndef SUBLANG_ARABIC_OMAN
3263 #define SUBLANG_ARABIC_OMAN SUBLANG_DEFAULT
3264 #endif
3265 #ifndef SUBLANG_ARABIC_QATAR
3266 #define SUBLANG_ARABIC_QATAR SUBLANG_DEFAULT
3267 #endif
3268 #ifndef SUBLANG_ARABIC_SAUDI_ARABIA
3269 #define SUBLANG_ARABIC_SAUDI_ARABIA SUBLANG_DEFAULT
3270 #endif
3271 #ifndef SUBLANG_ARABIC_SYRIA
3272 #define SUBLANG_ARABIC_SYRIA SUBLANG_DEFAULT
3273 #endif
3274 #ifndef SUBLANG_ARABIC_TUNISIA
3275 #define SUBLANG_ARABIC_TUNISIA SUBLANG_DEFAULT
3276 #endif
3277 #ifndef SUBLANG_ARABIC_UAE
3278 #define SUBLANG_ARABIC_UAE SUBLANG_DEFAULT
3279 #endif
3280 #ifndef SUBLANG_ARABIC_YEMEN
3281 #define SUBLANG_ARABIC_YEMEN SUBLANG_DEFAULT
3282 #endif
3283 #ifndef SUBLANG_AZERI_CYRILLIC
3284 #define SUBLANG_AZERI_CYRILLIC SUBLANG_DEFAULT
3285 #endif
3286 #ifndef SUBLANG_AZERI_LATIN
3287 #define SUBLANG_AZERI_LATIN SUBLANG_DEFAULT
3288 #endif
3289 #ifndef SUBLANG_CHINESE_SIMPLIFIED
3290 #define SUBLANG_CHINESE_SIMPLIFIED SUBLANG_DEFAULT
3291 #endif
3292 #ifndef SUBLANG_CHINESE_TRADITIONAL
3293 #define SUBLANG_CHINESE_TRADITIONAL SUBLANG_DEFAULT
3294 #endif
3295 #ifndef SUBLANG_CHINESE_HONGKONG
3296 #define SUBLANG_CHINESE_HONGKONG SUBLANG_DEFAULT
3297 #endif
3298 #ifndef SUBLANG_CHINESE_MACAU
3299 #define SUBLANG_CHINESE_MACAU SUBLANG_DEFAULT
3300 #endif
3301 #ifndef SUBLANG_CHINESE_SINGAPORE
3302 #define SUBLANG_CHINESE_SINGAPORE SUBLANG_DEFAULT
3303 #endif
3304 #ifndef SUBLANG_DUTCH
3305 #define SUBLANG_DUTCH SUBLANG_DEFAULT
3306 #endif
3307 #ifndef SUBLANG_DUTCH_BELGIAN
3308 #define SUBLANG_DUTCH_BELGIAN SUBLANG_DEFAULT
3309 #endif
3310 #ifndef SUBLANG_ENGLISH_UK
3311 #define SUBLANG_ENGLISH_UK SUBLANG_DEFAULT
3312 #endif
3313 #ifndef SUBLANG_ENGLISH_US
3314 #define SUBLANG_ENGLISH_US SUBLANG_DEFAULT
3315 #endif
3316 #ifndef SUBLANG_ENGLISH_AUS
3317 #define SUBLANG_ENGLISH_AUS SUBLANG_DEFAULT
3318 #endif
3319 #ifndef SUBLANG_ENGLISH_BELIZE
3320 #define SUBLANG_ENGLISH_BELIZE SUBLANG_DEFAULT
3321 #endif
3322 #ifndef SUBLANG_ENGLISH_CAN
3323 #define SUBLANG_ENGLISH_CAN SUBLANG_DEFAULT
3324 #endif
3325 #ifndef SUBLANG_ENGLISH_CARIBBEAN
3326 #define SUBLANG_ENGLISH_CARIBBEAN SUBLANG_DEFAULT
3327 #endif
3328 #ifndef SUBLANG_ENGLISH_EIRE
3329 #define SUBLANG_ENGLISH_EIRE SUBLANG_DEFAULT
3330 #endif
3331 #ifndef SUBLANG_ENGLISH_JAMAICA
3332 #define SUBLANG_ENGLISH_JAMAICA SUBLANG_DEFAULT
3333 #endif
3334 #ifndef SUBLANG_ENGLISH_NZ
3335 #define SUBLANG_ENGLISH_NZ SUBLANG_DEFAULT
3336 #endif
3337 #ifndef SUBLANG_ENGLISH_PHILIPPINES
3338 #define SUBLANG_ENGLISH_PHILIPPINES SUBLANG_DEFAULT
3339 #endif
3340 #ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
3341 #define SUBLANG_ENGLISH_SOUTH_AFRICA SUBLANG_DEFAULT
3342 #endif
3343 #ifndef SUBLANG_ENGLISH_TRINIDAD
3344 #define SUBLANG_ENGLISH_TRINIDAD SUBLANG_DEFAULT
3345 #endif
3346 #ifndef SUBLANG_ENGLISH_ZIMBABWE
3347 #define SUBLANG_ENGLISH_ZIMBABWE SUBLANG_DEFAULT
3348 #endif
3349 #ifndef SUBLANG_FRENCH
3350 #define SUBLANG_FRENCH SUBLANG_DEFAULT
3351 #endif
3352 #ifndef SUBLANG_FRENCH_BELGIAN
3353 #define SUBLANG_FRENCH_BELGIAN SUBLANG_DEFAULT
3354 #endif
3355 #ifndef SUBLANG_FRENCH_CANADIAN
3356 #define SUBLANG_FRENCH_CANADIAN SUBLANG_DEFAULT
3357 #endif
3358 #ifndef SUBLANG_FRENCH_LUXEMBOURG
3359 #define SUBLANG_FRENCH_LUXEMBOURG SUBLANG_DEFAULT
3360 #endif
3361 #ifndef SUBLANG_FRENCH_MONACO
3362 #define SUBLANG_FRENCH_MONACO SUBLANG_DEFAULT
3363 #endif
3364 #ifndef SUBLANG_FRENCH_SWISS
3365 #define SUBLANG_FRENCH_SWISS SUBLANG_DEFAULT
3366 #endif
3367 #ifndef SUBLANG_GERMAN
3368 #define SUBLANG_GERMAN SUBLANG_DEFAULT
3369 #endif
3370 #ifndef SUBLANG_GERMAN_AUSTRIAN
3371 #define SUBLANG_GERMAN_AUSTRIAN SUBLANG_DEFAULT
3372 #endif
3373 #ifndef SUBLANG_GERMAN_LIECHTENSTEIN
3374 #define SUBLANG_GERMAN_LIECHTENSTEIN SUBLANG_DEFAULT
3375 #endif
3376 #ifndef SUBLANG_GERMAN_LUXEMBOURG
3377 #define SUBLANG_GERMAN_LUXEMBOURG SUBLANG_DEFAULT
3378 #endif
3379 #ifndef SUBLANG_GERMAN_SWISS
3380 #define SUBLANG_GERMAN_SWISS SUBLANG_DEFAULT
3381 #endif
3382 #ifndef SUBLANG_ITALIAN
3383 #define SUBLANG_ITALIAN SUBLANG_DEFAULT
3384 #endif
3385 #ifndef SUBLANG_ITALIAN_SWISS
3386 #define SUBLANG_ITALIAN_SWISS SUBLANG_DEFAULT
3387 #endif
3388 #ifndef SUBLANG_KASHMIRI_INDIA
3389 #define SUBLANG_KASHMIRI_INDIA SUBLANG_DEFAULT
3390 #endif
3391 #ifndef SUBLANG_KOREAN
3392 #define SUBLANG_KOREAN SUBLANG_DEFAULT
3393 #endif
3394 #ifndef SUBLANG_LITHUANIAN
3395 #define SUBLANG_LITHUANIAN SUBLANG_DEFAULT
3396 #endif
3397 #ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
3398 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM SUBLANG_DEFAULT
3399 #endif
3400 #ifndef SUBLANG_MALAY_MALAYSIA
3401 #define SUBLANG_MALAY_MALAYSIA SUBLANG_DEFAULT
3402 #endif
3403 #ifndef SUBLANG_NEPALI_INDIA
3404 #define SUBLANG_NEPALI_INDIA SUBLANG_DEFAULT
3405 #endif
3406 #ifndef SUBLANG_NORWEGIAN_BOKMAL
3407 #define SUBLANG_NORWEGIAN_BOKMAL SUBLANG_DEFAULT
3408 #endif
3409 #ifndef SUBLANG_NORWEGIAN_NYNORSK
3410 #define SUBLANG_NORWEGIAN_NYNORSK SUBLANG_DEFAULT
3411 #endif
3412 #ifndef SUBLANG_PORTUGUESE
3413 #define SUBLANG_PORTUGUESE SUBLANG_DEFAULT
3414 #endif
3415 #ifndef SUBLANG_PORTUGUESE_BRAZILIAN
3416 #define SUBLANG_PORTUGUESE_BRAZILIAN SUBLANG_DEFAULT
3417 #endif
3418 #ifndef SUBLANG_SERBIAN_CYRILLIC
3419 #define SUBLANG_SERBIAN_CYRILLIC SUBLANG_DEFAULT
3420 #endif
3421 #ifndef SUBLANG_SERBIAN_LATIN
3422 #define SUBLANG_SERBIAN_LATIN SUBLANG_DEFAULT
3423 #endif
3424 #ifndef SUBLANG_SPANISH
3425 #define SUBLANG_SPANISH SUBLANG_DEFAULT
3426 #endif
3427 #ifndef SUBLANG_SPANISH_ARGENTINA
3428 #define SUBLANG_SPANISH_ARGENTINA SUBLANG_DEFAULT
3429 #endif
3430 #ifndef SUBLANG_SPANISH_BOLIVIA
3431 #define SUBLANG_SPANISH_BOLIVIA SUBLANG_DEFAULT
3432 #endif
3433 #ifndef SUBLANG_SPANISH_CHILE
3434 #define SUBLANG_SPANISH_CHILE SUBLANG_DEFAULT
3435 #endif
3436 #ifndef SUBLANG_SPANISH_COLOMBIA
3437 #define SUBLANG_SPANISH_COLOMBIA SUBLANG_DEFAULT
3438 #endif
3439 #ifndef SUBLANG_SPANISH_COSTA_RICA
3440 #define SUBLANG_SPANISH_COSTA_RICA SUBLANG_DEFAULT
3441 #endif
3442 #ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
3443 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC SUBLANG_DEFAULT
3444 #endif
3445 #ifndef SUBLANG_SPANISH_ECUADOR
3446 #define SUBLANG_SPANISH_ECUADOR SUBLANG_DEFAULT
3447 #endif
3448 #ifndef SUBLANG_SPANISH_EL_SALVADOR
3449 #define SUBLANG_SPANISH_EL_SALVADOR SUBLANG_DEFAULT
3450 #endif
3451 #ifndef SUBLANG_SPANISH_GUATEMALA
3452 #define SUBLANG_SPANISH_GUATEMALA SUBLANG_DEFAULT
3453 #endif
3454 #ifndef SUBLANG_SPANISH_HONDURAS
3455 #define SUBLANG_SPANISH_HONDURAS SUBLANG_DEFAULT
3456 #endif
3457 #ifndef SUBLANG_SPANISH_MEXICAN
3458 #define SUBLANG_SPANISH_MEXICAN SUBLANG_DEFAULT
3459 #endif
3460 #ifndef SUBLANG_SPANISH_MODERN
3461 #define SUBLANG_SPANISH_MODERN SUBLANG_DEFAULT
3462 #endif
3463 #ifndef SUBLANG_SPANISH_NICARAGUA
3464 #define SUBLANG_SPANISH_NICARAGUA SUBLANG_DEFAULT
3465 #endif
3466 #ifndef SUBLANG_SPANISH_PANAMA
3467 #define SUBLANG_SPANISH_PANAMA SUBLANG_DEFAULT
3468 #endif
3469 #ifndef SUBLANG_SPANISH_PARAGUAY
3470 #define SUBLANG_SPANISH_PARAGUAY SUBLANG_DEFAULT
3471 #endif
3472 #ifndef SUBLANG_SPANISH_PERU
3473 #define SUBLANG_SPANISH_PERU SUBLANG_DEFAULT
3474 #endif
3475 #ifndef SUBLANG_SPANISH_PUERTO_RICO
3476 #define SUBLANG_SPANISH_PUERTO_RICO SUBLANG_DEFAULT
3477 #endif
3478 #ifndef SUBLANG_SPANISH_URUGUAY
3479 #define SUBLANG_SPANISH_URUGUAY SUBLANG_DEFAULT
3480 #endif
3481 #ifndef SUBLANG_SPANISH_VENEZUELA
3482 #define SUBLANG_SPANISH_VENEZUELA SUBLANG_DEFAULT
3483 #endif
3484 #ifndef SUBLANG_SWEDISH
3485 #define SUBLANG_SWEDISH SUBLANG_DEFAULT
3486 #endif
3487 #ifndef SUBLANG_SWEDISH_FINLAND
3488 #define SUBLANG_SWEDISH_FINLAND SUBLANG_DEFAULT
3489 #endif
3490 #ifndef SUBLANG_URDU_INDIA
3491 #define SUBLANG_URDU_INDIA SUBLANG_DEFAULT
3492 #endif
3493 #ifndef SUBLANG_URDU_PAKISTAN
3494 #define SUBLANG_URDU_PAKISTAN SUBLANG_DEFAULT
3495 #endif
3496 #ifndef SUBLANG_UZBEK_CYRILLIC
3497 #define SUBLANG_UZBEK_CYRILLIC SUBLANG_DEFAULT
3498 #endif
3499 #ifndef SUBLANG_UZBEK_LATIN
3500 #define SUBLANG_UZBEK_LATIN SUBLANG_DEFAULT
3501 #endif
3502
3503
3504 #endif // __WIN32__
3505
3506 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
3507 info.Language = wxlang; \
3508 info.CanonicalName = wxT(canonical); \
3509 info.LayoutDirection = layout; \
3510 info.Description = wxT(desc); \
3511 SETWINLANG(info, winlang, winsublang) \
3512 AddLanguage(info);
3513
3514 void wxLocale::InitLanguagesDB()
3515 {
3516 wxLanguageInfo info;
3517 wxStringTokenizer tkn;
3518
3519 LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , wxLayout_LeftToRight, "Abkhazian")
3520 LNG(wxLANGUAGE_AFAR, "aa" , 0 , 0 , wxLayout_LeftToRight, "Afar")
3521 LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Afrikaans")
3522 LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Albanian")
3523 LNG(wxLANGUAGE_AMHARIC, "am" , 0 , 0 , wxLayout_LeftToRight, "Amharic")
3524 LNG(wxLANGUAGE_ARABIC, "ar" , LANG_ARABIC , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Arabic")
3525 LNG(wxLANGUAGE_ARABIC_ALGERIA, "ar_DZ", LANG_ARABIC , SUBLANG_ARABIC_ALGERIA , wxLayout_RightToLeft, "Arabic (Algeria)")
3526 LNG(wxLANGUAGE_ARABIC_BAHRAIN, "ar_BH", LANG_ARABIC , SUBLANG_ARABIC_BAHRAIN , wxLayout_RightToLeft, "Arabic (Bahrain)")
3527 LNG(wxLANGUAGE_ARABIC_EGYPT, "ar_EG", LANG_ARABIC , SUBLANG_ARABIC_EGYPT , wxLayout_RightToLeft, "Arabic (Egypt)")
3528 LNG(wxLANGUAGE_ARABIC_IRAQ, "ar_IQ", LANG_ARABIC , SUBLANG_ARABIC_IRAQ , wxLayout_RightToLeft, "Arabic (Iraq)")
3529 LNG(wxLANGUAGE_ARABIC_JORDAN, "ar_JO", LANG_ARABIC , SUBLANG_ARABIC_JORDAN , wxLayout_RightToLeft, "Arabic (Jordan)")
3530 LNG(wxLANGUAGE_ARABIC_KUWAIT, "ar_KW", LANG_ARABIC , SUBLANG_ARABIC_KUWAIT , wxLayout_RightToLeft, "Arabic (Kuwait)")
3531 LNG(wxLANGUAGE_ARABIC_LEBANON, "ar_LB", LANG_ARABIC , SUBLANG_ARABIC_LEBANON , wxLayout_RightToLeft, "Arabic (Lebanon)")
3532 LNG(wxLANGUAGE_ARABIC_LIBYA, "ar_LY", LANG_ARABIC , SUBLANG_ARABIC_LIBYA , wxLayout_RightToLeft, "Arabic (Libya)")
3533 LNG(wxLANGUAGE_ARABIC_MOROCCO, "ar_MA", LANG_ARABIC , SUBLANG_ARABIC_MOROCCO , wxLayout_RightToLeft, "Arabic (Morocco)")
3534 LNG(wxLANGUAGE_ARABIC_OMAN, "ar_OM", LANG_ARABIC , SUBLANG_ARABIC_OMAN , wxLayout_RightToLeft, "Arabic (Oman)")
3535 LNG(wxLANGUAGE_ARABIC_QATAR, "ar_QA", LANG_ARABIC , SUBLANG_ARABIC_QATAR , wxLayout_RightToLeft, "Arabic (Qatar)")
3536 LNG(wxLANGUAGE_ARABIC_SAUDI_ARABIA, "ar_SA", LANG_ARABIC , SUBLANG_ARABIC_SAUDI_ARABIA , wxLayout_RightToLeft, "Arabic (Saudi Arabia)")
3537 LNG(wxLANGUAGE_ARABIC_SUDAN, "ar_SD", 0 , 0 , wxLayout_RightToLeft, "Arabic (Sudan)")
3538 LNG(wxLANGUAGE_ARABIC_SYRIA, "ar_SY", LANG_ARABIC , SUBLANG_ARABIC_SYRIA , wxLayout_RightToLeft, "Arabic (Syria)")
3539 LNG(wxLANGUAGE_ARABIC_TUNISIA, "ar_TN", LANG_ARABIC , SUBLANG_ARABIC_TUNISIA , wxLayout_RightToLeft, "Arabic (Tunisia)")
3540 LNG(wxLANGUAGE_ARABIC_UAE, "ar_AE", LANG_ARABIC , SUBLANG_ARABIC_UAE , wxLayout_RightToLeft, "Arabic (Uae)")
3541 LNG(wxLANGUAGE_ARABIC_YEMEN, "ar_YE", LANG_ARABIC , SUBLANG_ARABIC_YEMEN , wxLayout_RightToLeft, "Arabic (Yemen)")
3542 LNG(wxLANGUAGE_ARMENIAN, "hy" , LANG_ARMENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Armenian")
3543 LNG(wxLANGUAGE_ASSAMESE, "as" , LANG_ASSAMESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Assamese")
3544 LNG(wxLANGUAGE_AYMARA, "ay" , 0 , 0 , wxLayout_LeftToRight, "Aymara")
3545 LNG(wxLANGUAGE_AZERI, "az" , LANG_AZERI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Azeri")
3546 LNG(wxLANGUAGE_AZERI_CYRILLIC, "az" , LANG_AZERI , SUBLANG_AZERI_CYRILLIC , wxLayout_LeftToRight, "Azeri (Cyrillic)")
3547 LNG(wxLANGUAGE_AZERI_LATIN, "az" , LANG_AZERI , SUBLANG_AZERI_LATIN , wxLayout_LeftToRight, "Azeri (Latin)")
3548 LNG(wxLANGUAGE_BASHKIR, "ba" , 0 , 0 , wxLayout_LeftToRight, "Bashkir")
3549 LNG(wxLANGUAGE_BASQUE, "eu_ES", LANG_BASQUE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Basque")
3550 LNG(wxLANGUAGE_BELARUSIAN, "be_BY", LANG_BELARUSIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Belarusian")
3551 LNG(wxLANGUAGE_BENGALI, "bn" , LANG_BENGALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bengali")
3552 LNG(wxLANGUAGE_BHUTANI, "dz" , 0 , 0 , wxLayout_LeftToRight, "Bhutani")
3553 LNG(wxLANGUAGE_BIHARI, "bh" , 0 , 0 , wxLayout_LeftToRight, "Bihari")
3554 LNG(wxLANGUAGE_BISLAMA, "bi" , 0 , 0 , wxLayout_LeftToRight, "Bislama")
3555 LNG(wxLANGUAGE_BRETON, "br" , 0 , 0 , wxLayout_LeftToRight, "Breton")
3556 LNG(wxLANGUAGE_BULGARIAN, "bg_BG", LANG_BULGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Bulgarian")
3557 LNG(wxLANGUAGE_BURMESE, "my" , 0 , 0 , wxLayout_LeftToRight, "Burmese")
3558 LNG(wxLANGUAGE_CAMBODIAN, "km" , 0 , 0 , wxLayout_LeftToRight, "Cambodian")
3559 LNG(wxLANGUAGE_CATALAN, "ca_ES", LANG_CATALAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Catalan")
3560 LNG(wxLANGUAGE_CHINESE, "zh_TW", LANG_CHINESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Chinese")
3561 LNG(wxLANGUAGE_CHINESE_SIMPLIFIED, "zh_CN", LANG_CHINESE , SUBLANG_CHINESE_SIMPLIFIED , wxLayout_LeftToRight, "Chinese (Simplified)")
3562 LNG(wxLANGUAGE_CHINESE_TRADITIONAL, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Traditional)")
3563 LNG(wxLANGUAGE_CHINESE_HONGKONG, "zh_HK", LANG_CHINESE , SUBLANG_CHINESE_HONGKONG , wxLayout_LeftToRight, "Chinese (Hongkong)")
3564 LNG(wxLANGUAGE_CHINESE_MACAU, "zh_MO", LANG_CHINESE , SUBLANG_CHINESE_MACAU , wxLayout_LeftToRight, "Chinese (Macau)")
3565 LNG(wxLANGUAGE_CHINESE_SINGAPORE, "zh_SG", LANG_CHINESE , SUBLANG_CHINESE_SINGAPORE , wxLayout_LeftToRight, "Chinese (Singapore)")
3566 LNG(wxLANGUAGE_CHINESE_TAIWAN, "zh_TW", LANG_CHINESE , SUBLANG_CHINESE_TRADITIONAL , wxLayout_LeftToRight, "Chinese (Taiwan)")
3567 LNG(wxLANGUAGE_CORSICAN, "co" , 0 , 0 , wxLayout_LeftToRight, "Corsican")
3568 LNG(wxLANGUAGE_CROATIAN, "hr_HR", LANG_CROATIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Croatian")
3569 LNG(wxLANGUAGE_CZECH, "cs_CZ", LANG_CZECH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Czech")
3570 LNG(wxLANGUAGE_DANISH, "da_DK", LANG_DANISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Danish")
3571 LNG(wxLANGUAGE_DUTCH, "nl_NL", LANG_DUTCH , SUBLANG_DUTCH , wxLayout_LeftToRight, "Dutch")
3572 LNG(wxLANGUAGE_DUTCH_BELGIAN, "nl_BE", LANG_DUTCH , SUBLANG_DUTCH_BELGIAN , wxLayout_LeftToRight, "Dutch (Belgian)")
3573 LNG(wxLANGUAGE_ENGLISH, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English")
3574 LNG(wxLANGUAGE_ENGLISH_UK, "en_GB", LANG_ENGLISH , SUBLANG_ENGLISH_UK , wxLayout_LeftToRight, "English (U.K.)")
3575 LNG(wxLANGUAGE_ENGLISH_US, "en_US", LANG_ENGLISH , SUBLANG_ENGLISH_US , wxLayout_LeftToRight, "English (U.S.)")
3576 LNG(wxLANGUAGE_ENGLISH_AUSTRALIA, "en_AU", LANG_ENGLISH , SUBLANG_ENGLISH_AUS , wxLayout_LeftToRight, "English (Australia)")
3577 LNG(wxLANGUAGE_ENGLISH_BELIZE, "en_BZ", LANG_ENGLISH , SUBLANG_ENGLISH_BELIZE , wxLayout_LeftToRight, "English (Belize)")
3578 LNG(wxLANGUAGE_ENGLISH_BOTSWANA, "en_BW", 0 , 0 , wxLayout_LeftToRight, "English (Botswana)")
3579 LNG(wxLANGUAGE_ENGLISH_CANADA, "en_CA", LANG_ENGLISH , SUBLANG_ENGLISH_CAN , wxLayout_LeftToRight, "English (Canada)")
3580 LNG(wxLANGUAGE_ENGLISH_CARIBBEAN, "en_CB", LANG_ENGLISH , SUBLANG_ENGLISH_CARIBBEAN , wxLayout_LeftToRight, "English (Caribbean)")
3581 LNG(wxLANGUAGE_ENGLISH_DENMARK, "en_DK", 0 , 0 , wxLayout_LeftToRight, "English (Denmark)")
3582 LNG(wxLANGUAGE_ENGLISH_EIRE, "en_IE", LANG_ENGLISH , SUBLANG_ENGLISH_EIRE , wxLayout_LeftToRight, "English (Eire)")
3583 LNG(wxLANGUAGE_ENGLISH_JAMAICA, "en_JM", LANG_ENGLISH , SUBLANG_ENGLISH_JAMAICA , wxLayout_LeftToRight, "English (Jamaica)")
3584 LNG(wxLANGUAGE_ENGLISH_NEW_ZEALAND, "en_NZ", LANG_ENGLISH , SUBLANG_ENGLISH_NZ , wxLayout_LeftToRight, "English (New Zealand)")
3585 LNG(wxLANGUAGE_ENGLISH_PHILIPPINES, "en_PH", LANG_ENGLISH , SUBLANG_ENGLISH_PHILIPPINES , wxLayout_LeftToRight, "English (Philippines)")
3586 LNG(wxLANGUAGE_ENGLISH_SOUTH_AFRICA, "en_ZA", LANG_ENGLISH , SUBLANG_ENGLISH_SOUTH_AFRICA , wxLayout_LeftToRight, "English (South Africa)")
3587 LNG(wxLANGUAGE_ENGLISH_TRINIDAD, "en_TT", LANG_ENGLISH , SUBLANG_ENGLISH_TRINIDAD , wxLayout_LeftToRight, "English (Trinidad)")
3588 LNG(wxLANGUAGE_ENGLISH_ZIMBABWE, "en_ZW", LANG_ENGLISH , SUBLANG_ENGLISH_ZIMBABWE , wxLayout_LeftToRight, "English (Zimbabwe)")
3589 LNG(wxLANGUAGE_ESPERANTO, "eo" , 0 , 0 , wxLayout_LeftToRight, "Esperanto")
3590 LNG(wxLANGUAGE_ESTONIAN, "et_EE", LANG_ESTONIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Estonian")
3591 LNG(wxLANGUAGE_FAEROESE, "fo_FO", LANG_FAEROESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Faeroese")
3592 LNG(wxLANGUAGE_FARSI, "fa_IR", LANG_FARSI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Farsi")
3593 LNG(wxLANGUAGE_FIJI, "fj" , 0 , 0 , wxLayout_LeftToRight, "Fiji")
3594 LNG(wxLANGUAGE_FINNISH, "fi_FI", LANG_FINNISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Finnish")
3595 LNG(wxLANGUAGE_FRENCH, "fr_FR", LANG_FRENCH , SUBLANG_FRENCH , wxLayout_LeftToRight, "French")
3596 LNG(wxLANGUAGE_FRENCH_BELGIAN, "fr_BE", LANG_FRENCH , SUBLANG_FRENCH_BELGIAN , wxLayout_LeftToRight, "French (Belgian)")
3597 LNG(wxLANGUAGE_FRENCH_CANADIAN, "fr_CA", LANG_FRENCH , SUBLANG_FRENCH_CANADIAN , wxLayout_LeftToRight, "French (Canadian)")
3598 LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , wxLayout_LeftToRight, "French (Luxembourg)")
3599 LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , wxLayout_LeftToRight, "French (Monaco)")
3600 LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , wxLayout_LeftToRight, "French (Swiss)")
3601 LNG(wxLANGUAGE_FRISIAN, "fy" , 0 , 0 , wxLayout_LeftToRight, "Frisian")
3602 LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , wxLayout_LeftToRight, "Galician")
3603 LNG(wxLANGUAGE_GEORGIAN, "ka" , LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian")
3604 LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , wxLayout_LeftToRight, "German")
3605 LNG(wxLANGUAGE_GERMAN_AUSTRIAN, "de_AT", LANG_GERMAN , SUBLANG_GERMAN_AUSTRIAN , wxLayout_LeftToRight, "German (Austrian)")
3606 LNG(wxLANGUAGE_GERMAN_BELGIUM, "de_BE", 0 , 0 , wxLayout_LeftToRight, "German (Belgium)")
3607 LNG(wxLANGUAGE_GERMAN_LIECHTENSTEIN, "de_LI", LANG_GERMAN , SUBLANG_GERMAN_LIECHTENSTEIN , wxLayout_LeftToRight, "German (Liechtenstein)")
3608 LNG(wxLANGUAGE_GERMAN_LUXEMBOURG, "de_LU", LANG_GERMAN , SUBLANG_GERMAN_LUXEMBOURG , wxLayout_LeftToRight, "German (Luxembourg)")
3609 LNG(wxLANGUAGE_GERMAN_SWISS, "de_CH", LANG_GERMAN , SUBLANG_GERMAN_SWISS , wxLayout_LeftToRight, "German (Swiss)")
3610 LNG(wxLANGUAGE_GREEK, "el_GR", LANG_GREEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Greek")
3611 LNG(wxLANGUAGE_GREENLANDIC, "kl_GL", 0 , 0 , wxLayout_LeftToRight, "Greenlandic")
3612 LNG(wxLANGUAGE_GUARANI, "gn" , 0 , 0 , wxLayout_LeftToRight, "Guarani")
3613 LNG(wxLANGUAGE_GUJARATI, "gu" , LANG_GUJARATI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Gujarati")
3614 LNG(wxLANGUAGE_HAUSA, "ha" , 0 , 0 , wxLayout_LeftToRight, "Hausa")
3615 LNG(wxLANGUAGE_HEBREW, "he_IL", LANG_HEBREW , SUBLANG_DEFAULT , wxLayout_RightToLeft, "Hebrew")
3616 LNG(wxLANGUAGE_HINDI, "hi_IN", LANG_HINDI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hindi")
3617 LNG(wxLANGUAGE_HUNGARIAN, "hu_HU", LANG_HUNGARIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Hungarian")
3618 LNG(wxLANGUAGE_ICELANDIC, "is_IS", LANG_ICELANDIC , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Icelandic")
3619 LNG(wxLANGUAGE_INDONESIAN, "id_ID", LANG_INDONESIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Indonesian")
3620 LNG(wxLANGUAGE_INTERLINGUA, "ia" , 0 , 0 , wxLayout_LeftToRight, "Interlingua")
3621 LNG(wxLANGUAGE_INTERLINGUE, "ie" , 0 , 0 , wxLayout_LeftToRight, "Interlingue")
3622 LNG(wxLANGUAGE_INUKTITUT, "iu" , 0 , 0 , wxLayout_LeftToRight, "Inuktitut")
3623 LNG(wxLANGUAGE_INUPIAK, "ik" , 0 , 0 , wxLayout_LeftToRight, "Inupiak")
3624 LNG(wxLANGUAGE_IRISH, "ga_IE", 0 , 0 , wxLayout_LeftToRight, "Irish")
3625 LNG(wxLANGUAGE_ITALIAN, "it_IT", LANG_ITALIAN , SUBLANG_ITALIAN , wxLayout_LeftToRight, "Italian")
3626 LNG(wxLANGUAGE_ITALIAN_SWISS, "it_CH", LANG_ITALIAN , SUBLANG_ITALIAN_SWISS , wxLayout_LeftToRight, "Italian (Swiss)")
3627 LNG(wxLANGUAGE_JAPANESE, "ja_JP", LANG_JAPANESE , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Japanese")
3628 LNG(wxLANGUAGE_JAVANESE, "jw" , 0 , 0 , wxLayout_LeftToRight, "Javanese")
3629 LNG(wxLANGUAGE_KANNADA, "kn" , LANG_KANNADA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kannada")
3630 LNG(wxLANGUAGE_KASHMIRI, "ks" , LANG_KASHMIRI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kashmiri")
3631 LNG(wxLANGUAGE_KASHMIRI_INDIA, "ks_IN", LANG_KASHMIRI , SUBLANG_KASHMIRI_INDIA , wxLayout_LeftToRight, "Kashmiri (India)")
3632 LNG(wxLANGUAGE_KAZAKH, "kk" , LANG_KAZAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Kazakh")
3633 LNG(wxLANGUAGE_KERNEWEK, "kw_GB", 0 , 0 , wxLayout_LeftToRight, "Kernewek")
3634 LNG(wxLANGUAGE_KINYARWANDA, "rw" , 0 , 0 , wxLayout_LeftToRight, "Kinyarwanda")
3635 LNG(wxLANGUAGE_KIRGHIZ, "ky" , 0 , 0 , wxLayout_LeftToRight, "Kirghiz")
3636 LNG(wxLANGUAGE_KIRUNDI, "rn" , 0 , 0 , wxLayout_LeftToRight, "Kirundi")
3637 LNG(wxLANGUAGE_KONKANI, "" , LANG_KONKANI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Konkani")
3638 LNG(wxLANGUAGE_KOREAN, "ko_KR", LANG_KOREAN , SUBLANG_KOREAN , wxLayout_LeftToRight, "Korean")
3639 LNG(wxLANGUAGE_KURDISH, "ku" , 0 , 0 , wxLayout_LeftToRight, "Kurdish")
3640 LNG(wxLANGUAGE_LAOTHIAN, "lo" , 0 , 0 , wxLayout_LeftToRight, "Laothian")
3641 LNG(wxLANGUAGE_LATIN, "la" , 0 , 0 , wxLayout_LeftToRight, "Latin")
3642 LNG(wxLANGUAGE_LATVIAN, "lv_LV", LANG_LATVIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Latvian")
3643 LNG(wxLANGUAGE_LINGALA, "ln" , 0 , 0 , wxLayout_LeftToRight, "Lingala")
3644 LNG(wxLANGUAGE_LITHUANIAN, "lt_LT", LANG_LITHUANIAN, SUBLANG_LITHUANIAN , wxLayout_LeftToRight, "Lithuanian")
3645 LNG(wxLANGUAGE_MACEDONIAN, "mk_MK", LANG_MACEDONIAN, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Macedonian")
3646 LNG(wxLANGUAGE_MALAGASY, "mg" , 0 , 0 , wxLayout_LeftToRight, "Malagasy")
3647 LNG(wxLANGUAGE_MALAY, "ms_MY", LANG_MALAY , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malay")
3648 LNG(wxLANGUAGE_MALAYALAM, "ml" , LANG_MALAYALAM , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Malayalam")
3649 LNG(wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM, "ms_BN", LANG_MALAY , SUBLANG_MALAY_BRUNEI_DARUSSALAM , wxLayout_LeftToRight, "Malay (Brunei Darussalam)")
3650 LNG(wxLANGUAGE_MALAY_MALAYSIA, "ms_MY", LANG_MALAY , SUBLANG_MALAY_MALAYSIA , wxLayout_LeftToRight, "Malay (Malaysia)")
3651 LNG(wxLANGUAGE_MALTESE, "mt_MT", 0 , 0 , wxLayout_LeftToRight, "Maltese")
3652 LNG(wxLANGUAGE_MANIPURI, "" , LANG_MANIPURI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Manipuri")
3653 LNG(wxLANGUAGE_MAORI, "mi" , 0 , 0 , wxLayout_LeftToRight, "Maori")
3654 LNG(wxLANGUAGE_MARATHI, "mr_IN", LANG_MARATHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Marathi")
3655 LNG(wxLANGUAGE_MOLDAVIAN, "mo" , 0 , 0 , wxLayout_LeftToRight, "Moldavian")
3656 LNG(wxLANGUAGE_MONGOLIAN, "mn" , 0 , 0 , wxLayout_LeftToRight, "Mongolian")
3657 LNG(wxLANGUAGE_NAURU, "na" , 0 , 0 , wxLayout_LeftToRight, "Nauru")
3658 LNG(wxLANGUAGE_NEPALI, "ne" , LANG_NEPALI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Nepali")
3659 LNG(wxLANGUAGE_NEPALI_INDIA, "ne_IN", LANG_NEPALI , SUBLANG_NEPALI_INDIA , wxLayout_LeftToRight, "Nepali (India)")
3660 LNG(wxLANGUAGE_NORWEGIAN_BOKMAL, "nb_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_BOKMAL , wxLayout_LeftToRight, "Norwegian (Bokmal)")
3661 LNG(wxLANGUAGE_NORWEGIAN_NYNORSK, "nn_NO", LANG_NORWEGIAN , SUBLANG_NORWEGIAN_NYNORSK , wxLayout_LeftToRight, "Norwegian (Nynorsk)")
3662 LNG(wxLANGUAGE_OCCITAN, "oc" , 0 , 0 , wxLayout_LeftToRight, "Occitan")
3663 LNG(wxLANGUAGE_ORIYA, "or" , LANG_ORIYA , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Oriya")
3664 LNG(wxLANGUAGE_OROMO, "om" , 0 , 0 , wxLayout_LeftToRight, "(Afan) Oromo")
3665 LNG(wxLANGUAGE_PASHTO, "ps" , 0 , 0 , wxLayout_LeftToRight, "Pashto, Pushto")
3666 LNG(wxLANGUAGE_POLISH, "pl_PL", LANG_POLISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Polish")
3667 LNG(wxLANGUAGE_PORTUGUESE, "pt_PT", LANG_PORTUGUESE, SUBLANG_PORTUGUESE , wxLayout_LeftToRight, "Portuguese")
3668 LNG(wxLANGUAGE_PORTUGUESE_BRAZILIAN, "pt_BR", LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN , wxLayout_LeftToRight, "Portuguese (Brazilian)")
3669 LNG(wxLANGUAGE_PUNJABI, "pa" , LANG_PUNJABI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Punjabi")
3670 LNG(wxLANGUAGE_QUECHUA, "qu" , 0 , 0 , wxLayout_LeftToRight, "Quechua")
3671 LNG(wxLANGUAGE_RHAETO_ROMANCE, "rm" , 0 , 0 , wxLayout_LeftToRight, "Rhaeto-Romance")
3672 LNG(wxLANGUAGE_ROMANIAN, "ro_RO", LANG_ROMANIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Romanian")
3673 LNG(wxLANGUAGE_RUSSIAN, "ru_RU", LANG_RUSSIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Russian")
3674 LNG(wxLANGUAGE_RUSSIAN_UKRAINE, "ru_UA", 0 , 0 , wxLayout_LeftToRight, "Russian (Ukraine)")
3675 LNG(wxLANGUAGE_SAMOAN, "sm" , 0 , 0 , wxLayout_LeftToRight, "Samoan")
3676 LNG(wxLANGUAGE_SANGHO, "sg" , 0 , 0 , wxLayout_LeftToRight, "Sangho")
3677 LNG(wxLANGUAGE_SANSKRIT, "sa" , LANG_SANSKRIT , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sanskrit")
3678 LNG(wxLANGUAGE_SCOTS_GAELIC, "gd" , 0 , 0 , wxLayout_LeftToRight, "Scots Gaelic")
3679 LNG(wxLANGUAGE_SERBIAN_CYRILLIC, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_CYRILLIC , wxLayout_LeftToRight, "Serbian (Cyrillic)")
3680 LNG(wxLANGUAGE_SERBIAN_LATIN, "sr_YU", LANG_SERBIAN , SUBLANG_SERBIAN_LATIN , wxLayout_LeftToRight, "Serbian (Latin)")
3681 LNG(wxLANGUAGE_SERBO_CROATIAN, "sh" , 0 , 0 , wxLayout_LeftToRight, "Serbo-Croatian")
3682 LNG(wxLANGUAGE_SESOTHO, "st" , 0 , 0 , wxLayout_LeftToRight, "Sesotho")
3683 LNG(wxLANGUAGE_SETSWANA, "tn" , 0 , 0 , wxLayout_LeftToRight, "Setswana")
3684 LNG(wxLANGUAGE_SHONA, "sn" , 0 , 0 , wxLayout_LeftToRight, "Shona")
3685 LNG(wxLANGUAGE_SINDHI, "sd" , LANG_SINDHI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Sindhi")
3686 LNG(wxLANGUAGE_SINHALESE, "si" , 0 , 0 , wxLayout_LeftToRight, "Sinhalese")
3687 LNG(wxLANGUAGE_SISWATI, "ss" , 0 , 0 , wxLayout_LeftToRight, "Siswati")
3688 LNG(wxLANGUAGE_SLOVAK, "sk_SK", LANG_SLOVAK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovak")
3689 LNG(wxLANGUAGE_SLOVENIAN, "sl_SI", LANG_SLOVENIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Slovenian")
3690 LNG(wxLANGUAGE_SOMALI, "so" , 0 , 0 , wxLayout_LeftToRight, "Somali")
3691 LNG(wxLANGUAGE_SPANISH, "es_ES", LANG_SPANISH , SUBLANG_SPANISH , wxLayout_LeftToRight, "Spanish")
3692 LNG(wxLANGUAGE_SPANISH_ARGENTINA, "es_AR", LANG_SPANISH , SUBLANG_SPANISH_ARGENTINA , wxLayout_LeftToRight, "Spanish (Argentina)")
3693 LNG(wxLANGUAGE_SPANISH_BOLIVIA, "es_BO", LANG_SPANISH , SUBLANG_SPANISH_BOLIVIA , wxLayout_LeftToRight, "Spanish (Bolivia)")
3694 LNG(wxLANGUAGE_SPANISH_CHILE, "es_CL", LANG_SPANISH , SUBLANG_SPANISH_CHILE , wxLayout_LeftToRight, "Spanish (Chile)")
3695 LNG(wxLANGUAGE_SPANISH_COLOMBIA, "es_CO", LANG_SPANISH , SUBLANG_SPANISH_COLOMBIA , wxLayout_LeftToRight, "Spanish (Colombia)")
3696 LNG(wxLANGUAGE_SPANISH_COSTA_RICA, "es_CR", LANG_SPANISH , SUBLANG_SPANISH_COSTA_RICA , wxLayout_LeftToRight, "Spanish (Costa Rica)")
3697 LNG(wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC, "es_DO", LANG_SPANISH , SUBLANG_SPANISH_DOMINICAN_REPUBLIC, wxLayout_LeftToRight, "Spanish (Dominican republic)")
3698 LNG(wxLANGUAGE_SPANISH_ECUADOR, "es_EC", LANG_SPANISH , SUBLANG_SPANISH_ECUADOR , wxLayout_LeftToRight, "Spanish (Ecuador)")
3699 LNG(wxLANGUAGE_SPANISH_EL_SALVADOR, "es_SV", LANG_SPANISH , SUBLANG_SPANISH_EL_SALVADOR , wxLayout_LeftToRight, "Spanish (El Salvador)")
3700 LNG(wxLANGUAGE_SPANISH_GUATEMALA, "es_GT", LANG_SPANISH , SUBLANG_SPANISH_GUATEMALA , wxLayout_LeftToRight, "Spanish (Guatemala)")
3701 LNG(wxLANGUAGE_SPANISH_HONDURAS, "es_HN", LANG_SPANISH , SUBLANG_SPANISH_HONDURAS , wxLayout_LeftToRight, "Spanish (Honduras)")
3702 LNG(wxLANGUAGE_SPANISH_MEXICAN, "es_MX", LANG_SPANISH , SUBLANG_SPANISH_MEXICAN , wxLayout_LeftToRight, "Spanish (Mexican)")
3703 LNG(wxLANGUAGE_SPANISH_MODERN, "es_ES", LANG_SPANISH , SUBLANG_SPANISH_MODERN , wxLayout_LeftToRight, "Spanish (Modern)")
3704 LNG(wxLANGUAGE_SPANISH_NICARAGUA, "es_NI", LANG_SPANISH , SUBLANG_SPANISH_NICARAGUA , wxLayout_LeftToRight, "Spanish (Nicaragua)")
3705 LNG(wxLANGUAGE_SPANISH_PANAMA, "es_PA", LANG_SPANISH , SUBLANG_SPANISH_PANAMA , wxLayout_LeftToRight, "Spanish (Panama)")
3706 LNG(wxLANGUAGE_SPANISH_PARAGUAY, "es_PY", LANG_SPANISH , SUBLANG_SPANISH_PARAGUAY , wxLayout_LeftToRight, "Spanish (Paraguay)")
3707 LNG(wxLANGUAGE_SPANISH_PERU, "es_PE", LANG_SPANISH , SUBLANG_SPANISH_PERU , wxLayout_LeftToRight, "Spanish (Peru)")
3708 LNG(wxLANGUAGE_SPANISH_PUERTO_RICO, "es_PR", LANG_SPANISH , SUBLANG_SPANISH_PUERTO_RICO , wxLayout_LeftToRight, "Spanish (Puerto Rico)")
3709 LNG(wxLANGUAGE_SPANISH_URUGUAY, "es_UY", LANG_SPANISH , SUBLANG_SPANISH_URUGUAY , wxLayout_LeftToRight, "Spanish (Uruguay)")
3710 LNG(wxLANGUAGE_SPANISH_US, "es_US", 0 , 0 , wxLayout_LeftToRight, "Spanish (U.S.)")
3711 LNG(wxLANGUAGE_SPANISH_VENEZUELA, "es_VE", LANG_SPANISH , SUBLANG_SPANISH_VENEZUELA , wxLayout_LeftToRight, "Spanish (Venezuela)")
3712 LNG(wxLANGUAGE_SUNDANESE, "su" , 0 , 0 , wxLayout_LeftToRight, "Sundanese")
3713 LNG(wxLANGUAGE_SWAHILI, "sw_KE", LANG_SWAHILI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Swahili")
3714 LNG(wxLANGUAGE_SWEDISH, "sv_SE", LANG_SWEDISH , SUBLANG_SWEDISH , wxLayout_LeftToRight, "Swedish")
3715 LNG(wxLANGUAGE_SWEDISH_FINLAND, "sv_FI", LANG_SWEDISH , SUBLANG_SWEDISH_FINLAND , wxLayout_LeftToRight, "Swedish (Finland)")
3716 LNG(wxLANGUAGE_TAGALOG, "tl_PH", 0 , 0 , wxLayout_LeftToRight, "Tagalog")
3717 LNG(wxLANGUAGE_TAJIK, "tg" , 0 , 0 , wxLayout_LeftToRight, "Tajik")
3718 LNG(wxLANGUAGE_TAMIL, "ta" , LANG_TAMIL , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tamil")
3719 LNG(wxLANGUAGE_TATAR, "tt" , LANG_TATAR , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Tatar")
3720 LNG(wxLANGUAGE_TELUGU, "te" , LANG_TELUGU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Telugu")
3721 LNG(wxLANGUAGE_THAI, "th_TH", LANG_THAI , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Thai")
3722 LNG(wxLANGUAGE_TIBETAN, "bo" , 0 , 0 , wxLayout_LeftToRight, "Tibetan")
3723 LNG(wxLANGUAGE_TIGRINYA, "ti" , 0 , 0 , wxLayout_LeftToRight, "Tigrinya")
3724 LNG(wxLANGUAGE_TONGA, "to" , 0 , 0 , wxLayout_LeftToRight, "Tonga")
3725 LNG(wxLANGUAGE_TSONGA, "ts" , 0 , 0 , wxLayout_LeftToRight, "Tsonga")
3726 LNG(wxLANGUAGE_TURKISH, "tr_TR", LANG_TURKISH , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Turkish")
3727 LNG(wxLANGUAGE_TURKMEN, "tk" , 0 , 0 , wxLayout_LeftToRight, "Turkmen")
3728 LNG(wxLANGUAGE_TWI, "tw" , 0 , 0 , wxLayout_LeftToRight, "Twi")
3729 LNG(wxLANGUAGE_UIGHUR, "ug" , 0 , 0 , wxLayout_LeftToRight, "Uighur")
3730 LNG(wxLANGUAGE_UKRAINIAN, "uk_UA", LANG_UKRAINIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Ukrainian")
3731 LNG(wxLANGUAGE_URDU, "ur" , LANG_URDU , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Urdu")
3732 LNG(wxLANGUAGE_URDU_INDIA, "ur_IN", LANG_URDU , SUBLANG_URDU_INDIA , wxLayout_LeftToRight, "Urdu (India)")
3733 LNG(wxLANGUAGE_URDU_PAKISTAN, "ur_PK", LANG_URDU , SUBLANG_URDU_PAKISTAN , wxLayout_LeftToRight, "Urdu (Pakistan)")
3734 LNG(wxLANGUAGE_UZBEK, "uz" , LANG_UZBEK , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Uzbek")
3735 LNG(wxLANGUAGE_UZBEK_CYRILLIC, "uz" , LANG_UZBEK , SUBLANG_UZBEK_CYRILLIC , wxLayout_LeftToRight, "Uzbek (Cyrillic)")
3736 LNG(wxLANGUAGE_UZBEK_LATIN, "uz" , LANG_UZBEK , SUBLANG_UZBEK_LATIN , wxLayout_LeftToRight, "Uzbek (Latin)")
3737 LNG(wxLANGUAGE_VIETNAMESE, "vi_VN", LANG_VIETNAMESE, SUBLANG_DEFAULT , wxLayout_LeftToRight, "Vietnamese")
3738 LNG(wxLANGUAGE_VOLAPUK, "vo" , 0 , 0 , wxLayout_LeftToRight, "Volapuk")
3739 LNG(wxLANGUAGE_WELSH, "cy" , 0 , 0 , wxLayout_LeftToRight, "Welsh")
3740 LNG(wxLANGUAGE_WOLOF, "wo" , 0 , 0 , wxLayout_LeftToRight, "Wolof")
3741 LNG(wxLANGUAGE_XHOSA, "xh" , 0 , 0 , wxLayout_LeftToRight, "Xhosa")
3742 LNG(wxLANGUAGE_YIDDISH, "yi" , 0 , 0 , wxLayout_LeftToRight, "Yiddish")
3743 LNG(wxLANGUAGE_YORUBA, "yo" , 0 , 0 , wxLayout_LeftToRight, "Yoruba")
3744 LNG(wxLANGUAGE_ZHUANG, "za" , 0 , 0 , wxLayout_LeftToRight, "Zhuang")
3745 LNG(wxLANGUAGE_ZULU, "zu" , 0 , 0 , wxLayout_LeftToRight, "Zulu")
3746 }
3747 #undef LNG
3748
3749 // --- --- --- generated code ends here --- --- ---
3750
3751 #endif // wxUSE_INTL