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