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