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