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