1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/intl.cpp
3 // Purpose: Internationalization and localisation for wxWidgets
4 // Author: Vadim Zeitlin
5 // Modified by: Michael N. Filippov <michael@idisys.iae.nsk.su>
6 // (2003/09/30 - PluralForms support)
9 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
29 // The following define is needed by Innotek's libc to
30 // make the definition of struct localeconv available.
31 #define __INTERNAL_DEFS
37 #include "wx/dynarray.h"
38 #include "wx/string.h"
43 #include "wx/hashmap.h"
44 #include "wx/module.h"
54 #ifdef HAVE_LANGINFO_H
59 #include "wx/msw/private.h"
60 #elif defined(__UNIX_LIKE__)
61 #include "wx/fontmap.h" // for CharsetToEncoding()
65 #include "wx/filename.h"
66 #include "wx/tokenzr.h"
67 #include "wx/fontmap.h"
68 #include "wx/scopedptr.h"
69 #include "wx/apptrait.h"
70 #include "wx/stdpaths.h"
71 #include "wx/hashset.h"
73 #if defined(__WXOSX__)
74 #include "wx/osx/core/cfref.h"
75 #include <CoreFoundation/CFLocale.h>
76 #include <CoreFoundation/CFDateFormatter.h>
77 #include "wx/osx/core/cfstring.h"
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
84 // this should *not* be wxChar, this type must have exactly 8 bits!
85 typedef wxUint8 size_t8
;
86 typedef wxUint32 size_t32
;
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 // magic number identifying the .mo format file
93 const size_t32 MSGCATALOG_MAGIC
= 0x950412de;
94 const size_t32 MSGCATALOG_MAGIC_SW
= 0xde120495;
96 // the constants describing the format of ll_CC locale string
97 static const size_t LEN_LANG
= 2;
98 static const size_t LEN_SUBLANG
= 2;
99 static const size_t LEN_FULL
= LEN_LANG
+ 1 + LEN_SUBLANG
; // 1 for '_'
101 #define TRACE_I18N wxS("i18n")
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 static wxLocale
*wxSetLocale(wxLocale
*pLocale
);
112 // get just the language part
113 inline wxString
ExtractLang(const wxString
& langFull
)
115 return langFull
.Left(LEN_LANG
);
118 // helper functions of GetSystemLanguage()
121 // get everything else (including the leading '_')
122 inline wxString
ExtractNotLang(const wxString
& langFull
)
124 return langFull
.Mid(LEN_LANG
);
129 } // anonymous namespace
131 // ----------------------------------------------------------------------------
132 // Plural forms parser
133 // ----------------------------------------------------------------------------
139 LogicalOrExpression '?' Expression ':' Expression
143 LogicalAndExpression "||" LogicalOrExpression // to (a || b) || c
146 LogicalAndExpression:
147 EqualityExpression "&&" LogicalAndExpression // to (a && b) && c
151 RelationalExpression "==" RelationalExperession
152 RelationalExpression "!=" RelationalExperession
155 RelationalExpression:
156 MultiplicativeExpression '>' MultiplicativeExpression
157 MultiplicativeExpression '<' MultiplicativeExpression
158 MultiplicativeExpression ">=" MultiplicativeExpression
159 MultiplicativeExpression "<=" MultiplicativeExpression
160 MultiplicativeExpression
162 MultiplicativeExpression:
163 PmExpression '%' PmExpression
172 class wxPluralFormsToken
177 T_ERROR
, T_EOF
, T_NUMBER
, T_N
, T_PLURAL
, T_NPLURALS
, T_EQUAL
, T_ASSIGN
,
178 T_GREATER
, T_GREATER_OR_EQUAL
, T_LESS
, T_LESS_OR_EQUAL
,
179 T_REMINDER
, T_NOT_EQUAL
,
180 T_LOGICAL_AND
, T_LOGICAL_OR
, T_QUESTION
, T_COLON
, T_SEMICOLON
,
181 T_LEFT_BRACKET
, T_RIGHT_BRACKET
183 Type
type() const { return m_type
; }
184 void setType(Type type
) { m_type
= type
; }
187 Number
number() const { return m_number
; }
188 void setNumber(Number num
) { m_number
= num
; }
195 class wxPluralFormsScanner
198 wxPluralFormsScanner(const char* s
);
199 const wxPluralFormsToken
& token() const { return m_token
; }
200 bool nextToken(); // returns false if error
203 wxPluralFormsToken m_token
;
206 wxPluralFormsScanner::wxPluralFormsScanner(const char* s
) : m_s(s
)
211 bool wxPluralFormsScanner::nextToken()
213 wxPluralFormsToken::Type type
= wxPluralFormsToken::T_ERROR
;
214 while (isspace((unsigned char) *m_s
))
220 type
= wxPluralFormsToken::T_EOF
;
222 else if (isdigit((unsigned char) *m_s
))
224 wxPluralFormsToken::Number number
= *m_s
++ - '0';
225 while (isdigit((unsigned char) *m_s
))
227 number
= number
* 10 + (*m_s
++ - '0');
229 m_token
.setNumber(number
);
230 type
= wxPluralFormsToken::T_NUMBER
;
232 else if (isalpha((unsigned char) *m_s
))
234 const char* begin
= m_s
++;
235 while (isalnum((unsigned char) *m_s
))
239 size_t size
= m_s
- begin
;
240 if (size
== 1 && memcmp(begin
, "n", size
) == 0)
242 type
= wxPluralFormsToken::T_N
;
244 else if (size
== 6 && memcmp(begin
, "plural", size
) == 0)
246 type
= wxPluralFormsToken::T_PLURAL
;
248 else if (size
== 8 && memcmp(begin
, "nplurals", size
) == 0)
250 type
= wxPluralFormsToken::T_NPLURALS
;
253 else if (*m_s
== '=')
259 type
= wxPluralFormsToken::T_EQUAL
;
263 type
= wxPluralFormsToken::T_ASSIGN
;
266 else if (*m_s
== '>')
272 type
= wxPluralFormsToken::T_GREATER_OR_EQUAL
;
276 type
= wxPluralFormsToken::T_GREATER
;
279 else if (*m_s
== '<')
285 type
= wxPluralFormsToken::T_LESS_OR_EQUAL
;
289 type
= wxPluralFormsToken::T_LESS
;
292 else if (*m_s
== '%')
295 type
= wxPluralFormsToken::T_REMINDER
;
297 else if (*m_s
== '!' && m_s
[1] == '=')
300 type
= wxPluralFormsToken::T_NOT_EQUAL
;
302 else if (*m_s
== '&' && m_s
[1] == '&')
305 type
= wxPluralFormsToken::T_LOGICAL_AND
;
307 else if (*m_s
== '|' && m_s
[1] == '|')
310 type
= wxPluralFormsToken::T_LOGICAL_OR
;
312 else if (*m_s
== '?')
315 type
= wxPluralFormsToken::T_QUESTION
;
317 else if (*m_s
== ':')
320 type
= wxPluralFormsToken::T_COLON
;
321 } else if (*m_s
== ';') {
323 type
= wxPluralFormsToken::T_SEMICOLON
;
325 else if (*m_s
== '(')
328 type
= wxPluralFormsToken::T_LEFT_BRACKET
;
330 else if (*m_s
== ')')
333 type
= wxPluralFormsToken::T_RIGHT_BRACKET
;
335 m_token
.setType(type
);
336 return type
!= wxPluralFormsToken::T_ERROR
;
339 class wxPluralFormsNode
;
341 // NB: Can't use wxDEFINE_SCOPED_PTR_TYPE because wxPluralFormsNode is not
342 // fully defined yet:
343 class wxPluralFormsNodePtr
346 wxPluralFormsNodePtr(wxPluralFormsNode
*p
= NULL
) : m_p(p
) {}
347 ~wxPluralFormsNodePtr();
348 wxPluralFormsNode
& operator*() const { return *m_p
; }
349 wxPluralFormsNode
* operator->() const { return m_p
; }
350 wxPluralFormsNode
* get() const { return m_p
; }
351 wxPluralFormsNode
* release();
352 void reset(wxPluralFormsNode
*p
);
355 wxPluralFormsNode
*m_p
;
358 class wxPluralFormsNode
361 wxPluralFormsNode(const wxPluralFormsToken
& token
) : m_token(token
) {}
362 const wxPluralFormsToken
& token() const { return m_token
; }
363 const wxPluralFormsNode
* node(size_t i
) const
364 { return m_nodes
[i
].get(); }
365 void setNode(size_t i
, wxPluralFormsNode
* n
);
366 wxPluralFormsNode
* releaseNode(size_t i
);
367 wxPluralFormsToken::Number
evaluate(wxPluralFormsToken::Number n
) const;
370 wxPluralFormsToken m_token
;
371 wxPluralFormsNodePtr m_nodes
[3];
374 wxPluralFormsNodePtr::~wxPluralFormsNodePtr()
378 wxPluralFormsNode
* wxPluralFormsNodePtr::release()
380 wxPluralFormsNode
*p
= m_p
;
384 void wxPluralFormsNodePtr::reset(wxPluralFormsNode
*p
)
394 void wxPluralFormsNode::setNode(size_t i
, wxPluralFormsNode
* n
)
399 wxPluralFormsNode
* wxPluralFormsNode::releaseNode(size_t i
)
401 return m_nodes
[i
].release();
404 wxPluralFormsToken::Number
405 wxPluralFormsNode::evaluate(wxPluralFormsToken::Number n
) const
407 switch (token().type())
410 case wxPluralFormsToken::T_NUMBER
:
411 return token().number();
412 case wxPluralFormsToken::T_N
:
415 case wxPluralFormsToken::T_EQUAL
:
416 return node(0)->evaluate(n
) == node(1)->evaluate(n
);
417 case wxPluralFormsToken::T_NOT_EQUAL
:
418 return node(0)->evaluate(n
) != node(1)->evaluate(n
);
419 case wxPluralFormsToken::T_GREATER
:
420 return node(0)->evaluate(n
) > node(1)->evaluate(n
);
421 case wxPluralFormsToken::T_GREATER_OR_EQUAL
:
422 return node(0)->evaluate(n
) >= node(1)->evaluate(n
);
423 case wxPluralFormsToken::T_LESS
:
424 return node(0)->evaluate(n
) < node(1)->evaluate(n
);
425 case wxPluralFormsToken::T_LESS_OR_EQUAL
:
426 return node(0)->evaluate(n
) <= node(1)->evaluate(n
);
427 case wxPluralFormsToken::T_REMINDER
:
429 wxPluralFormsToken::Number number
= node(1)->evaluate(n
);
432 return node(0)->evaluate(n
) % number
;
439 case wxPluralFormsToken::T_LOGICAL_AND
:
440 return node(0)->evaluate(n
) && node(1)->evaluate(n
);
441 case wxPluralFormsToken::T_LOGICAL_OR
:
442 return node(0)->evaluate(n
) || node(1)->evaluate(n
);
444 case wxPluralFormsToken::T_QUESTION
:
445 return node(0)->evaluate(n
)
446 ? node(1)->evaluate(n
)
447 : node(2)->evaluate(n
);
454 class wxPluralFormsCalculator
457 wxPluralFormsCalculator() : m_nplurals(0), m_plural(0) {}
459 // input: number, returns msgstr index
460 int evaluate(int n
) const;
462 // input: text after "Plural-Forms:" (e.g. "nplurals=2; plural=(n != 1);"),
463 // if s == 0, creates default handler
464 // returns 0 if error
465 static wxPluralFormsCalculator
* make(const char* s
= 0);
467 ~wxPluralFormsCalculator() {}
469 void init(wxPluralFormsToken::Number nplurals
, wxPluralFormsNode
* plural
);
472 wxPluralFormsToken::Number m_nplurals
;
473 wxPluralFormsNodePtr m_plural
;
476 wxDEFINE_SCOPED_PTR_TYPE(wxPluralFormsCalculator
)
478 void wxPluralFormsCalculator::init(wxPluralFormsToken::Number nplurals
,
479 wxPluralFormsNode
* plural
)
481 m_nplurals
= nplurals
;
482 m_plural
.reset(plural
);
485 int wxPluralFormsCalculator::evaluate(int n
) const
487 if (m_plural
.get() == 0)
491 wxPluralFormsToken::Number number
= m_plural
->evaluate(n
);
492 if (number
< 0 || number
> m_nplurals
)
500 class wxPluralFormsParser
503 wxPluralFormsParser(wxPluralFormsScanner
& scanner
) : m_scanner(scanner
) {}
504 bool parse(wxPluralFormsCalculator
& rCalculator
);
507 wxPluralFormsNode
* parsePlural();
508 // stops at T_SEMICOLON, returns 0 if error
509 wxPluralFormsScanner
& m_scanner
;
510 const wxPluralFormsToken
& token() const;
513 wxPluralFormsNode
* expression();
514 wxPluralFormsNode
* logicalOrExpression();
515 wxPluralFormsNode
* logicalAndExpression();
516 wxPluralFormsNode
* equalityExpression();
517 wxPluralFormsNode
* multiplicativeExpression();
518 wxPluralFormsNode
* relationalExpression();
519 wxPluralFormsNode
* pmExpression();
522 bool wxPluralFormsParser::parse(wxPluralFormsCalculator
& rCalculator
)
524 if (token().type() != wxPluralFormsToken::T_NPLURALS
)
528 if (token().type() != wxPluralFormsToken::T_ASSIGN
)
532 if (token().type() != wxPluralFormsToken::T_NUMBER
)
534 wxPluralFormsToken::Number nplurals
= token().number();
537 if (token().type() != wxPluralFormsToken::T_SEMICOLON
)
541 if (token().type() != wxPluralFormsToken::T_PLURAL
)
545 if (token().type() != wxPluralFormsToken::T_ASSIGN
)
549 wxPluralFormsNode
* plural
= parsePlural();
552 if (token().type() != wxPluralFormsToken::T_SEMICOLON
)
556 if (token().type() != wxPluralFormsToken::T_EOF
)
558 rCalculator
.init(nplurals
, plural
);
562 wxPluralFormsNode
* wxPluralFormsParser::parsePlural()
564 wxPluralFormsNode
* p
= expression();
569 wxPluralFormsNodePtr
n(p
);
570 if (token().type() != wxPluralFormsToken::T_SEMICOLON
)
577 const wxPluralFormsToken
& wxPluralFormsParser::token() const
579 return m_scanner
.token();
582 bool wxPluralFormsParser::nextToken()
584 if (!m_scanner
.nextToken())
589 wxPluralFormsNode
* wxPluralFormsParser::expression()
591 wxPluralFormsNode
* p
= logicalOrExpression();
594 wxPluralFormsNodePtr
n(p
);
595 if (token().type() == wxPluralFormsToken::T_QUESTION
)
597 wxPluralFormsNodePtr
qn(new wxPluralFormsNode(token()));
608 if (token().type() != wxPluralFormsToken::T_COLON
)
622 qn
->setNode(0, n
.release());
628 wxPluralFormsNode
*wxPluralFormsParser::logicalOrExpression()
630 wxPluralFormsNode
* p
= logicalAndExpression();
633 wxPluralFormsNodePtr
ln(p
);
634 if (token().type() == wxPluralFormsToken::T_LOGICAL_OR
)
636 wxPluralFormsNodePtr
un(new wxPluralFormsNode(token()));
641 p
= logicalOrExpression();
646 wxPluralFormsNodePtr
rn(p
); // right
647 if (rn
->token().type() == wxPluralFormsToken::T_LOGICAL_OR
)
649 // see logicalAndExpression comment
650 un
->setNode(0, ln
.release());
651 un
->setNode(1, rn
->releaseNode(0));
652 rn
->setNode(0, un
.release());
657 un
->setNode(0, ln
.release());
658 un
->setNode(1, rn
.release());
664 wxPluralFormsNode
* wxPluralFormsParser::logicalAndExpression()
666 wxPluralFormsNode
* p
= equalityExpression();
669 wxPluralFormsNodePtr
ln(p
); // left
670 if (token().type() == wxPluralFormsToken::T_LOGICAL_AND
)
672 wxPluralFormsNodePtr
un(new wxPluralFormsNode(token())); // up
677 p
= logicalAndExpression();
682 wxPluralFormsNodePtr
rn(p
); // right
683 if (rn
->token().type() == wxPluralFormsToken::T_LOGICAL_AND
)
685 // transform 1 && (2 && 3) -> (1 && 2) && 3
689 un
->setNode(0, ln
.release());
690 un
->setNode(1, rn
->releaseNode(0));
691 rn
->setNode(0, un
.release());
695 un
->setNode(0, ln
.release());
696 un
->setNode(1, rn
.release());
702 wxPluralFormsNode
* wxPluralFormsParser::equalityExpression()
704 wxPluralFormsNode
* p
= relationalExpression();
707 wxPluralFormsNodePtr
n(p
);
708 if (token().type() == wxPluralFormsToken::T_EQUAL
709 || token().type() == wxPluralFormsToken::T_NOT_EQUAL
)
711 wxPluralFormsNodePtr
qn(new wxPluralFormsNode(token()));
716 p
= relationalExpression();
722 qn
->setNode(0, n
.release());
728 wxPluralFormsNode
* wxPluralFormsParser::relationalExpression()
730 wxPluralFormsNode
* p
= multiplicativeExpression();
733 wxPluralFormsNodePtr
n(p
);
734 if (token().type() == wxPluralFormsToken::T_GREATER
735 || token().type() == wxPluralFormsToken::T_LESS
736 || token().type() == wxPluralFormsToken::T_GREATER_OR_EQUAL
737 || token().type() == wxPluralFormsToken::T_LESS_OR_EQUAL
)
739 wxPluralFormsNodePtr
qn(new wxPluralFormsNode(token()));
744 p
= multiplicativeExpression();
750 qn
->setNode(0, n
.release());
756 wxPluralFormsNode
* wxPluralFormsParser::multiplicativeExpression()
758 wxPluralFormsNode
* p
= pmExpression();
761 wxPluralFormsNodePtr
n(p
);
762 if (token().type() == wxPluralFormsToken::T_REMINDER
)
764 wxPluralFormsNodePtr
qn(new wxPluralFormsNode(token()));
775 qn
->setNode(0, n
.release());
781 wxPluralFormsNode
* wxPluralFormsParser::pmExpression()
783 wxPluralFormsNodePtr n
;
784 if (token().type() == wxPluralFormsToken::T_N
785 || token().type() == wxPluralFormsToken::T_NUMBER
)
787 n
.reset(new wxPluralFormsNode(token()));
793 else if (token().type() == wxPluralFormsToken::T_LEFT_BRACKET
) {
798 wxPluralFormsNode
* p
= expression();
804 if (token().type() != wxPluralFormsToken::T_RIGHT_BRACKET
)
820 wxPluralFormsCalculator
* wxPluralFormsCalculator::make(const char* s
)
822 wxPluralFormsCalculatorPtr
calculator(new wxPluralFormsCalculator
);
825 wxPluralFormsScanner
scanner(s
);
826 wxPluralFormsParser
p(scanner
);
827 if (!p
.parse(*calculator
))
832 return calculator
.release();
838 // ----------------------------------------------------------------------------
839 // wxMsgCatalogFile corresponds to one disk-file message catalog.
841 // This is a "low-level" class and is used only by wxMsgCatalog
842 // NOTE: for the documentation of the binary catalog (.MO) files refer to
843 // the GNU gettext manual:
844 // http://www.gnu.org/software/autoconf/manual/gettext/MO-Files.html
845 // ----------------------------------------------------------------------------
847 WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxString
, wxMessagesHash
);
849 class wxMsgCatalogFile
856 // load the catalog from disk (szDirPrefix corresponds to language)
857 bool Load(const wxString
& szDirPrefix
, const wxString
& szName
,
858 wxPluralFormsCalculatorPtr
& rPluralFormsCalculator
);
860 // fills the hash with string-translation pairs
861 bool FillHash(wxMessagesHash
& hash
, const wxString
& msgIdCharset
) const;
863 // return the charset of the strings in this catalog or empty string if
865 wxString
GetCharset() const { return m_charset
; }
868 // this implementation is binary compatible with GNU gettext() version 0.10
870 // an entry in the string table
871 struct wxMsgTableEntry
873 size_t32 nLen
; // length of the string
874 size_t32 ofsString
; // pointer to the string
877 // header of a .mo file
878 struct wxMsgCatalogHeader
880 size_t32 magic
, // offset +00: magic id
881 revision
, // +04: revision
882 numStrings
; // +08: number of strings in the file
883 size_t32 ofsOrigTable
, // +0C: start of original string table
884 ofsTransTable
; // +10: start of translated string table
885 size_t32 nHashSize
, // +14: hash table size
886 ofsHashTable
; // +18: offset of hash table start
889 // all data is stored here
890 wxMemoryBuffer m_data
;
893 size_t32 m_numStrings
; // number of strings in this domain
894 wxMsgTableEntry
*m_pOrigTable
, // pointer to original strings
895 *m_pTransTable
; // translated
897 wxString m_charset
; // from the message catalog header
900 // swap the 2 halves of 32 bit integer if needed
901 size_t32
Swap(size_t32 ui
) const
903 return m_bSwapped
? (ui
<< 24) | ((ui
& 0xff00) << 8) |
904 ((ui
>> 8) & 0xff00) | (ui
>> 24)
908 // just return the pointer to the start of the data as "char *" to
909 // facilitate doing pointer arithmetic with it
910 char *StringData() const
912 return static_cast<char *>(m_data
.GetData());
915 const char *StringAtOfs(wxMsgTableEntry
*pTable
, size_t32 n
) const
917 const wxMsgTableEntry
* const ent
= pTable
+ n
;
919 // this check could fail for a corrupt message catalog
920 size_t32 ofsString
= Swap(ent
->ofsString
);
921 if ( ofsString
+ Swap(ent
->nLen
) > m_data
.GetDataLen())
926 return StringData() + ofsString
;
929 bool m_bSwapped
; // wrong endianness?
931 wxDECLARE_NO_COPY_CLASS(wxMsgCatalogFile
);
935 // ----------------------------------------------------------------------------
936 // wxMsgCatalog corresponds to one loaded message catalog.
938 // This is a "low-level" class and is used only by wxLocale (that's why
939 // it's designed to be stored in a linked list)
940 // ----------------------------------------------------------------------------
946 wxMsgCatalog() { m_conv
= NULL
; }
950 // load the catalog from disk (szDirPrefix corresponds to language)
951 bool Load(const wxString
& dirPrefix
, const wxString
& name
,
952 const wxString
& msgIdCharset
);
954 // get name of the catalog
955 wxString
GetName() const { return m_name
; }
957 // get the translated string: returns NULL if not found
958 const wxString
*GetString(const wxString
& sz
, size_t n
= size_t(-1)) const;
960 // public variable pointing to the next element in a linked list (or NULL)
961 wxMsgCatalog
*m_pNext
;
964 wxMessagesHash m_messages
; // all messages in the catalog
965 wxString m_name
; // name of the domain
968 // the conversion corresponding to this catalog charset if we installed it
973 wxPluralFormsCalculatorPtr m_pluralFormsCalculator
;
976 // ----------------------------------------------------------------------------
978 // ----------------------------------------------------------------------------
980 // the list of the directories to search for message catalog files
981 static wxArrayString gs_searchPrefixes
;
983 // ============================================================================
985 // ============================================================================
987 // ----------------------------------------------------------------------------
989 // ----------------------------------------------------------------------------
993 // helper used by wxLanguageInfo::GetLocaleName() and elsewhere to determine
994 // whether the locale is Unicode-only (it is if this function returns empty
996 static wxString
wxGetANSICodePageForLocale(LCID lcid
)
1001 if ( ::GetLocaleInfo(lcid
, LOCALE_IDEFAULTANSICODEPAGE
,
1002 buffer
, WXSIZEOF(buffer
)) > 0 )
1004 if ( buffer
[0] != wxT('0') || buffer
[1] != wxT('\0') )
1006 //else: this locale doesn't use ANSI code page
1012 wxUint32
wxLanguageInfo::GetLCID() const
1014 return MAKELCID(MAKELANGID(WinLang
, WinSublang
), SORT_DEFAULT
);
1017 wxString
wxLanguageInfo::GetLocaleName() const
1021 const LCID lcid
= GetLCID();
1024 buffer
[0] = wxT('\0');
1025 if ( !::GetLocaleInfo(lcid
, LOCALE_SENGLANGUAGE
, buffer
, WXSIZEOF(buffer
)) )
1027 wxLogLastError(wxT("GetLocaleInfo(LOCALE_SENGLANGUAGE)"));
1032 if ( ::GetLocaleInfo(lcid
, LOCALE_SENGCOUNTRY
,
1033 buffer
, WXSIZEOF(buffer
)) > 0 )
1035 locale
<< wxT('_') << buffer
;
1038 const wxString cp
= wxGetANSICodePageForLocale(lcid
);
1041 locale
<< wxT('.') << cp
;
1049 // ----------------------------------------------------------------------------
1050 // wxMsgCatalogFile class
1051 // ----------------------------------------------------------------------------
1053 wxMsgCatalogFile::wxMsgCatalogFile()
1057 wxMsgCatalogFile::~wxMsgCatalogFile()
1061 // return the directories to search for message catalogs under the given
1062 // prefix, separated by wxPATH_SEP
1064 wxString
GetMsgCatalogSubdirs(const wxString
& prefix
, const wxString
& lang
)
1066 // Search first in Unix-standard prefix/lang/LC_MESSAGES, then in
1067 // prefix/lang and finally in just prefix.
1069 // Note that we use LC_MESSAGES on all platforms and not just Unix, because
1070 // it doesn't cost much to look into one more directory and doing it this
1071 // way has two important benefits:
1072 // a) we don't break compatibility with wx-2.6 and older by stopping to
1073 // look in a directory where the catalogs used to be and thus silently
1074 // breaking apps after they are recompiled against the latest wx
1075 // b) it makes it possible to package app's support files in the same
1076 // way on all target platforms
1077 const wxString pathPrefix
= wxFileName(prefix
, lang
).GetFullPath();
1079 wxString searchPath
;
1080 searchPath
.reserve(4*pathPrefix
.length());
1081 searchPath
<< pathPrefix
<< wxFILE_SEP_PATH
<< "LC_MESSAGES" << wxPATH_SEP
1082 << prefix
<< wxFILE_SEP_PATH
<< wxPATH_SEP
1088 // construct the search path for the given language
1089 static wxString
GetFullSearchPath(const wxString
& lang
)
1091 // first take the entries explicitly added by the program
1092 wxArrayString paths
;
1093 paths
.reserve(gs_searchPrefixes
.size() + 1);
1095 count
= gs_searchPrefixes
.size();
1096 for ( n
= 0; n
< count
; n
++ )
1098 paths
.Add(GetMsgCatalogSubdirs(gs_searchPrefixes
[n
], lang
));
1103 // then look in the standard location
1104 const wxString stdp
= wxStandardPaths::Get().
1105 GetLocalizedResourcesDir(lang
, wxStandardPaths::ResourceCat_Messages
);
1107 if ( paths
.Index(stdp
) == wxNOT_FOUND
)
1109 #endif // wxUSE_STDPATHS
1111 // last look in default locations
1113 // LC_PATH is a standard env var containing the search path for the .mo
1115 const char *pszLcPath
= wxGetenv("LC_PATH");
1118 const wxString lcp
= GetMsgCatalogSubdirs(pszLcPath
, lang
);
1119 if ( paths
.Index(lcp
) == wxNOT_FOUND
)
1123 // also add the one from where wxWin was installed:
1124 wxString wxp
= wxGetInstallPrefix();
1127 wxp
= GetMsgCatalogSubdirs(wxp
+ wxS("/share/locale"), lang
);
1128 if ( paths
.Index(wxp
) == wxNOT_FOUND
)
1134 // finally construct the full search path
1135 wxString searchPath
;
1136 searchPath
.reserve(500);
1137 count
= paths
.size();
1138 for ( n
= 0; n
< count
; n
++ )
1140 searchPath
+= paths
[n
];
1141 if ( n
!= count
- 1 )
1142 searchPath
+= wxPATH_SEP
;
1148 // open disk file and read in it's contents
1149 bool wxMsgCatalogFile::Load(const wxString
& szDirPrefix
, const wxString
& szName
,
1150 wxPluralFormsCalculatorPtr
& rPluralFormsCalculator
)
1152 wxCHECK_MSG( szDirPrefix
.length() >= LEN_LANG
, false,
1153 "invalid language specification" );
1155 wxString searchPath
;
1158 // first look for the catalog for this language and the current locale:
1159 // notice that we don't use the system name for the locale as this would
1160 // force us to install catalogs in different locations depending on the
1161 // system but always use the canonical name
1162 wxFontEncoding encSys
= wxLocale::GetSystemEncoding();
1163 if ( encSys
!= wxFONTENCODING_SYSTEM
)
1165 wxString
fullname(szDirPrefix
);
1166 fullname
<< wxS('.') << wxFontMapperBase::GetEncodingName(encSys
);
1167 searchPath
<< GetFullSearchPath(fullname
) << wxPATH_SEP
;
1169 #endif // wxUSE_FONTMAP
1172 searchPath
+= GetFullSearchPath(szDirPrefix
);
1173 if ( szDirPrefix
.length() > LEN_LANG
&& szDirPrefix
[LEN_LANG
] == wxS('_') )
1175 // also add just base locale name: for things like "fr_BE" (Belgium
1176 // French) we should use fall back on plain "fr" if no Belgium-specific
1177 // message catalogs exist
1178 searchPath
<< wxPATH_SEP
1179 << GetFullSearchPath(ExtractLang(szDirPrefix
));
1182 wxLogTrace(TRACE_I18N
, wxS("Looking for \"%s.mo\" in search path \"%s\""),
1183 szName
, searchPath
);
1185 wxFileName
fn(szName
);
1186 fn
.SetExt(wxS("mo"));
1188 wxString strFullName
;
1189 if ( !wxFindFileInPath(&strFullName
, searchPath
, fn
.GetFullPath()) )
1191 wxLogVerbose(_("catalog file for domain '%s' not found."), szName
);
1192 wxLogTrace(TRACE_I18N
, wxS("Catalog \"%s.mo\" not found"), szName
);
1196 // open file and read its data
1197 wxLogVerbose(_("using catalog '%s' from '%s'."), szName
, strFullName
.c_str());
1198 wxLogTrace(TRACE_I18N
, wxS("Using catalog \"%s\"."), strFullName
.c_str());
1200 wxFile
fileMsg(strFullName
);
1201 if ( !fileMsg
.IsOpened() )
1204 // get the file size (assume it is less than 4Gb...)
1205 wxFileOffset lenFile
= fileMsg
.Length();
1206 if ( lenFile
== wxInvalidOffset
)
1209 size_t nSize
= wx_truncate_cast(size_t, lenFile
);
1210 wxASSERT_MSG( nSize
== lenFile
+ size_t(0), wxS("message catalog bigger than 4GB?") );
1212 // read the whole file in memory
1213 if ( fileMsg
.Read(m_data
.GetWriteBuf(nSize
), nSize
) != lenFile
)
1216 m_data
.UngetWriteBuf(nSize
);
1220 bool bValid
= m_data
.GetDataLen() > sizeof(wxMsgCatalogHeader
);
1222 const wxMsgCatalogHeader
*pHeader
= (wxMsgCatalogHeader
*)m_data
.GetData();
1224 // we'll have to swap all the integers if it's true
1225 m_bSwapped
= pHeader
->magic
== MSGCATALOG_MAGIC_SW
;
1227 // check the magic number
1228 bValid
= m_bSwapped
|| pHeader
->magic
== MSGCATALOG_MAGIC
;
1232 // it's either too short or has incorrect magic number
1233 wxLogWarning(_("'%s' is not a valid message catalog."), strFullName
.c_str());
1239 m_numStrings
= Swap(pHeader
->numStrings
);
1240 m_pOrigTable
= (wxMsgTableEntry
*)(StringData() +
1241 Swap(pHeader
->ofsOrigTable
));
1242 m_pTransTable
= (wxMsgTableEntry
*)(StringData() +
1243 Swap(pHeader
->ofsTransTable
));
1245 // now parse catalog's header and try to extract catalog charset and
1246 // plural forms formula from it:
1248 const char* headerData
= StringAtOfs(m_pOrigTable
, 0);
1249 if ( headerData
&& headerData
[0] == '\0' )
1251 // Extract the charset:
1252 const char * const header
= StringAtOfs(m_pTransTable
, 0);
1254 cset
= strstr(header
, "Content-Type: text/plain; charset=");
1257 cset
+= 34; // strlen("Content-Type: text/plain; charset=")
1259 const char * const csetEnd
= strchr(cset
, '\n');
1262 m_charset
= wxString(cset
, csetEnd
- cset
);
1263 if ( m_charset
== wxS("CHARSET") )
1265 // "CHARSET" is not valid charset, but lazy translator
1270 // else: incorrectly filled Content-Type header
1272 // Extract plural forms:
1273 const char * plurals
= strstr(header
, "Plural-Forms:");
1276 plurals
+= 13; // strlen("Plural-Forms:")
1277 const char * const pluralsEnd
= strchr(plurals
, '\n');
1280 const size_t pluralsLen
= pluralsEnd
- plurals
;
1281 wxCharBuffer
buf(pluralsLen
);
1282 strncpy(buf
.data(), plurals
, pluralsLen
);
1283 wxPluralFormsCalculator
* const
1284 pCalculator
= wxPluralFormsCalculator::make(buf
);
1287 rPluralFormsCalculator
.reset(pCalculator
);
1291 wxLogVerbose(_("Failed to parse Plural-Forms: '%s'"),
1297 if ( !rPluralFormsCalculator
.get() )
1298 rPluralFormsCalculator
.reset(wxPluralFormsCalculator::make());
1301 // everything is fine
1305 bool wxMsgCatalogFile::FillHash(wxMessagesHash
& hash
,
1306 const wxString
& msgIdCharset
) const
1308 // conversion to use to convert catalog strings to the GUI encoding
1309 wxMBConv
*inputConv
,
1310 *inputConvPtr
= NULL
; // same as inputConv but safely deleteable
1312 if ( !m_charset
.empty() )
1314 #if !wxUSE_UNICODE && wxUSE_FONTMAP
1315 // determine if we need any conversion at all
1316 wxFontEncoding encCat
= wxFontMapperBase::GetEncodingFromName(m_charset
);
1317 if ( encCat
!= wxLocale::GetSystemEncoding() )
1321 inputConv
= new wxCSConv(m_charset
);
1324 else // no need or not possible to convert the encoding
1327 // we must somehow convert the narrow strings in the message catalog to
1328 // wide strings, so use the default conversion if we have no charset
1329 inputConv
= wxConvCurrent
;
1333 // conversion to apply to msgid strings before looking them up: we only
1334 // need it if the msgids are neither in 7 bit ASCII nor in the same
1335 // encoding as the catalog
1336 wxCSConv
*sourceConv
= msgIdCharset
.empty() || (msgIdCharset
== m_charset
)
1338 : new wxCSConv(msgIdCharset
);
1340 for (size_t32 i
= 0; i
< m_numStrings
; i
++)
1342 const char *data
= StringAtOfs(m_pOrigTable
, i
);
1344 return false; // may happen for invalid MO files
1348 msgid
= wxString(data
, *inputConv
);
1350 if ( inputConv
&& sourceConv
)
1351 msgid
= wxString(inputConv
->cMB2WC(data
), *sourceConv
);
1354 #endif // wxUSE_UNICODE
1356 data
= StringAtOfs(m_pTransTable
, i
);
1358 return false; // may happen for invalid MO files
1360 size_t length
= Swap(m_pTransTable
[i
].nLen
);
1363 while (offset
< length
)
1365 const char * const str
= data
+ offset
;
1369 msgstr
= wxString(str
, *inputConv
);
1372 msgstr
= wxString(inputConv
->cMB2WC(str
), *wxConvUI
);
1375 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
1377 if ( !msgstr
.empty() )
1379 hash
[index
== 0 ? msgid
: msgid
+ wxChar(index
)] = msgstr
;
1383 // IMPORTANT: accesses to the 'data' pointer are valid only for
1384 // the first 'length+1' bytes (GNU specs says that the
1385 // final NUL is not counted in length); using wxStrnlen()
1386 // we make sure we don't access memory beyond the valid range
1387 // (which otherwise may happen for invalid MO files):
1388 offset
+= wxStrnlen(str
, length
- offset
) + 1;
1394 delete inputConvPtr
;
1400 // ----------------------------------------------------------------------------
1401 // wxMsgCatalog class
1402 // ----------------------------------------------------------------------------
1405 wxMsgCatalog::~wxMsgCatalog()
1409 if ( wxConvUI
== m_conv
)
1411 // we only change wxConvUI if it points to wxConvLocal so we reset
1412 // it back to it too
1413 wxConvUI
= &wxConvLocal
;
1419 #endif // !wxUSE_UNICODE
1421 bool wxMsgCatalog::Load(const wxString
& dirPrefix
, const wxString
& name
,
1422 const wxString
& msgIdCharset
)
1424 wxMsgCatalogFile file
;
1428 if ( !file
.Load(dirPrefix
, name
, m_pluralFormsCalculator
) )
1431 if ( !file
.FillHash(m_messages
, msgIdCharset
) )
1437 const wxString
*wxMsgCatalog::GetString(const wxString
& str
, size_t n
) const
1440 if (n
!= size_t(-1))
1442 index
= m_pluralFormsCalculator
->evaluate(n
);
1444 wxMessagesHash::const_iterator i
;
1447 i
= m_messages
.find(wxString(str
) + wxChar(index
)); // plural
1451 i
= m_messages
.find(str
);
1454 if ( i
!= m_messages
.end() )
1462 // ----------------------------------------------------------------------------
1464 // ----------------------------------------------------------------------------
1466 #include "wx/arrimpl.cpp"
1467 WX_DECLARE_EXPORTED_OBJARRAY(wxLanguageInfo
, wxLanguageInfoArray
);
1468 WX_DEFINE_OBJARRAY(wxLanguageInfoArray
)
1470 wxLanguageInfoArray
*wxLocale::ms_languagesDB
= NULL
;
1472 /*static*/ void wxLocale::CreateLanguagesDB()
1474 if (ms_languagesDB
== NULL
)
1476 ms_languagesDB
= new wxLanguageInfoArray
;
1481 /*static*/ void wxLocale::DestroyLanguagesDB()
1483 delete ms_languagesDB
;
1484 ms_languagesDB
= NULL
;
1488 void wxLocale::DoCommonInit()
1490 m_pszOldLocale
= NULL
;
1492 m_pOldLocale
= wxSetLocale(this);
1495 m_language
= wxLANGUAGE_UNKNOWN
;
1496 m_initialized
= false;
1499 // NB: this function has (desired) side effect of changing current locale
1500 bool wxLocale::Init(const wxString
& name
,
1501 const wxString
& shortName
,
1502 const wxString
& locale
,
1504 #if WXWIN_COMPATIBILITY_2_8
1505 ,bool bConvertEncoding
1509 wxASSERT_MSG( !m_initialized
,
1510 wxS("you can't call wxLocale::Init more than once") );
1512 #if WXWIN_COMPATIBILITY_2_8
1513 wxASSERT_MSG( bConvertEncoding
,
1514 wxS("wxLocale::Init with bConvertEncoding=false is no longer supported, add charset to your catalogs") );
1517 m_initialized
= true;
1519 m_strShort
= shortName
;
1520 m_language
= wxLANGUAGE_UNKNOWN
;
1522 // change current locale (default: same as long name)
1523 wxString
szLocale(locale
);
1524 if ( szLocale
.empty() )
1526 // the argument to setlocale()
1527 szLocale
= shortName
;
1529 wxCHECK_MSG( !szLocale
.empty(), false,
1530 wxS("no locale to set in wxLocale::Init()") );
1533 const char *oldLocale
= wxSetlocale(LC_ALL
, szLocale
);
1535 m_pszOldLocale
= wxStrdup(oldLocale
);
1537 m_pszOldLocale
= NULL
;
1539 if ( m_pszOldLocale
== NULL
)
1541 wxLogError(_("locale '%s' can not be set."), szLocale
);
1544 // the short name will be used to look for catalog files as well,
1545 // so we need something here
1546 if ( m_strShort
.empty() ) {
1547 // FIXME I don't know how these 2 letter abbreviations are formed,
1548 // this wild guess is surely wrong
1549 if ( !szLocale
.empty() )
1551 m_strShort
+= (wxChar
)wxTolower(szLocale
[0]);
1552 if ( szLocale
.length() > 1 )
1553 m_strShort
+= (wxChar
)wxTolower(szLocale
[1]);
1557 // load the default catalog with wxWidgets standard messages
1562 bOk
= AddCatalog(wxS("wxstd"));
1564 // there may be a catalog with toolkit specific overrides, it is not
1565 // an error if this does not exist
1568 wxString
port(wxPlatformInfo::Get().GetPortIdName());
1569 if ( !port
.empty() )
1571 AddCatalog(port
.BeforeFirst(wxS('/')).MakeLower());
1580 #if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WXMAC__)
1581 static const char *wxSetlocaleTryUTF8(int c
, const wxString
& lc
)
1583 const char *l
= NULL
;
1585 // NB: We prefer to set UTF-8 locale if it's possible and only fall back to
1586 // non-UTF-8 locale if it fails
1592 buf2
= buf
+ wxS(".UTF-8");
1593 l
= wxSetlocale(c
, buf2
);
1596 buf2
= buf
+ wxS(".utf-8");
1597 l
= wxSetlocale(c
, buf2
);
1601 buf2
= buf
+ wxS(".UTF8");
1602 l
= wxSetlocale(c
, buf2
);
1606 buf2
= buf
+ wxS(".utf8");
1607 l
= wxSetlocale(c
, buf2
);
1611 // if we can't set UTF-8 locale, try non-UTF-8 one:
1613 l
= wxSetlocale(c
, lc
);
1618 #define wxSetlocaleTryUTF8(c, lc) wxSetlocale(c, lc)
1621 bool wxLocale::Init(int language
, int flags
)
1623 #if WXWIN_COMPATIBILITY_2_8
1624 wxASSERT_MSG( !(flags
& wxLOCALE_CONV_ENCODING
),
1625 wxS("wxLOCALE_CONV_ENCODING is no longer supported, add charset to your catalogs") );
1630 int lang
= language
;
1631 if (lang
== wxLANGUAGE_DEFAULT
)
1633 // auto detect the language
1634 lang
= GetSystemLanguage();
1637 // We failed to detect system language, so we will use English:
1638 if (lang
== wxLANGUAGE_UNKNOWN
)
1643 const wxLanguageInfo
*info
= GetLanguageInfo(lang
);
1645 // Unknown language:
1648 wxLogError(wxS("Unknown language %i."), lang
);
1652 wxString name
= info
->Description
;
1653 wxString canonical
= info
->CanonicalName
;
1657 #if defined(__OS2__)
1658 const char *retloc
= wxSetlocale(LC_ALL
, wxEmptyString
);
1659 #elif defined(__UNIX__) && !defined(__WXMAC__)
1660 if (language
!= wxLANGUAGE_DEFAULT
)
1661 locale
= info
->CanonicalName
;
1663 const char *retloc
= wxSetlocaleTryUTF8(LC_ALL
, locale
);
1665 const wxString langOnly
= ExtractLang(locale
);
1668 // Some C libraries don't like xx_YY form and require xx only
1669 retloc
= wxSetlocaleTryUTF8(LC_ALL
, langOnly
);
1673 // some systems (e.g. FreeBSD and HP-UX) don't have xx_YY aliases but
1674 // require the full xx_YY.encoding form, so try using UTF-8 because this is
1675 // the only thing we can do generically
1677 // TODO: add encodings applicable to each language to the lang DB and try
1678 // them all in turn here
1681 const wxChar
**names
=
1682 wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8
);
1685 retloc
= wxSetlocale(LC_ALL
, locale
+ wxS('.') + *names
++);
1690 #endif // wxUSE_FONTMAP
1694 // Some C libraries (namely glibc) still use old ISO 639,
1695 // so will translate the abbrev for them
1697 if ( langOnly
== wxS("he") )
1698 localeAlt
= wxS("iw") + ExtractNotLang(locale
);
1699 else if ( langOnly
== wxS("id") )
1700 localeAlt
= wxS("in") + ExtractNotLang(locale
);
1701 else if ( langOnly
== wxS("yi") )
1702 localeAlt
= wxS("ji") + ExtractNotLang(locale
);
1703 else if ( langOnly
== wxS("nb") )
1704 localeAlt
= wxS("no_NO");
1705 else if ( langOnly
== wxS("nn") )
1706 localeAlt
= wxS("no_NY");
1708 if ( !localeAlt
.empty() )
1710 retloc
= wxSetlocaleTryUTF8(LC_ALL
, localeAlt
);
1712 retloc
= wxSetlocaleTryUTF8(LC_ALL
, ExtractLang(localeAlt
));
1720 // at least in AIX 5.2 libc is buggy and the string returned from
1721 // setlocale(LC_ALL) can't be passed back to it because it returns 6
1722 // strings (one for each locale category), i.e. for C locale we get back
1725 // this contradicts IBM own docs but this is not of much help, so just work
1726 // around it in the crudest possible manner
1727 char* p
= const_cast<char*>(wxStrchr(retloc
, ' '));
1732 #elif defined(__WIN32__)
1733 const char *retloc
= "C";
1734 if ( language
!= wxLANGUAGE_DEFAULT
)
1736 if ( info
->WinLang
== 0 )
1738 wxLogWarning(wxS("Locale '%s' not supported by OS."), name
.c_str());
1739 // retloc already set to "C"
1741 else // language supported by Windows
1743 // Windows CE doesn't have SetThreadLocale() and there doesn't seem
1744 // to be any equivalent
1746 const wxUint32 lcid
= info
->GetLCID();
1748 // change locale used by Windows functions
1749 ::SetThreadLocale(lcid
);
1752 // and also call setlocale() to change locale used by the CRT
1753 locale
= info
->GetLocaleName();
1754 if ( locale
.empty() )
1758 else // have a valid locale
1760 retloc
= wxSetlocale(LC_ALL
, locale
);
1764 else // language == wxLANGUAGE_DEFAULT
1766 retloc
= wxSetlocale(LC_ALL
, wxEmptyString
);
1769 #if wxUSE_UNICODE && (defined(__VISUALC__) || defined(__MINGW32__))
1770 // VC++ setlocale() (also used by Mingw) can't set locale to languages that
1771 // can only be written using Unicode, therefore wxSetlocale() call fails
1772 // for such languages but we don't want to report it as an error -- so that
1773 // at least message catalogs can be used.
1776 if ( wxGetANSICodePageForLocale(LOCALE_USER_DEFAULT
).empty() )
1778 // we set the locale to a Unicode-only language, don't treat the
1779 // inability of CRT to use it as an error
1783 #endif // CRT not handling Unicode-only languages
1787 #elif defined(__WXMAC__)
1788 if (lang
== wxLANGUAGE_DEFAULT
)
1789 locale
= wxEmptyString
;
1791 locale
= info
->CanonicalName
;
1793 const char *retloc
= wxSetlocale(LC_ALL
, locale
);
1797 // Some C libraries don't like xx_YY form and require xx only
1798 retloc
= wxSetlocale(LC_ALL
, ExtractLang(locale
));
1803 #define WX_NO_LOCALE_SUPPORT
1806 #ifndef WX_NO_LOCALE_SUPPORT
1809 wxLogWarning(_("Cannot set locale to language \"%s\"."), name
.c_str());
1811 // continue nevertheless and try to load at least the translations for
1815 if ( !Init(name
, canonical
, retloc
,
1816 (flags
& wxLOCALE_LOAD_DEFAULT
) != 0) )
1821 if (IsOk()) // setlocale() succeeded
1825 #endif // !WX_NO_LOCALE_SUPPORT
1830 void wxLocale::AddCatalogLookupPathPrefix(const wxString
& prefix
)
1832 if ( gs_searchPrefixes
.Index(prefix
) == wxNOT_FOUND
)
1834 gs_searchPrefixes
.Add(prefix
);
1836 //else: already have it
1839 /*static*/ int wxLocale::GetSystemLanguage()
1841 CreateLanguagesDB();
1843 // init i to avoid compiler warning
1845 count
= ms_languagesDB
->GetCount();
1847 #if defined(__UNIX__)
1848 // first get the string identifying the language from the environment
1851 wxCFRef
<CFLocaleRef
> userLocaleRef(CFLocaleCopyCurrent());
1853 // because the locale identifier (kCFLocaleIdentifier) is formatted a little bit differently, eg
1854 // az_Cyrl_AZ@calendar=buddhist;currency=JPY we just recreate the base info as expected by wx here
1856 wxCFStringRef
str(wxCFRetain((CFStringRef
)CFLocaleGetValue(userLocaleRef
, kCFLocaleLanguageCode
)));
1857 langFull
= str
.AsString()+"_";
1858 str
.reset(wxCFRetain((CFStringRef
)CFLocaleGetValue(userLocaleRef
, kCFLocaleCountryCode
)));
1859 langFull
+= str
.AsString();
1861 if (!wxGetEnv(wxS("LC_ALL"), &langFull
) &&
1862 !wxGetEnv(wxS("LC_MESSAGES"), &langFull
) &&
1863 !wxGetEnv(wxS("LANG"), &langFull
))
1865 // no language specified, treat it as English
1866 return wxLANGUAGE_ENGLISH_US
;
1869 if ( langFull
== wxS("C") || langFull
== wxS("POSIX") )
1871 // default C locale is English too
1872 return wxLANGUAGE_ENGLISH_US
;
1876 // the language string has the following form
1878 // lang[_LANG][.encoding][@modifier]
1880 // (see environ(5) in the Open Unix specification)
1882 // where lang is the primary language, LANG is a sublang/territory,
1883 // encoding is the charset to use and modifier "allows the user to select
1884 // a specific instance of localization data within a single category"
1886 // for example, the following strings are valid:
1891 // de_DE.iso88591@euro
1893 // for now we don't use the encoding, although we probably should (doing
1894 // translations of the msg catalogs on the fly as required) (TODO)
1896 // we need the modified for languages like Valencian: ca_ES@valencia
1897 // though, remember it
1899 size_t posModifier
= langFull
.find_first_of(wxS("@"));
1900 if ( posModifier
!= wxString::npos
)
1901 modifier
= langFull
.Mid(posModifier
);
1903 size_t posEndLang
= langFull
.find_first_of(wxS("@."));
1904 if ( posEndLang
!= wxString::npos
)
1906 langFull
.Truncate(posEndLang
);
1909 // in addition to the format above, we also can have full language names
1910 // in LANG env var - for example, SuSE is known to use LANG="german" - so
1913 // do we have just the language (or sublang too)?
1914 bool justLang
= langFull
.length() == LEN_LANG
;
1916 (langFull
.length() == LEN_FULL
&& langFull
[LEN_LANG
] == wxS('_')) )
1918 // 0. Make sure the lang is according to latest ISO 639
1919 // (this is necessary because glibc uses iw and in instead
1920 // of he and id respectively).
1922 // the language itself (second part is the dialect/sublang)
1923 wxString langOrig
= ExtractLang(langFull
);
1926 if ( langOrig
== wxS("iw"))
1928 else if (langOrig
== wxS("in"))
1930 else if (langOrig
== wxS("ji"))
1932 else if (langOrig
== wxS("no_NO"))
1933 lang
= wxS("nb_NO");
1934 else if (langOrig
== wxS("no_NY"))
1935 lang
= wxS("nn_NO");
1936 else if (langOrig
== wxS("no"))
1937 lang
= wxS("nb_NO");
1941 // did we change it?
1942 if ( lang
!= langOrig
)
1944 langFull
= lang
+ ExtractNotLang(langFull
);
1947 // 1. Try to find the language either as is:
1948 // a) With modifier if set
1949 if ( !modifier
.empty() )
1951 wxString langFullWithModifier
= langFull
+ modifier
;
1952 for ( i
= 0; i
< count
; i
++ )
1954 if ( ms_languagesDB
->Item(i
).CanonicalName
== langFullWithModifier
)
1959 // b) Without modifier
1960 if ( modifier
.empty() || i
== count
)
1962 for ( i
= 0; i
< count
; i
++ )
1964 if ( ms_languagesDB
->Item(i
).CanonicalName
== langFull
)
1969 // 2. If langFull is of the form xx_YY, try to find xx:
1970 if ( i
== count
&& !justLang
)
1972 for ( i
= 0; i
< count
; i
++ )
1974 if ( ms_languagesDB
->Item(i
).CanonicalName
== lang
)
1981 // 3. If langFull is of the form xx, try to find any xx_YY record:
1982 if ( i
== count
&& justLang
)
1984 for ( i
= 0; i
< count
; i
++ )
1986 if ( ExtractLang(ms_languagesDB
->Item(i
).CanonicalName
)
1994 else // not standard format
1996 // try to find the name in verbose description
1997 for ( i
= 0; i
< count
; i
++ )
1999 if (ms_languagesDB
->Item(i
).Description
.CmpNoCase(langFull
) == 0)
2005 #elif defined(__WIN32__)
2006 LCID lcid
= GetUserDefaultLCID();
2009 wxUint32 lang
= PRIMARYLANGID(LANGIDFROMLCID(lcid
));
2010 wxUint32 sublang
= SUBLANGID(LANGIDFROMLCID(lcid
));
2012 for ( i
= 0; i
< count
; i
++ )
2014 if (ms_languagesDB
->Item(i
).WinLang
== lang
&&
2015 ms_languagesDB
->Item(i
).WinSublang
== sublang
)
2021 //else: leave wxlang == wxLANGUAGE_UNKNOWN
2022 #endif // Unix/Win32
2026 // we did find a matching entry, use it
2027 return ms_languagesDB
->Item(i
).Language
;
2030 // no info about this language in the database
2031 return wxLANGUAGE_UNKNOWN
;
2034 // ----------------------------------------------------------------------------
2036 // ----------------------------------------------------------------------------
2038 // this is a bit strange as under Windows we get the encoding name using its
2039 // numeric value and under Unix we do it the other way round, but this just
2040 // reflects the way different systems provide the encoding info
2043 wxString
wxLocale::GetSystemEncodingName()
2047 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
2048 // FIXME: what is the error return value for GetACP()?
2049 UINT codepage
= ::GetACP();
2050 encname
.Printf(wxS("windows-%u"), codepage
);
2051 #elif defined(__WXMAC__)
2052 // default is just empty string, this resolves to the default system
2054 #elif defined(__UNIX_LIKE__)
2056 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
2057 // GNU libc provides current character set this way (this conforms
2059 char *oldLocale
= strdup(setlocale(LC_CTYPE
, NULL
));
2060 setlocale(LC_CTYPE
, "");
2061 const char *alang
= nl_langinfo(CODESET
);
2062 setlocale(LC_CTYPE
, oldLocale
);
2067 encname
= wxString::FromAscii( alang
);
2069 else // nl_langinfo() failed
2070 #endif // HAVE_LANGINFO_H
2072 // if we can't get at the character set directly, try to see if it's in
2073 // the environment variables (in most cases this won't work, but I was
2075 char *lang
= getenv( "LC_ALL");
2076 char *dot
= lang
? strchr(lang
, '.') : NULL
;
2079 lang
= getenv( "LC_CTYPE" );
2081 dot
= strchr(lang
, '.' );
2085 lang
= getenv( "LANG");
2087 dot
= strchr(lang
, '.');
2092 encname
= wxString::FromAscii( dot
+1 );
2095 #endif // Win32/Unix
2101 wxFontEncoding
wxLocale::GetSystemEncoding()
2103 #if defined(__WIN32__) && !defined(__WXMICROWIN__)
2104 UINT codepage
= ::GetACP();
2106 // wxWidgets only knows about CP1250-1257, 874, 932, 936, 949, 950
2107 if ( codepage
>= 1250 && codepage
<= 1257 )
2109 return (wxFontEncoding
)(wxFONTENCODING_CP1250
+ codepage
- 1250);
2112 if ( codepage
== 874 )
2114 return wxFONTENCODING_CP874
;
2117 if ( codepage
== 932 )
2119 return wxFONTENCODING_CP932
;
2122 if ( codepage
== 936 )
2124 return wxFONTENCODING_CP936
;
2127 if ( codepage
== 949 )
2129 return wxFONTENCODING_CP949
;
2132 if ( codepage
== 950 )
2134 return wxFONTENCODING_CP950
;
2136 #elif defined(__WXMAC__)
2137 CFStringEncoding encoding
= 0 ;
2138 encoding
= CFStringGetSystemEncoding() ;
2139 return wxMacGetFontEncFromSystemEnc( encoding
) ;
2140 #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP
2141 const wxString encname
= GetSystemEncodingName();
2142 if ( !encname
.empty() )
2144 wxFontEncoding enc
= wxFontMapperBase::GetEncodingFromName(encname
);
2146 // on some modern Linux systems (RedHat 8) the default system locale
2147 // is UTF8 -- but it isn't supported by wxGTK1 in ANSI build at all so
2148 // don't even try to use it in this case
2149 #if !wxUSE_UNICODE && \
2150 ((defined(__WXGTK__) && !defined(__WXGTK20__)) || defined(__WXMOTIF__))
2151 if ( enc
== wxFONTENCODING_UTF8
)
2153 // the most similar supported encoding...
2154 enc
= wxFONTENCODING_ISO8859_1
;
2156 #endif // !wxUSE_UNICODE
2158 // GetEncodingFromName() returns wxFONTENCODING_DEFAULT for C locale
2159 // (a.k.a. US-ASCII) which is arguably a bug but keep it like this for
2160 // backwards compatibility and just take care to not return
2161 // wxFONTENCODING_DEFAULT from here as this surely doesn't make sense
2162 if ( enc
== wxFONTENCODING_DEFAULT
)
2164 // we don't have wxFONTENCODING_ASCII, so use the closest one
2165 return wxFONTENCODING_ISO8859_1
;
2168 if ( enc
!= wxFONTENCODING_MAX
)
2172 //else: return wxFONTENCODING_SYSTEM below
2174 #endif // Win32/Unix
2176 return wxFONTENCODING_SYSTEM
;
2180 void wxLocale::AddLanguage(const wxLanguageInfo
& info
)
2182 CreateLanguagesDB();
2183 ms_languagesDB
->Add(info
);
2187 const wxLanguageInfo
*wxLocale::GetLanguageInfo(int lang
)
2189 CreateLanguagesDB();
2191 // calling GetLanguageInfo(wxLANGUAGE_DEFAULT) is a natural thing to do, so
2193 if ( lang
== wxLANGUAGE_DEFAULT
)
2194 lang
= GetSystemLanguage();
2196 const size_t count
= ms_languagesDB
->GetCount();
2197 for ( size_t i
= 0; i
< count
; i
++ )
2199 if ( ms_languagesDB
->Item(i
).Language
== lang
)
2201 // We need to create a temporary here in order to make this work with BCC in final build mode
2202 wxLanguageInfo
*ptr
= &ms_languagesDB
->Item(i
);
2211 wxString
wxLocale::GetLanguageName(int lang
)
2213 const wxLanguageInfo
*info
= GetLanguageInfo(lang
);
2215 return wxEmptyString
;
2217 return info
->Description
;
2221 const wxLanguageInfo
*wxLocale::FindLanguageInfo(const wxString
& locale
)
2223 CreateLanguagesDB();
2225 const wxLanguageInfo
*infoRet
= NULL
;
2227 const size_t count
= ms_languagesDB
->GetCount();
2228 for ( size_t i
= 0; i
< count
; i
++ )
2230 const wxLanguageInfo
*info
= &ms_languagesDB
->Item(i
);
2232 if ( wxStricmp(locale
, info
->CanonicalName
) == 0 ||
2233 wxStricmp(locale
, info
->Description
) == 0 )
2235 // exact match, stop searching
2240 if ( wxStricmp(locale
, info
->CanonicalName
.BeforeFirst(wxS('_'))) == 0 )
2242 // a match -- but maybe we'll find an exact one later, so continue
2245 // OTOH, maybe we had already found a language match and in this
2246 // case don't overwrite it because the entry for the default
2247 // country always appears first in ms_languagesDB
2256 wxString
wxLocale::GetSysName() const
2258 return wxSetlocale(LC_ALL
, NULL
);
2262 wxLocale::~wxLocale()
2265 wxMsgCatalog
*pTmpCat
;
2266 while ( m_pMsgCat
!= NULL
) {
2267 pTmpCat
= m_pMsgCat
;
2268 m_pMsgCat
= m_pMsgCat
->m_pNext
;
2272 // restore old locale pointer
2273 wxSetLocale(m_pOldLocale
);
2275 wxSetlocale(LC_ALL
, m_pszOldLocale
);
2276 free((wxChar
*)m_pszOldLocale
); // const_cast
2279 // get the translation of given string in current locale
2280 const wxString
& wxLocale::GetString(const wxString
& origString
,
2281 const wxString
& domain
) const
2283 return GetString(origString
, origString
, size_t(-1), domain
);
2286 const wxString
& wxLocale::GetString(const wxString
& origString
,
2287 const wxString
& origString2
,
2289 const wxString
& domain
) const
2291 if ( origString
.empty() )
2292 return GetUntranslatedString(origString
);
2294 const wxString
*trans
= NULL
;
2295 wxMsgCatalog
*pMsgCat
;
2297 if ( !domain
.empty() )
2299 pMsgCat
= FindCatalog(domain
);
2301 // does the catalog exist?
2302 if ( pMsgCat
!= NULL
)
2303 trans
= pMsgCat
->GetString(origString
, n
);
2307 // search in all domains
2308 for ( pMsgCat
= m_pMsgCat
; pMsgCat
!= NULL
; pMsgCat
= pMsgCat
->m_pNext
)
2310 trans
= pMsgCat
->GetString(origString
, n
);
2311 if ( trans
!= NULL
) // take the first found
2316 if ( trans
== NULL
)
2318 wxLogTrace(TRACE_I18N
,
2319 wxS("string \"%s\"[%ld] not found in %slocale '%s'."),
2320 origString
, (long)n
,
2321 wxString::Format(wxS("domain '%s' "), domain
).c_str(),
2322 m_strLocale
.c_str());
2324 if (n
== size_t(-1))
2325 return GetUntranslatedString(origString
);
2327 return GetUntranslatedString(n
== 1 ? origString
: origString2
);
2333 WX_DECLARE_HASH_SET(wxString
, wxStringHash
, wxStringEqual
,
2334 wxLocaleUntranslatedStrings
);
2337 const wxString
& wxLocale::GetUntranslatedString(const wxString
& str
)
2339 static wxLocaleUntranslatedStrings s_strings
;
2341 wxLocaleUntranslatedStrings::iterator i
= s_strings
.find(str
);
2342 if ( i
== s_strings
.end() )
2343 return *s_strings
.insert(str
).first
;
2348 wxString
wxLocale::GetHeaderValue(const wxString
& header
,
2349 const wxString
& domain
) const
2351 if ( header
.empty() )
2352 return wxEmptyString
;
2354 const wxString
*trans
= NULL
;
2355 wxMsgCatalog
*pMsgCat
;
2357 if ( !domain
.empty() )
2359 pMsgCat
= FindCatalog(domain
);
2361 // does the catalog exist?
2362 if ( pMsgCat
== NULL
)
2363 return wxEmptyString
;
2365 trans
= pMsgCat
->GetString(wxEmptyString
, (size_t)-1);
2369 // search in all domains
2370 for ( pMsgCat
= m_pMsgCat
; pMsgCat
!= NULL
; pMsgCat
= pMsgCat
->m_pNext
)
2372 trans
= pMsgCat
->GetString(wxEmptyString
, (size_t)-1);
2373 if ( trans
!= NULL
) // take the first found
2378 if ( !trans
|| trans
->empty() )
2379 return wxEmptyString
;
2381 size_t found
= trans
->find(header
);
2382 if ( found
== wxString::npos
)
2383 return wxEmptyString
;
2385 found
+= header
.length() + 2 /* ': ' */;
2387 // Every header is separated by \n
2389 size_t endLine
= trans
->find(wxS('\n'), found
);
2390 size_t len
= (endLine
== wxString::npos
) ?
2391 wxString::npos
: (endLine
- found
);
2393 return trans
->substr(found
, len
);
2397 // find catalog by name in a linked list, return NULL if !found
2398 wxMsgCatalog
*wxLocale::FindCatalog(const wxString
& domain
) const
2400 // linear search in the linked list
2401 wxMsgCatalog
*pMsgCat
;
2402 for ( pMsgCat
= m_pMsgCat
; pMsgCat
!= NULL
; pMsgCat
= pMsgCat
->m_pNext
)
2404 if ( pMsgCat
->GetName() == domain
)
2411 // check if the given locale is provided by OS and C run time
2413 bool wxLocale::IsAvailable(int lang
)
2415 const wxLanguageInfo
*info
= wxLocale::GetLanguageInfo(lang
);
2416 wxCHECK_MSG( info
, false, wxS("invalid language") );
2418 #if defined(__WIN32__)
2419 if ( !info
->WinLang
)
2422 if ( !::IsValidLocale(info
->GetLCID(), LCID_INSTALLED
) )
2425 #elif defined(__UNIX__)
2427 // Test if setting the locale works, then set it back.
2428 const char *oldLocale
= wxSetlocaleTryUTF8(LC_ALL
, info
->CanonicalName
);
2431 // Some C libraries don't like xx_YY form and require xx only
2432 oldLocale
= wxSetlocaleTryUTF8(LC_ALL
, ExtractLang(info
->CanonicalName
));
2436 // restore the original locale
2437 wxSetlocale(LC_ALL
, oldLocale
);
2443 // check if the given catalog is loaded
2444 bool wxLocale::IsLoaded(const wxString
& szDomain
) const
2446 return FindCatalog(szDomain
) != NULL
;
2449 // add a catalog to our linked list
2450 bool wxLocale::AddCatalog(const wxString
& szDomain
)
2452 return AddCatalog(szDomain
, wxLANGUAGE_ENGLISH_US
, wxEmptyString
);
2455 // add a catalog to our linked list
2456 bool wxLocale::AddCatalog(const wxString
& szDomain
,
2457 wxLanguage msgIdLanguage
,
2458 const wxString
& msgIdCharset
)
2461 wxCHECK_MSG( !m_strShort
.empty(), false, "must initialize catalog first" );
2464 // It is OK to not load catalog if the msgid language and m_language match,
2465 // in which case we can directly display the texts embedded in program's
2467 if ( msgIdLanguage
== m_language
)
2471 wxMsgCatalog
*pMsgCat
= new wxMsgCatalog
;
2473 if ( pMsgCat
->Load(m_strShort
, szDomain
, msgIdCharset
) )
2475 // add it to the head of the list so that in GetString it will
2476 // be searched before the catalogs added earlier
2477 pMsgCat
->m_pNext
= m_pMsgCat
;
2478 m_pMsgCat
= pMsgCat
;
2483 // don't add it because it couldn't be loaded anyway
2487 // If there's no exact match, we may still get partial match where the
2488 // (basic) language is same, but the country differs. For example, it's
2489 // permitted to use en_US strings from sources even if m_language is en_GB:
2490 const wxLanguageInfo
*msgIdLangInfo
= GetLanguageInfo(msgIdLanguage
);
2491 if ( msgIdLangInfo
&&
2492 ExtractLang(msgIdLangInfo
->CanonicalName
) == ExtractLang(m_strShort
) )
2500 // ----------------------------------------------------------------------------
2501 // accessors for locale-dependent data
2502 // ----------------------------------------------------------------------------
2504 #if defined(__WXMSW__) || defined(__WXOSX__)
2509 // This function translates from Unicode date formats described at
2511 // http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
2513 // to strftime()-like syntax. This translation is not lossless but we try to do
2516 static wxString
TranslateFromUnicodeFormat(const wxString
& fmt
)
2519 fmtWX
.reserve(fmt
.length());
2522 size_t lastCount
= 0;
2524 const char* formatchars
=
2532 for ( wxString::const_iterator p
= fmt
.begin(); /* end handled inside */; ++p
)
2534 if ( p
!= fmt
.end() )
2542 const wxUniChar ch
= (*p
).GetValue();
2543 if ( ch
.IsAscii() && strchr(formatchars
, ch
) )
2545 // these characters come in groups, start counting them
2552 // interpret any special characters we collected so far
2558 switch ( lastCount
)
2562 // these two are the same as we don't distinguish
2563 // between 1 and 2 digits for days
2576 wxFAIL_MSG( "too many 'd's" );
2581 switch ( lastCount
)
2590 wxFAIL_MSG( "wrong number of 'D's" );
2594 switch ( lastCount
)
2602 wxFAIL_MSG( "wrong number of 'w's" );
2606 switch ( lastCount
)
2621 wxFAIL_MSG( "wrong number of 'E's" );
2626 switch ( lastCount
)
2630 // as for 'd' and 'dd' above
2643 wxFAIL_MSG( "too many 'M's" );
2648 switch ( lastCount
)
2660 wxFAIL_MSG( "wrong number of 'y's" );
2665 switch ( lastCount
)
2673 wxFAIL_MSG( "wrong number of 'H's" );
2678 switch ( lastCount
)
2686 wxFAIL_MSG( "wrong number of 'h's" );
2691 switch ( lastCount
)
2699 wxFAIL_MSG( "wrong number of 'm's" );
2704 switch ( lastCount
)
2712 wxFAIL_MSG( "wrong number of 's's" );
2717 // strftime() doesn't have era string,
2718 // ignore this format
2719 wxASSERT_MSG( lastCount
<= 2, "too many 'g's" );
2729 switch ( lastCount
)
2737 wxFAIL_MSG( "too many 't's" );
2742 wxFAIL_MSG( "unreachable" );
2749 if ( p
== fmt
.end() )
2752 // not a special character so must be just a separator, treat as is
2753 if ( *p
== wxT('%') )
2755 // this one needs to be escaped
2765 } // anonymous namespace
2767 #endif // __WXMSW__ || __WXOSX__
2769 #if defined(__WXMSW__)
2774 LCTYPE
GetLCTYPEFormatFromLocalInfo(wxLocaleInfo index
)
2778 case wxLOCALE_SHORT_DATE_FMT
:
2779 return LOCALE_SSHORTDATE
;
2781 case wxLOCALE_LONG_DATE_FMT
:
2782 return LOCALE_SLONGDATE
;
2784 case wxLOCALE_TIME_FMT
:
2785 return LOCALE_STIMEFORMAT
;
2788 wxFAIL_MSG( "no matching LCTYPE" );
2794 } // anonymous namespace
2797 wxString
wxLocale::GetInfo(wxLocaleInfo index
, wxLocaleCategory
WXUNUSED(cat
))
2799 wxUint32 lcid
= LOCALE_USER_DEFAULT
;
2800 if ( wxGetLocale() )
2802 const wxLanguageInfo
* const
2803 info
= GetLanguageInfo(wxGetLocale()->GetLanguage());
2805 lcid
= info
->GetLCID();
2815 case wxLOCALE_DECIMAL_POINT
:
2816 if ( ::GetLocaleInfo(lcid
, LOCALE_SDECIMAL
, buf
, WXSIZEOF(buf
)) )
2820 case wxLOCALE_SHORT_DATE_FMT
:
2821 case wxLOCALE_LONG_DATE_FMT
:
2822 case wxLOCALE_TIME_FMT
:
2823 if ( ::GetLocaleInfo(lcid
, GetLCTYPEFormatFromLocalInfo(index
),
2824 buf
, WXSIZEOF(buf
)) )
2826 return TranslateFromUnicodeFormat(buf
);
2830 case wxLOCALE_DATE_TIME_FMT
:
2831 // there doesn't seem to be any specific setting for this, so just
2832 // combine date and time ones
2834 // we use the short date because this is what "%c" uses by default
2835 // ("%#c" uses long date but we have no way to specify the
2836 // alternate representation here)
2838 const wxString datefmt
= GetInfo(wxLOCALE_SHORT_DATE_FMT
);
2839 if ( datefmt
.empty() )
2842 const wxString timefmt
= GetInfo(wxLOCALE_TIME_FMT
);
2843 if ( timefmt
.empty() )
2846 str
<< datefmt
<< ' ' << timefmt
;
2851 wxFAIL_MSG( "unknown wxLocaleInfo" );
2857 #elif defined(__WXOSX__)
2860 wxString
wxLocale::GetInfo(wxLocaleInfo index
, wxLocaleCategory
WXUNUSED(cat
))
2862 CFLocaleRef userLocaleRefRaw
;
2863 if ( wxGetLocale() )
2865 userLocaleRefRaw
= CFLocaleCreate
2867 kCFAllocatorDefault
,
2868 wxCFStringRef(wxGetLocale()->GetCanonicalName())
2871 else // no current locale, use the default one
2873 userLocaleRefRaw
= CFLocaleCopyCurrent();
2876 wxCFRef
<CFLocaleRef
> userLocaleRef(userLocaleRefRaw
);
2878 CFStringRef cfstr
= 0;
2881 case wxLOCALE_THOUSANDS_SEP
:
2882 cfstr
= (CFStringRef
) CFLocaleGetValue(userLocaleRef
, kCFLocaleGroupingSeparator
);
2885 case wxLOCALE_DECIMAL_POINT
:
2886 cfstr
= (CFStringRef
) CFLocaleGetValue(userLocaleRef
, kCFLocaleDecimalSeparator
);
2889 case wxLOCALE_SHORT_DATE_FMT
:
2890 case wxLOCALE_LONG_DATE_FMT
:
2891 case wxLOCALE_DATE_TIME_FMT
:
2892 case wxLOCALE_TIME_FMT
:
2894 CFDateFormatterStyle dateStyle
= kCFDateFormatterNoStyle
;
2895 CFDateFormatterStyle timeStyle
= kCFDateFormatterNoStyle
;
2898 case wxLOCALE_SHORT_DATE_FMT
:
2899 dateStyle
= kCFDateFormatterShortStyle
;
2901 case wxLOCALE_LONG_DATE_FMT
:
2902 dateStyle
= kCFDateFormatterFullStyle
;
2904 case wxLOCALE_DATE_TIME_FMT
:
2905 dateStyle
= kCFDateFormatterFullStyle
;
2906 timeStyle
= kCFDateFormatterMediumStyle
;
2908 case wxLOCALE_TIME_FMT
:
2909 timeStyle
= kCFDateFormatterMediumStyle
;
2912 wxFAIL_MSG( "unexpected time locale" );
2915 wxCFRef
<CFDateFormatterRef
> dateFormatter( CFDateFormatterCreate
2916 (NULL
, userLocaleRef
, dateStyle
, timeStyle
));
2917 wxCFStringRef cfs
= wxCFRetain( CFDateFormatterGetFormat(dateFormatter
));
2918 wxString format
= TranslateFromUnicodeFormat(cfs
.AsString());
2919 // we always want full years
2920 format
.Replace("%y","%Y");
2926 wxFAIL_MSG( "Unknown locale info" );
2930 wxCFStringRef
str(wxCFRetain(cfstr
));
2931 return str
.AsString();
2934 #else // !__WXMSW__ && !__WXOSX__, assume generic POSIX
2939 wxString
GetDateFormatFromLangInfo(wxLocaleInfo index
)
2941 #ifdef HAVE_LANGINFO_H
2942 // array containing parameters for nl_langinfo() indexes by offset of index
2943 // from wxLOCALE_SHORT_DATE_FMT
2944 static const nl_item items
[] =
2946 D_FMT
, D_T_FMT
, D_T_FMT
, T_FMT
,
2949 const int nlidx
= index
- wxLOCALE_SHORT_DATE_FMT
;
2950 if ( nlidx
< 0 || nlidx
>= (int)WXSIZEOF(items
) )
2952 wxFAIL_MSG( "logic error in GetInfo() code" );
2956 const wxString
fmt(nl_langinfo(items
[nlidx
]));
2958 // just return the format returned by nl_langinfo() except for long date
2959 // format which we need to recover from date/time format ourselves (but not
2960 // if we failed completely)
2961 if ( fmt
.empty() || index
!= wxLOCALE_LONG_DATE_FMT
)
2964 // this is not 100% precise but the idea is that a typical date/time format
2965 // under POSIX systems is a combination of a long date format with time one
2966 // so we should be able to get just the long date format by removing all
2967 // time-specific format specifiers
2968 static const char *timeFmtSpecs
= "HIklMpPrRsSTXzZ";
2969 static const char *timeSep
= " :./-";
2971 wxString fmtDateOnly
;
2972 const wxString::const_iterator end
= fmt
.end();
2973 wxString::const_iterator lastSep
= end
;
2974 for ( wxString::const_iterator p
= fmt
.begin(); p
!= end
; ++p
)
2976 if ( strchr(timeSep
, *p
) )
2978 if ( lastSep
== end
)
2981 // skip it for now, we'll discard it if it's followed by a time
2982 // specifier later or add it to fmtDateOnly if it is not
2987 (p
+ 1 != end
) && strchr(timeFmtSpecs
, p
[1]) )
2989 // time specified found: skip it and any preceding separators
2995 if ( lastSep
!= end
)
2997 fmtDateOnly
+= wxString(lastSep
, p
);
3005 #else // !HAVE_LANGINFO_H
3008 // no fallback, let the application deal with unavailability of
3009 // nl_langinfo() itself as there is no good way for us to do it (well, we
3010 // could try to reverse engineer the format from strftime() output but this
3011 // looks like too much trouble considering the relatively small number of
3012 // systems without nl_langinfo() still in use)
3014 #endif // HAVE_LANGINFO_H/!HAVE_LANGINFO_H
3017 } // anonymous namespace
3020 wxString
wxLocale::GetInfo(wxLocaleInfo index
, wxLocaleCategory cat
)
3022 lconv
* const lc
= localeconv();
3028 case wxLOCALE_THOUSANDS_SEP
:
3029 if ( cat
== wxLOCALE_CAT_NUMBER
)
3030 return lc
->thousands_sep
;
3031 else if ( cat
== wxLOCALE_CAT_MONEY
)
3032 return lc
->mon_thousands_sep
;
3034 wxFAIL_MSG( "invalid wxLocaleCategory" );
3038 case wxLOCALE_DECIMAL_POINT
:
3039 if ( cat
== wxLOCALE_CAT_NUMBER
)
3040 return lc
->decimal_point
;
3041 else if ( cat
== wxLOCALE_CAT_MONEY
)
3042 return lc
->mon_decimal_point
;
3044 wxFAIL_MSG( "invalid wxLocaleCategory" );
3047 case wxLOCALE_SHORT_DATE_FMT
:
3048 case wxLOCALE_LONG_DATE_FMT
:
3049 case wxLOCALE_DATE_TIME_FMT
:
3050 case wxLOCALE_TIME_FMT
:
3051 if ( cat
!= wxLOCALE_CAT_DATE
&& cat
!= wxLOCALE_CAT_DEFAULT
)
3053 wxFAIL_MSG( "invalid wxLocaleCategory" );
3057 return GetDateFormatFromLangInfo(index
);
3061 wxFAIL_MSG( "unknown wxLocaleInfo value" );
3069 // ----------------------------------------------------------------------------
3070 // global functions and variables
3071 // ----------------------------------------------------------------------------
3073 // retrieve/change current locale
3074 // ------------------------------
3076 // the current locale object
3077 static wxLocale
*g_pLocale
= NULL
;
3079 wxLocale
*wxGetLocale()
3084 wxLocale
*wxSetLocale(wxLocale
*pLocale
)
3086 wxLocale
*pOld
= g_pLocale
;
3087 g_pLocale
= pLocale
;
3093 // ----------------------------------------------------------------------------
3094 // wxLocale module (for lazy destruction of languagesDB)
3095 // ----------------------------------------------------------------------------
3097 class wxLocaleModule
: public wxModule
3099 DECLARE_DYNAMIC_CLASS(wxLocaleModule
)
3102 bool OnInit() { return true; }
3103 void OnExit() { wxLocale::DestroyLanguagesDB(); }
3106 IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule
, wxModule
)
3110 // ----------------------------------------------------------------------------
3111 // default languages table & initialization
3112 // ----------------------------------------------------------------------------
3115 // --- --- --- generated code begins here --- --- ---
3117 // This table is generated by misc/languages/genlang.py
3118 // When making changes, please put them into misc/languages/langtabl.txt
3120 #if !defined(__WIN32__) || defined(__WXMICROWIN__)
3122 #define SETWINLANG(info,lang,sublang)
3126 #define SETWINLANG(info,lang,sublang) \
3127 info.WinLang = lang, info.WinSublang = sublang;
3129 #ifndef LANG_AFRIKAANS
3130 #define LANG_AFRIKAANS (0)
3132 #ifndef LANG_ALBANIAN
3133 #define LANG_ALBANIAN (0)
3136 #define LANG_ARABIC (0)
3138 #ifndef LANG_ARMENIAN
3139 #define LANG_ARMENIAN (0)
3141 #ifndef LANG_ASSAMESE
3142 #define LANG_ASSAMESE (0)
3145 #define LANG_AZERI (0)
3148 #define LANG_BASQUE (0)
3150 #ifndef LANG_BELARUSIAN
3151 #define LANG_BELARUSIAN (0)
3153 #ifndef LANG_BENGALI
3154 #define LANG_BENGALI (0)
3156 #ifndef LANG_BULGARIAN
3157 #define LANG_BULGARIAN (0)
3159 #ifndef LANG_CATALAN
3160 #define LANG_CATALAN (0)
3162 #ifndef LANG_CHINESE
3163 #define LANG_CHINESE (0)
3165 #ifndef LANG_CROATIAN
3166 #define LANG_CROATIAN (0)
3169 #define LANG_CZECH (0)
3172 #define LANG_DANISH (0)
3175 #define LANG_DUTCH (0)
3177 #ifndef LANG_ENGLISH
3178 #define LANG_ENGLISH (0)
3180 #ifndef LANG_ESTONIAN
3181 #define LANG_ESTONIAN (0)
3183 #ifndef LANG_FAEROESE
3184 #define LANG_FAEROESE (0)
3187 #define LANG_FARSI (0)
3189 #ifndef LANG_FINNISH
3190 #define LANG_FINNISH (0)
3193 #define LANG_FRENCH (0)
3195 #ifndef LANG_GEORGIAN
3196 #define LANG_GEORGIAN (0)
3199 #define LANG_GERMAN (0)
3202 #define LANG_GREEK (0)
3204 #ifndef LANG_GUJARATI
3205 #define LANG_GUJARATI (0)
3208 #define LANG_HEBREW (0)
3211 #define LANG_HINDI (0)
3213 #ifndef LANG_HUNGARIAN
3214 #define LANG_HUNGARIAN (0)
3216 #ifndef LANG_ICELANDIC
3217 #define LANG_ICELANDIC (0)
3219 #ifndef LANG_INDONESIAN
3220 #define LANG_INDONESIAN (0)
3222 #ifndef LANG_ITALIAN
3223 #define LANG_ITALIAN (0)
3225 #ifndef LANG_JAPANESE
3226 #define LANG_JAPANESE (0)
3228 #ifndef LANG_KANNADA
3229 #define LANG_KANNADA (0)
3231 #ifndef LANG_KASHMIRI
3232 #define LANG_KASHMIRI (0)
3235 #define LANG_KAZAK (0)
3237 #ifndef LANG_KONKANI
3238 #define LANG_KONKANI (0)
3241 #define LANG_KOREAN (0)
3243 #ifndef LANG_LATVIAN
3244 #define LANG_LATVIAN (0)
3246 #ifndef LANG_LITHUANIAN
3247 #define LANG_LITHUANIAN (0)
3249 #ifndef LANG_MACEDONIAN
3250 #define LANG_MACEDONIAN (0)
3253 #define LANG_MALAY (0)
3255 #ifndef LANG_MALAYALAM
3256 #define LANG_MALAYALAM (0)
3258 #ifndef LANG_MANIPURI
3259 #define LANG_MANIPURI (0)
3261 #ifndef LANG_MARATHI
3262 #define LANG_MARATHI (0)
3265 #define LANG_NEPALI (0)
3267 #ifndef LANG_NORWEGIAN
3268 #define LANG_NORWEGIAN (0)
3271 #define LANG_ORIYA (0)
3274 #define LANG_POLISH (0)
3276 #ifndef LANG_PORTUGUESE
3277 #define LANG_PORTUGUESE (0)
3279 #ifndef LANG_PUNJABI
3280 #define LANG_PUNJABI (0)
3282 #ifndef LANG_ROMANIAN
3283 #define LANG_ROMANIAN (0)
3285 #ifndef LANG_RUSSIAN
3286 #define LANG_RUSSIAN (0)
3289 #define LANG_SAMI (0)
3291 #ifndef LANG_SANSKRIT
3292 #define LANG_SANSKRIT (0)
3294 #ifndef LANG_SERBIAN
3295 #define LANG_SERBIAN (0)
3298 #define LANG_SINDHI (0)
3301 #define LANG_SLOVAK (0)
3303 #ifndef LANG_SLOVENIAN
3304 #define LANG_SLOVENIAN (0)
3306 #ifndef LANG_SPANISH
3307 #define LANG_SPANISH (0)
3309 #ifndef LANG_SWAHILI
3310 #define LANG_SWAHILI (0)
3312 #ifndef LANG_SWEDISH
3313 #define LANG_SWEDISH (0)
3316 #define LANG_TAMIL (0)
3319 #define LANG_TATAR (0)
3322 #define LANG_TELUGU (0)
3325 #define LANG_THAI (0)
3327 #ifndef LANG_TURKISH
3328 #define LANG_TURKISH (0)
3330 #ifndef LANG_UKRAINIAN
3331 #define LANG_UKRAINIAN (0)
3334 #define LANG_URDU (0)
3337 #define LANG_UZBEK (0)
3339 #ifndef LANG_VIETNAMESE
3340 #define LANG_VIETNAMESE (0)
3342 #ifndef SUBLANG_ARABIC_ALGERIA
3343 #define SUBLANG_ARABIC_ALGERIA SUBLANG_DEFAULT
3345 #ifndef SUBLANG_ARABIC_BAHRAIN
3346 #define SUBLANG_ARABIC_BAHRAIN SUBLANG_DEFAULT
3348 #ifndef SUBLANG_ARABIC_EGYPT
3349 #define SUBLANG_ARABIC_EGYPT SUBLANG_DEFAULT
3351 #ifndef SUBLANG_ARABIC_IRAQ
3352 #define SUBLANG_ARABIC_IRAQ SUBLANG_DEFAULT
3354 #ifndef SUBLANG_ARABIC_JORDAN
3355 #define SUBLANG_ARABIC_JORDAN SUBLANG_DEFAULT
3357 #ifndef SUBLANG_ARABIC_KUWAIT
3358 #define SUBLANG_ARABIC_KUWAIT SUBLANG_DEFAULT
3360 #ifndef SUBLANG_ARABIC_LEBANON
3361 #define SUBLANG_ARABIC_LEBANON SUBLANG_DEFAULT
3363 #ifndef SUBLANG_ARABIC_LIBYA
3364 #define SUBLANG_ARABIC_LIBYA SUBLANG_DEFAULT
3366 #ifndef SUBLANG_ARABIC_MOROCCO
3367 #define SUBLANG_ARABIC_MOROCCO SUBLANG_DEFAULT
3369 #ifndef SUBLANG_ARABIC_OMAN
3370 #define SUBLANG_ARABIC_OMAN SUBLANG_DEFAULT
3372 #ifndef SUBLANG_ARABIC_QATAR
3373 #define SUBLANG_ARABIC_QATAR SUBLANG_DEFAULT
3375 #ifndef SUBLANG_ARABIC_SAUDI_ARABIA
3376 #define SUBLANG_ARABIC_SAUDI_ARABIA SUBLANG_DEFAULT
3378 #ifndef SUBLANG_ARABIC_SYRIA
3379 #define SUBLANG_ARABIC_SYRIA SUBLANG_DEFAULT
3381 #ifndef SUBLANG_ARABIC_TUNISIA
3382 #define SUBLANG_ARABIC_TUNISIA SUBLANG_DEFAULT
3384 #ifndef SUBLANG_ARABIC_UAE
3385 #define SUBLANG_ARABIC_UAE SUBLANG_DEFAULT
3387 #ifndef SUBLANG_ARABIC_YEMEN
3388 #define SUBLANG_ARABIC_YEMEN SUBLANG_DEFAULT
3390 #ifndef SUBLANG_AZERI_CYRILLIC
3391 #define SUBLANG_AZERI_CYRILLIC SUBLANG_DEFAULT
3393 #ifndef SUBLANG_AZERI_LATIN
3394 #define SUBLANG_AZERI_LATIN SUBLANG_DEFAULT
3396 #ifndef SUBLANG_CHINESE_SIMPLIFIED
3397 #define SUBLANG_CHINESE_SIMPLIFIED SUBLANG_DEFAULT
3399 #ifndef SUBLANG_CHINESE_TRADITIONAL
3400 #define SUBLANG_CHINESE_TRADITIONAL SUBLANG_DEFAULT
3402 #ifndef SUBLANG_CHINESE_HONGKONG
3403 #define SUBLANG_CHINESE_HONGKONG SUBLANG_DEFAULT
3405 #ifndef SUBLANG_CHINESE_MACAU
3406 #define SUBLANG_CHINESE_MACAU SUBLANG_DEFAULT
3408 #ifndef SUBLANG_CHINESE_SINGAPORE
3409 #define SUBLANG_CHINESE_SINGAPORE SUBLANG_DEFAULT
3411 #ifndef SUBLANG_DUTCH
3412 #define SUBLANG_DUTCH SUBLANG_DEFAULT
3414 #ifndef SUBLANG_DUTCH_BELGIAN
3415 #define SUBLANG_DUTCH_BELGIAN SUBLANG_DEFAULT
3417 #ifndef SUBLANG_ENGLISH_UK
3418 #define SUBLANG_ENGLISH_UK SUBLANG_DEFAULT
3420 #ifndef SUBLANG_ENGLISH_US
3421 #define SUBLANG_ENGLISH_US SUBLANG_DEFAULT
3423 #ifndef SUBLANG_ENGLISH_AUS
3424 #define SUBLANG_ENGLISH_AUS SUBLANG_DEFAULT
3426 #ifndef SUBLANG_ENGLISH_BELIZE
3427 #define SUBLANG_ENGLISH_BELIZE SUBLANG_DEFAULT
3429 #ifndef SUBLANG_ENGLISH_CAN
3430 #define SUBLANG_ENGLISH_CAN SUBLANG_DEFAULT
3432 #ifndef SUBLANG_ENGLISH_CARIBBEAN
3433 #define SUBLANG_ENGLISH_CARIBBEAN SUBLANG_DEFAULT
3435 #ifndef SUBLANG_ENGLISH_EIRE
3436 #define SUBLANG_ENGLISH_EIRE SUBLANG_DEFAULT
3438 #ifndef SUBLANG_ENGLISH_JAMAICA
3439 #define SUBLANG_ENGLISH_JAMAICA SUBLANG_DEFAULT
3441 #ifndef SUBLANG_ENGLISH_NZ
3442 #define SUBLANG_ENGLISH_NZ SUBLANG_DEFAULT
3444 #ifndef SUBLANG_ENGLISH_PHILIPPINES
3445 #define SUBLANG_ENGLISH_PHILIPPINES SUBLANG_DEFAULT
3447 #ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
3448 #define SUBLANG_ENGLISH_SOUTH_AFRICA SUBLANG_DEFAULT
3450 #ifndef SUBLANG_ENGLISH_TRINIDAD
3451 #define SUBLANG_ENGLISH_TRINIDAD SUBLANG_DEFAULT
3453 #ifndef SUBLANG_ENGLISH_ZIMBABWE
3454 #define SUBLANG_ENGLISH_ZIMBABWE SUBLANG_DEFAULT
3456 #ifndef SUBLANG_FRENCH
3457 #define SUBLANG_FRENCH SUBLANG_DEFAULT
3459 #ifndef SUBLANG_FRENCH_BELGIAN
3460 #define SUBLANG_FRENCH_BELGIAN SUBLANG_DEFAULT
3462 #ifndef SUBLANG_FRENCH_CANADIAN
3463 #define SUBLANG_FRENCH_CANADIAN SUBLANG_DEFAULT
3465 #ifndef SUBLANG_FRENCH_LUXEMBOURG
3466 #define SUBLANG_FRENCH_LUXEMBOURG SUBLANG_DEFAULT
3468 #ifndef SUBLANG_FRENCH_MONACO
3469 #define SUBLANG_FRENCH_MONACO SUBLANG_DEFAULT
3471 #ifndef SUBLANG_FRENCH_SWISS
3472 #define SUBLANG_FRENCH_SWISS SUBLANG_DEFAULT
3474 #ifndef SUBLANG_GERMAN
3475 #define SUBLANG_GERMAN SUBLANG_DEFAULT
3477 #ifndef SUBLANG_GERMAN_AUSTRIAN
3478 #define SUBLANG_GERMAN_AUSTRIAN SUBLANG_DEFAULT
3480 #ifndef SUBLANG_GERMAN_LIECHTENSTEIN
3481 #define SUBLANG_GERMAN_LIECHTENSTEIN SUBLANG_DEFAULT
3483 #ifndef SUBLANG_GERMAN_LUXEMBOURG
3484 #define SUBLANG_GERMAN_LUXEMBOURG SUBLANG_DEFAULT
3486 #ifndef SUBLANG_GERMAN_SWISS
3487 #define SUBLANG_GERMAN_SWISS SUBLANG_DEFAULT
3489 #ifndef SUBLANG_ITALIAN
3490 #define SUBLANG_ITALIAN SUBLANG_DEFAULT
3492 #ifndef SUBLANG_ITALIAN_SWISS
3493 #define SUBLANG_ITALIAN_SWISS SUBLANG_DEFAULT
3495 #ifndef SUBLANG_KASHMIRI_INDIA
3496 #define SUBLANG_KASHMIRI_INDIA SUBLANG_DEFAULT
3498 #ifndef SUBLANG_KOREAN
3499 #define SUBLANG_KOREAN SUBLANG_DEFAULT
3501 #ifndef SUBLANG_LITHUANIAN
3502 #define SUBLANG_LITHUANIAN SUBLANG_DEFAULT
3504 #ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
3505 #define SUBLANG_MALAY_BRUNEI_DARUSSALAM SUBLANG_DEFAULT
3507 #ifndef SUBLANG_MALAY_MALAYSIA
3508 #define SUBLANG_MALAY_MALAYSIA SUBLANG_DEFAULT
3510 #ifndef SUBLANG_NEPALI_INDIA
3511 #define SUBLANG_NEPALI_INDIA SUBLANG_DEFAULT
3513 #ifndef SUBLANG_NORWEGIAN_BOKMAL
3514 #define SUBLANG_NORWEGIAN_BOKMAL SUBLANG_DEFAULT
3516 #ifndef SUBLANG_NORWEGIAN_NYNORSK
3517 #define SUBLANG_NORWEGIAN_NYNORSK SUBLANG_DEFAULT
3519 #ifndef SUBLANG_PORTUGUESE
3520 #define SUBLANG_PORTUGUESE SUBLANG_DEFAULT
3522 #ifndef SUBLANG_PORTUGUESE_BRAZILIAN
3523 #define SUBLANG_PORTUGUESE_BRAZILIAN SUBLANG_DEFAULT
3525 #ifndef SUBLANG_SERBIAN_CYRILLIC
3526 #define SUBLANG_SERBIAN_CYRILLIC SUBLANG_DEFAULT
3528 #ifndef SUBLANG_SERBIAN_LATIN
3529 #define SUBLANG_SERBIAN_LATIN SUBLANG_DEFAULT
3531 #ifndef SUBLANG_SPANISH
3532 #define SUBLANG_SPANISH SUBLANG_DEFAULT
3534 #ifndef SUBLANG_SPANISH_ARGENTINA
3535 #define SUBLANG_SPANISH_ARGENTINA SUBLANG_DEFAULT
3537 #ifndef SUBLANG_SPANISH_BOLIVIA
3538 #define SUBLANG_SPANISH_BOLIVIA SUBLANG_DEFAULT
3540 #ifndef SUBLANG_SPANISH_CHILE
3541 #define SUBLANG_SPANISH_CHILE SUBLANG_DEFAULT
3543 #ifndef SUBLANG_SPANISH_COLOMBIA
3544 #define SUBLANG_SPANISH_COLOMBIA SUBLANG_DEFAULT
3546 #ifndef SUBLANG_SPANISH_COSTA_RICA
3547 #define SUBLANG_SPANISH_COSTA_RICA SUBLANG_DEFAULT
3549 #ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
3550 #define SUBLANG_SPANISH_DOMINICAN_REPUBLIC SUBLANG_DEFAULT
3552 #ifndef SUBLANG_SPANISH_ECUADOR
3553 #define SUBLANG_SPANISH_ECUADOR SUBLANG_DEFAULT
3555 #ifndef SUBLANG_SPANISH_EL_SALVADOR
3556 #define SUBLANG_SPANISH_EL_SALVADOR SUBLANG_DEFAULT
3558 #ifndef SUBLANG_SPANISH_GUATEMALA
3559 #define SUBLANG_SPANISH_GUATEMALA SUBLANG_DEFAULT
3561 #ifndef SUBLANG_SPANISH_HONDURAS
3562 #define SUBLANG_SPANISH_HONDURAS SUBLANG_DEFAULT
3564 #ifndef SUBLANG_SPANISH_MEXICAN
3565 #define SUBLANG_SPANISH_MEXICAN SUBLANG_DEFAULT
3567 #ifndef SUBLANG_SPANISH_MODERN
3568 #define SUBLANG_SPANISH_MODERN SUBLANG_DEFAULT
3570 #ifndef SUBLANG_SPANISH_NICARAGUA
3571 #define SUBLANG_SPANISH_NICARAGUA SUBLANG_DEFAULT
3573 #ifndef SUBLANG_SPANISH_PANAMA
3574 #define SUBLANG_SPANISH_PANAMA SUBLANG_DEFAULT
3576 #ifndef SUBLANG_SPANISH_PARAGUAY
3577 #define SUBLANG_SPANISH_PARAGUAY SUBLANG_DEFAULT
3579 #ifndef SUBLANG_SPANISH_PERU
3580 #define SUBLANG_SPANISH_PERU SUBLANG_DEFAULT
3582 #ifndef SUBLANG_SPANISH_PUERTO_RICO
3583 #define SUBLANG_SPANISH_PUERTO_RICO SUBLANG_DEFAULT
3585 #ifndef SUBLANG_SPANISH_URUGUAY
3586 #define SUBLANG_SPANISH_URUGUAY SUBLANG_DEFAULT
3588 #ifndef SUBLANG_SPANISH_VENEZUELA
3589 #define SUBLANG_SPANISH_VENEZUELA SUBLANG_DEFAULT
3591 #ifndef SUBLANG_SWEDISH
3592 #define SUBLANG_SWEDISH SUBLANG_DEFAULT
3594 #ifndef SUBLANG_SWEDISH_FINLAND
3595 #define SUBLANG_SWEDISH_FINLAND SUBLANG_DEFAULT
3597 #ifndef SUBLANG_URDU_INDIA
3598 #define SUBLANG_URDU_INDIA SUBLANG_DEFAULT
3600 #ifndef SUBLANG_URDU_PAKISTAN
3601 #define SUBLANG_URDU_PAKISTAN SUBLANG_DEFAULT
3603 #ifndef SUBLANG_UZBEK_CYRILLIC
3604 #define SUBLANG_UZBEK_CYRILLIC SUBLANG_DEFAULT
3606 #ifndef SUBLANG_UZBEK_LATIN
3607 #define SUBLANG_UZBEK_LATIN SUBLANG_DEFAULT
3613 #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
3614 info.Language = wxlang; \
3615 info.CanonicalName = wxT(canonical); \
3616 info.LayoutDirection = layout; \
3617 info.Description = wxT(desc); \
3618 SETWINLANG(info, winlang, winsublang) \
3621 void wxLocale::InitLanguagesDB()
3623 wxLanguageInfo info
;
3624 wxStringTokenizer tkn
;
3626 LNG(wxLANGUAGE_ABKHAZIAN
, "ab" , 0 , 0 , wxLayout_LeftToRight
, "Abkhazian")
3627 LNG(wxLANGUAGE_AFAR
, "aa" , 0 , 0 , wxLayout_LeftToRight
, "Afar")
3628 LNG(wxLANGUAGE_AFRIKAANS
, "af_ZA", LANG_AFRIKAANS
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Afrikaans")
3629 LNG(wxLANGUAGE_ALBANIAN
, "sq_AL", LANG_ALBANIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Albanian")
3630 LNG(wxLANGUAGE_AMHARIC
, "am" , 0 , 0 , wxLayout_LeftToRight
, "Amharic")
3631 LNG(wxLANGUAGE_ARABIC
, "ar" , LANG_ARABIC
, SUBLANG_DEFAULT
, wxLayout_RightToLeft
, "Arabic")
3632 LNG(wxLANGUAGE_ARABIC_ALGERIA
, "ar_DZ", LANG_ARABIC
, SUBLANG_ARABIC_ALGERIA
, wxLayout_RightToLeft
, "Arabic (Algeria)")
3633 LNG(wxLANGUAGE_ARABIC_BAHRAIN
, "ar_BH", LANG_ARABIC
, SUBLANG_ARABIC_BAHRAIN
, wxLayout_RightToLeft
, "Arabic (Bahrain)")
3634 LNG(wxLANGUAGE_ARABIC_EGYPT
, "ar_EG", LANG_ARABIC
, SUBLANG_ARABIC_EGYPT
, wxLayout_RightToLeft
, "Arabic (Egypt)")
3635 LNG(wxLANGUAGE_ARABIC_IRAQ
, "ar_IQ", LANG_ARABIC
, SUBLANG_ARABIC_IRAQ
, wxLayout_RightToLeft
, "Arabic (Iraq)")
3636 LNG(wxLANGUAGE_ARABIC_JORDAN
, "ar_JO", LANG_ARABIC
, SUBLANG_ARABIC_JORDAN
, wxLayout_RightToLeft
, "Arabic (Jordan)")
3637 LNG(wxLANGUAGE_ARABIC_KUWAIT
, "ar_KW", LANG_ARABIC
, SUBLANG_ARABIC_KUWAIT
, wxLayout_RightToLeft
, "Arabic (Kuwait)")
3638 LNG(wxLANGUAGE_ARABIC_LEBANON
, "ar_LB", LANG_ARABIC
, SUBLANG_ARABIC_LEBANON
, wxLayout_RightToLeft
, "Arabic (Lebanon)")
3639 LNG(wxLANGUAGE_ARABIC_LIBYA
, "ar_LY", LANG_ARABIC
, SUBLANG_ARABIC_LIBYA
, wxLayout_RightToLeft
, "Arabic (Libya)")
3640 LNG(wxLANGUAGE_ARABIC_MOROCCO
, "ar_MA", LANG_ARABIC
, SUBLANG_ARABIC_MOROCCO
, wxLayout_RightToLeft
, "Arabic (Morocco)")
3641 LNG(wxLANGUAGE_ARABIC_OMAN
, "ar_OM", LANG_ARABIC
, SUBLANG_ARABIC_OMAN
, wxLayout_RightToLeft
, "Arabic (Oman)")
3642 LNG(wxLANGUAGE_ARABIC_QATAR
, "ar_QA", LANG_ARABIC
, SUBLANG_ARABIC_QATAR
, wxLayout_RightToLeft
, "Arabic (Qatar)")
3643 LNG(wxLANGUAGE_ARABIC_SAUDI_ARABIA
, "ar_SA", LANG_ARABIC
, SUBLANG_ARABIC_SAUDI_ARABIA
, wxLayout_RightToLeft
, "Arabic (Saudi Arabia)")
3644 LNG(wxLANGUAGE_ARABIC_SUDAN
, "ar_SD", 0 , 0 , wxLayout_RightToLeft
, "Arabic (Sudan)")
3645 LNG(wxLANGUAGE_ARABIC_SYRIA
, "ar_SY", LANG_ARABIC
, SUBLANG_ARABIC_SYRIA
, wxLayout_RightToLeft
, "Arabic (Syria)")
3646 LNG(wxLANGUAGE_ARABIC_TUNISIA
, "ar_TN", LANG_ARABIC
, SUBLANG_ARABIC_TUNISIA
, wxLayout_RightToLeft
, "Arabic (Tunisia)")
3647 LNG(wxLANGUAGE_ARABIC_UAE
, "ar_AE", LANG_ARABIC
, SUBLANG_ARABIC_UAE
, wxLayout_RightToLeft
, "Arabic (Uae)")
3648 LNG(wxLANGUAGE_ARABIC_YEMEN
, "ar_YE", LANG_ARABIC
, SUBLANG_ARABIC_YEMEN
, wxLayout_RightToLeft
, "Arabic (Yemen)")
3649 LNG(wxLANGUAGE_ARMENIAN
, "hy" , LANG_ARMENIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Armenian")
3650 LNG(wxLANGUAGE_ASSAMESE
, "as" , LANG_ASSAMESE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Assamese")
3651 LNG(wxLANGUAGE_ASTURIAN
, "ast" , 0 , 0 , wxLayout_LeftToRight
, "Asturian")
3652 LNG(wxLANGUAGE_AYMARA
, "ay" , 0 , 0 , wxLayout_LeftToRight
, "Aymara")
3653 LNG(wxLANGUAGE_AZERI
, "az" , LANG_AZERI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Azeri")
3654 LNG(wxLANGUAGE_AZERI_CYRILLIC
, "az" , LANG_AZERI
, SUBLANG_AZERI_CYRILLIC
, wxLayout_LeftToRight
, "Azeri (Cyrillic)")
3655 LNG(wxLANGUAGE_AZERI_LATIN
, "az" , LANG_AZERI
, SUBLANG_AZERI_LATIN
, wxLayout_LeftToRight
, "Azeri (Latin)")
3656 LNG(wxLANGUAGE_BASHKIR
, "ba" , 0 , 0 , wxLayout_LeftToRight
, "Bashkir")
3657 LNG(wxLANGUAGE_BASQUE
, "eu_ES", LANG_BASQUE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Basque")
3658 LNG(wxLANGUAGE_BELARUSIAN
, "be_BY", LANG_BELARUSIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Belarusian")
3659 LNG(wxLANGUAGE_BENGALI
, "bn" , LANG_BENGALI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Bengali")
3660 LNG(wxLANGUAGE_BHUTANI
, "dz" , 0 , 0 , wxLayout_LeftToRight
, "Bhutani")
3661 LNG(wxLANGUAGE_BIHARI
, "bh" , 0 , 0 , wxLayout_LeftToRight
, "Bihari")
3662 LNG(wxLANGUAGE_BISLAMA
, "bi" , 0 , 0 , wxLayout_LeftToRight
, "Bislama")
3663 LNG(wxLANGUAGE_BRETON
, "br" , 0 , 0 , wxLayout_LeftToRight
, "Breton")
3664 LNG(wxLANGUAGE_BULGARIAN
, "bg_BG", LANG_BULGARIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Bulgarian")
3665 LNG(wxLANGUAGE_BURMESE
, "my" , 0 , 0 , wxLayout_LeftToRight
, "Burmese")
3666 LNG(wxLANGUAGE_CAMBODIAN
, "km" , 0 , 0 , wxLayout_LeftToRight
, "Cambodian")
3667 LNG(wxLANGUAGE_CATALAN
, "ca_ES", LANG_CATALAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Catalan")
3668 LNG(wxLANGUAGE_CHINESE
, "zh_TW", LANG_CHINESE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Chinese")
3669 LNG(wxLANGUAGE_CHINESE_SIMPLIFIED
, "zh_CN", LANG_CHINESE
, SUBLANG_CHINESE_SIMPLIFIED
, wxLayout_LeftToRight
, "Chinese (Simplified)")
3670 LNG(wxLANGUAGE_CHINESE_TRADITIONAL
, "zh_TW", LANG_CHINESE
, SUBLANG_CHINESE_TRADITIONAL
, wxLayout_LeftToRight
, "Chinese (Traditional)")
3671 LNG(wxLANGUAGE_CHINESE_HONGKONG
, "zh_HK", LANG_CHINESE
, SUBLANG_CHINESE_HONGKONG
, wxLayout_LeftToRight
, "Chinese (Hongkong)")
3672 LNG(wxLANGUAGE_CHINESE_MACAU
, "zh_MO", LANG_CHINESE
, SUBLANG_CHINESE_MACAU
, wxLayout_LeftToRight
, "Chinese (Macau)")
3673 LNG(wxLANGUAGE_CHINESE_SINGAPORE
, "zh_SG", LANG_CHINESE
, SUBLANG_CHINESE_SINGAPORE
, wxLayout_LeftToRight
, "Chinese (Singapore)")
3674 LNG(wxLANGUAGE_CHINESE_TAIWAN
, "zh_TW", LANG_CHINESE
, SUBLANG_CHINESE_TRADITIONAL
, wxLayout_LeftToRight
, "Chinese (Taiwan)")
3675 LNG(wxLANGUAGE_CORSICAN
, "co" , 0 , 0 , wxLayout_LeftToRight
, "Corsican")
3676 LNG(wxLANGUAGE_CROATIAN
, "hr_HR", LANG_CROATIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Croatian")
3677 LNG(wxLANGUAGE_CZECH
, "cs_CZ", LANG_CZECH
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Czech")
3678 LNG(wxLANGUAGE_DANISH
, "da_DK", LANG_DANISH
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Danish")
3679 LNG(wxLANGUAGE_DUTCH
, "nl_NL", LANG_DUTCH
, SUBLANG_DUTCH
, wxLayout_LeftToRight
, "Dutch")
3680 LNG(wxLANGUAGE_DUTCH_BELGIAN
, "nl_BE", LANG_DUTCH
, SUBLANG_DUTCH_BELGIAN
, wxLayout_LeftToRight
, "Dutch (Belgian)")
3681 LNG(wxLANGUAGE_ENGLISH
, "en_GB", LANG_ENGLISH
, SUBLANG_ENGLISH_UK
, wxLayout_LeftToRight
, "English")
3682 LNG(wxLANGUAGE_ENGLISH_UK
, "en_GB", LANG_ENGLISH
, SUBLANG_ENGLISH_UK
, wxLayout_LeftToRight
, "English (U.K.)")
3683 LNG(wxLANGUAGE_ENGLISH_US
, "en_US", LANG_ENGLISH
, SUBLANG_ENGLISH_US
, wxLayout_LeftToRight
, "English (U.S.)")
3684 LNG(wxLANGUAGE_ENGLISH_AUSTRALIA
, "en_AU", LANG_ENGLISH
, SUBLANG_ENGLISH_AUS
, wxLayout_LeftToRight
, "English (Australia)")
3685 LNG(wxLANGUAGE_ENGLISH_BELIZE
, "en_BZ", LANG_ENGLISH
, SUBLANG_ENGLISH_BELIZE
, wxLayout_LeftToRight
, "English (Belize)")
3686 LNG(wxLANGUAGE_ENGLISH_BOTSWANA
, "en_BW", 0 , 0 , wxLayout_LeftToRight
, "English (Botswana)")
3687 LNG(wxLANGUAGE_ENGLISH_CANADA
, "en_CA", LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
, wxLayout_LeftToRight
, "English (Canada)")
3688 LNG(wxLANGUAGE_ENGLISH_CARIBBEAN
, "en_CB", LANG_ENGLISH
, SUBLANG_ENGLISH_CARIBBEAN
, wxLayout_LeftToRight
, "English (Caribbean)")
3689 LNG(wxLANGUAGE_ENGLISH_DENMARK
, "en_DK", 0 , 0 , wxLayout_LeftToRight
, "English (Denmark)")
3690 LNG(wxLANGUAGE_ENGLISH_EIRE
, "en_IE", LANG_ENGLISH
, SUBLANG_ENGLISH_EIRE
, wxLayout_LeftToRight
, "English (Eire)")
3691 LNG(wxLANGUAGE_ENGLISH_JAMAICA
, "en_JM", LANG_ENGLISH
, SUBLANG_ENGLISH_JAMAICA
, wxLayout_LeftToRight
, "English (Jamaica)")
3692 LNG(wxLANGUAGE_ENGLISH_NEW_ZEALAND
, "en_NZ", LANG_ENGLISH
, SUBLANG_ENGLISH_NZ
, wxLayout_LeftToRight
, "English (New Zealand)")
3693 LNG(wxLANGUAGE_ENGLISH_PHILIPPINES
, "en_PH", LANG_ENGLISH
, SUBLANG_ENGLISH_PHILIPPINES
, wxLayout_LeftToRight
, "English (Philippines)")
3694 LNG(wxLANGUAGE_ENGLISH_SOUTH_AFRICA
, "en_ZA", LANG_ENGLISH
, SUBLANG_ENGLISH_SOUTH_AFRICA
, wxLayout_LeftToRight
, "English (South Africa)")
3695 LNG(wxLANGUAGE_ENGLISH_TRINIDAD
, "en_TT", LANG_ENGLISH
, SUBLANG_ENGLISH_TRINIDAD
, wxLayout_LeftToRight
, "English (Trinidad)")
3696 LNG(wxLANGUAGE_ENGLISH_ZIMBABWE
, "en_ZW", LANG_ENGLISH
, SUBLANG_ENGLISH_ZIMBABWE
, wxLayout_LeftToRight
, "English (Zimbabwe)")
3697 LNG(wxLANGUAGE_ESPERANTO
, "eo" , 0 , 0 , wxLayout_LeftToRight
, "Esperanto")
3698 LNG(wxLANGUAGE_ESTONIAN
, "et_EE", LANG_ESTONIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Estonian")
3699 LNG(wxLANGUAGE_FAEROESE
, "fo_FO", LANG_FAEROESE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Faeroese")
3700 LNG(wxLANGUAGE_FARSI
, "fa_IR", LANG_FARSI
, SUBLANG_DEFAULT
, wxLayout_RightToLeft
, "Farsi")
3701 LNG(wxLANGUAGE_FIJI
, "fj" , 0 , 0 , wxLayout_LeftToRight
, "Fiji")
3702 LNG(wxLANGUAGE_FINNISH
, "fi_FI", LANG_FINNISH
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Finnish")
3703 LNG(wxLANGUAGE_FRENCH
, "fr_FR", LANG_FRENCH
, SUBLANG_FRENCH
, wxLayout_LeftToRight
, "French")
3704 LNG(wxLANGUAGE_FRENCH_BELGIAN
, "fr_BE", LANG_FRENCH
, SUBLANG_FRENCH_BELGIAN
, wxLayout_LeftToRight
, "French (Belgian)")
3705 LNG(wxLANGUAGE_FRENCH_CANADIAN
, "fr_CA", LANG_FRENCH
, SUBLANG_FRENCH_CANADIAN
, wxLayout_LeftToRight
, "French (Canadian)")
3706 LNG(wxLANGUAGE_FRENCH_LUXEMBOURG
, "fr_LU", LANG_FRENCH
, SUBLANG_FRENCH_LUXEMBOURG
, wxLayout_LeftToRight
, "French (Luxembourg)")
3707 LNG(wxLANGUAGE_FRENCH_MONACO
, "fr_MC", LANG_FRENCH
, SUBLANG_FRENCH_MONACO
, wxLayout_LeftToRight
, "French (Monaco)")
3708 LNG(wxLANGUAGE_FRENCH_SWISS
, "fr_CH", LANG_FRENCH
, SUBLANG_FRENCH_SWISS
, wxLayout_LeftToRight
, "French (Swiss)")
3709 LNG(wxLANGUAGE_FRISIAN
, "fy" , 0 , 0 , wxLayout_LeftToRight
, "Frisian")
3710 LNG(wxLANGUAGE_GALICIAN
, "gl_ES", 0 , 0 , wxLayout_LeftToRight
, "Galician")
3711 LNG(wxLANGUAGE_GEORGIAN
, "ka_GE", LANG_GEORGIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Georgian")
3712 LNG(wxLANGUAGE_GERMAN
, "de_DE", LANG_GERMAN
, SUBLANG_GERMAN
, wxLayout_LeftToRight
, "German")
3713 LNG(wxLANGUAGE_GERMAN_AUSTRIAN
, "de_AT", LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
, wxLayout_LeftToRight
, "German (Austrian)")
3714 LNG(wxLANGUAGE_GERMAN_BELGIUM
, "de_BE", 0 , 0 , wxLayout_LeftToRight
, "German (Belgium)")
3715 LNG(wxLANGUAGE_GERMAN_LIECHTENSTEIN
, "de_LI", LANG_GERMAN
, SUBLANG_GERMAN_LIECHTENSTEIN
, wxLayout_LeftToRight
, "German (Liechtenstein)")
3716 LNG(wxLANGUAGE_GERMAN_LUXEMBOURG
, "de_LU", LANG_GERMAN
, SUBLANG_GERMAN_LUXEMBOURG
, wxLayout_LeftToRight
, "German (Luxembourg)")
3717 LNG(wxLANGUAGE_GERMAN_SWISS
, "de_CH", LANG_GERMAN
, SUBLANG_GERMAN_SWISS
, wxLayout_LeftToRight
, "German (Swiss)")
3718 LNG(wxLANGUAGE_GREEK
, "el_GR", LANG_GREEK
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Greek")
3719 LNG(wxLANGUAGE_GREENLANDIC
, "kl_GL", 0 , 0 , wxLayout_LeftToRight
, "Greenlandic")
3720 LNG(wxLANGUAGE_GUARANI
, "gn" , 0 , 0 , wxLayout_LeftToRight
, "Guarani")
3721 LNG(wxLANGUAGE_GUJARATI
, "gu" , LANG_GUJARATI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Gujarati")
3722 LNG(wxLANGUAGE_HAUSA
, "ha" , 0 , 0 , wxLayout_LeftToRight
, "Hausa")
3723 LNG(wxLANGUAGE_HEBREW
, "he_IL", LANG_HEBREW
, SUBLANG_DEFAULT
, wxLayout_RightToLeft
, "Hebrew")
3724 LNG(wxLANGUAGE_HINDI
, "hi_IN", LANG_HINDI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Hindi")
3725 LNG(wxLANGUAGE_HUNGARIAN
, "hu_HU", LANG_HUNGARIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Hungarian")
3726 LNG(wxLANGUAGE_ICELANDIC
, "is_IS", LANG_ICELANDIC
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Icelandic")
3727 LNG(wxLANGUAGE_INDONESIAN
, "id_ID", LANG_INDONESIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Indonesian")
3728 LNG(wxLANGUAGE_INTERLINGUA
, "ia" , 0 , 0 , wxLayout_LeftToRight
, "Interlingua")
3729 LNG(wxLANGUAGE_INTERLINGUE
, "ie" , 0 , 0 , wxLayout_LeftToRight
, "Interlingue")
3730 LNG(wxLANGUAGE_INUKTITUT
, "iu" , 0 , 0 , wxLayout_LeftToRight
, "Inuktitut")
3731 LNG(wxLANGUAGE_INUPIAK
, "ik" , 0 , 0 , wxLayout_LeftToRight
, "Inupiak")
3732 LNG(wxLANGUAGE_IRISH
, "ga_IE", 0 , 0 , wxLayout_LeftToRight
, "Irish")
3733 LNG(wxLANGUAGE_ITALIAN
, "it_IT", LANG_ITALIAN
, SUBLANG_ITALIAN
, wxLayout_LeftToRight
, "Italian")
3734 LNG(wxLANGUAGE_ITALIAN_SWISS
, "it_CH", LANG_ITALIAN
, SUBLANG_ITALIAN_SWISS
, wxLayout_LeftToRight
, "Italian (Swiss)")
3735 LNG(wxLANGUAGE_JAPANESE
, "ja_JP", LANG_JAPANESE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Japanese")
3736 LNG(wxLANGUAGE_JAVANESE
, "jw" , 0 , 0 , wxLayout_LeftToRight
, "Javanese")
3737 LNG(wxLANGUAGE_KANNADA
, "kn" , LANG_KANNADA
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Kannada")
3738 LNG(wxLANGUAGE_KASHMIRI
, "ks" , LANG_KASHMIRI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Kashmiri")
3739 LNG(wxLANGUAGE_KASHMIRI_INDIA
, "ks_IN", LANG_KASHMIRI
, SUBLANG_KASHMIRI_INDIA
, wxLayout_LeftToRight
, "Kashmiri (India)")
3740 LNG(wxLANGUAGE_KAZAKH
, "kk" , LANG_KAZAK
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Kazakh")
3741 LNG(wxLANGUAGE_KERNEWEK
, "kw_GB", 0 , 0 , wxLayout_LeftToRight
, "Kernewek")
3742 LNG(wxLANGUAGE_KINYARWANDA
, "rw" , 0 , 0 , wxLayout_LeftToRight
, "Kinyarwanda")
3743 LNG(wxLANGUAGE_KIRGHIZ
, "ky" , 0 , 0 , wxLayout_LeftToRight
, "Kirghiz")
3744 LNG(wxLANGUAGE_KIRUNDI
, "rn" , 0 , 0 , wxLayout_LeftToRight
, "Kirundi")
3745 LNG(wxLANGUAGE_KONKANI
, "" , LANG_KONKANI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Konkani")
3746 LNG(wxLANGUAGE_KOREAN
, "ko_KR", LANG_KOREAN
, SUBLANG_KOREAN
, wxLayout_LeftToRight
, "Korean")
3747 LNG(wxLANGUAGE_KURDISH
, "ku_TR", 0 , 0 , wxLayout_LeftToRight
, "Kurdish")
3748 LNG(wxLANGUAGE_LAOTHIAN
, "lo" , 0 , 0 , wxLayout_LeftToRight
, "Laothian")
3749 LNG(wxLANGUAGE_LATIN
, "la" , 0 , 0 , wxLayout_LeftToRight
, "Latin")
3750 LNG(wxLANGUAGE_LATVIAN
, "lv_LV", LANG_LATVIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Latvian")
3751 LNG(wxLANGUAGE_LINGALA
, "ln" , 0 , 0 , wxLayout_LeftToRight
, "Lingala")
3752 LNG(wxLANGUAGE_LITHUANIAN
, "lt_LT", LANG_LITHUANIAN
, SUBLANG_LITHUANIAN
, wxLayout_LeftToRight
, "Lithuanian")
3753 LNG(wxLANGUAGE_MACEDONIAN
, "mk_MK", LANG_MACEDONIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Macedonian")
3754 LNG(wxLANGUAGE_MALAGASY
, "mg" , 0 , 0 , wxLayout_LeftToRight
, "Malagasy")
3755 LNG(wxLANGUAGE_MALAY
, "ms_MY", LANG_MALAY
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Malay")
3756 LNG(wxLANGUAGE_MALAYALAM
, "ml" , LANG_MALAYALAM
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Malayalam")
3757 LNG(wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM
, "ms_BN", LANG_MALAY
, SUBLANG_MALAY_BRUNEI_DARUSSALAM
, wxLayout_LeftToRight
, "Malay (Brunei Darussalam)")
3758 LNG(wxLANGUAGE_MALAY_MALAYSIA
, "ms_MY", LANG_MALAY
, SUBLANG_MALAY_MALAYSIA
, wxLayout_LeftToRight
, "Malay (Malaysia)")
3759 LNG(wxLANGUAGE_MALTESE
, "mt_MT", 0 , 0 , wxLayout_LeftToRight
, "Maltese")
3760 LNG(wxLANGUAGE_MANIPURI
, "" , LANG_MANIPURI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Manipuri")
3761 LNG(wxLANGUAGE_MAORI
, "mi" , 0 , 0 , wxLayout_LeftToRight
, "Maori")
3762 LNG(wxLANGUAGE_MARATHI
, "mr_IN", LANG_MARATHI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Marathi")
3763 LNG(wxLANGUAGE_MOLDAVIAN
, "mo" , 0 , 0 , wxLayout_LeftToRight
, "Moldavian")
3764 LNG(wxLANGUAGE_MONGOLIAN
, "mn" , 0 , 0 , wxLayout_LeftToRight
, "Mongolian")
3765 LNG(wxLANGUAGE_NAURU
, "na" , 0 , 0 , wxLayout_LeftToRight
, "Nauru")
3766 LNG(wxLANGUAGE_NEPALI
, "ne_NP", LANG_NEPALI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Nepali")
3767 LNG(wxLANGUAGE_NEPALI_INDIA
, "ne_IN", LANG_NEPALI
, SUBLANG_NEPALI_INDIA
, wxLayout_LeftToRight
, "Nepali (India)")
3768 LNG(wxLANGUAGE_NORWEGIAN_BOKMAL
, "nb_NO", LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_BOKMAL
, wxLayout_LeftToRight
, "Norwegian (Bokmal)")
3769 LNG(wxLANGUAGE_NORWEGIAN_NYNORSK
, "nn_NO", LANG_NORWEGIAN
, SUBLANG_NORWEGIAN_NYNORSK
, wxLayout_LeftToRight
, "Norwegian (Nynorsk)")
3770 LNG(wxLANGUAGE_OCCITAN
, "oc" , 0 , 0 , wxLayout_LeftToRight
, "Occitan")
3771 LNG(wxLANGUAGE_ORIYA
, "or" , LANG_ORIYA
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Oriya")
3772 LNG(wxLANGUAGE_OROMO
, "om" , 0 , 0 , wxLayout_LeftToRight
, "(Afan) Oromo")
3773 LNG(wxLANGUAGE_PASHTO
, "ps" , 0 , 0 , wxLayout_LeftToRight
, "Pashto, Pushto")
3774 LNG(wxLANGUAGE_POLISH
, "pl_PL", LANG_POLISH
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Polish")
3775 LNG(wxLANGUAGE_PORTUGUESE
, "pt_PT", LANG_PORTUGUESE
, SUBLANG_PORTUGUESE
, wxLayout_LeftToRight
, "Portuguese")
3776 LNG(wxLANGUAGE_PORTUGUESE_BRAZILIAN
, "pt_BR", LANG_PORTUGUESE
, SUBLANG_PORTUGUESE_BRAZILIAN
, wxLayout_LeftToRight
, "Portuguese (Brazilian)")
3777 LNG(wxLANGUAGE_PUNJABI
, "pa" , LANG_PUNJABI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Punjabi")
3778 LNG(wxLANGUAGE_QUECHUA
, "qu" , 0 , 0 , wxLayout_LeftToRight
, "Quechua")
3779 LNG(wxLANGUAGE_RHAETO_ROMANCE
, "rm" , 0 , 0 , wxLayout_LeftToRight
, "Rhaeto-Romance")
3780 LNG(wxLANGUAGE_ROMANIAN
, "ro_RO", LANG_ROMANIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Romanian")
3781 LNG(wxLANGUAGE_RUSSIAN
, "ru_RU", LANG_RUSSIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Russian")
3782 LNG(wxLANGUAGE_RUSSIAN_UKRAINE
, "ru_UA", 0 , 0 , wxLayout_LeftToRight
, "Russian (Ukraine)")
3783 LNG(wxLANGUAGE_SAMI
, "se_NO", LANG_SAMI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Northern Sami")
3784 LNG(wxLANGUAGE_SAMOAN
, "sm" , 0 , 0 , wxLayout_LeftToRight
, "Samoan")
3785 LNG(wxLANGUAGE_SANGHO
, "sg" , 0 , 0 , wxLayout_LeftToRight
, "Sangho")
3786 LNG(wxLANGUAGE_SANSKRIT
, "sa" , LANG_SANSKRIT
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Sanskrit")
3787 LNG(wxLANGUAGE_SCOTS_GAELIC
, "gd" , 0 , 0 , wxLayout_LeftToRight
, "Scots Gaelic")
3788 LNG(wxLANGUAGE_SERBIAN
, "sr_RS", LANG_SERBIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Serbian")
3789 LNG(wxLANGUAGE_SERBIAN_CYRILLIC
, "sr_RS", LANG_SERBIAN
, SUBLANG_SERBIAN_CYRILLIC
, wxLayout_LeftToRight
, "Serbian (Cyrillic)")
3790 LNG(wxLANGUAGE_SERBIAN_LATIN
, "sr_RS@latin", LANG_SERBIAN
, SUBLANG_SERBIAN_LATIN
, wxLayout_LeftToRight
, "Serbian (Latin)")
3791 LNG(wxLANGUAGE_SERBIAN_CYRILLIC
, "sr_YU", LANG_SERBIAN
, SUBLANG_SERBIAN_CYRILLIC
, wxLayout_LeftToRight
, "Serbian (Cyrillic)")
3792 LNG(wxLANGUAGE_SERBIAN_LATIN
, "sr_YU@latin", LANG_SERBIAN
, SUBLANG_SERBIAN_LATIN
, wxLayout_LeftToRight
, "Serbian (Latin)")
3793 LNG(wxLANGUAGE_SERBO_CROATIAN
, "sh" , 0 , 0 , wxLayout_LeftToRight
, "Serbo-Croatian")
3794 LNG(wxLANGUAGE_SESOTHO
, "st" , 0 , 0 , wxLayout_LeftToRight
, "Sesotho")
3795 LNG(wxLANGUAGE_SETSWANA
, "tn" , 0 , 0 , wxLayout_LeftToRight
, "Setswana")
3796 LNG(wxLANGUAGE_SHONA
, "sn" , 0 , 0 , wxLayout_LeftToRight
, "Shona")
3797 LNG(wxLANGUAGE_SINDHI
, "sd" , LANG_SINDHI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Sindhi")
3798 LNG(wxLANGUAGE_SINHALESE
, "si" , 0 , 0 , wxLayout_LeftToRight
, "Sinhalese")
3799 LNG(wxLANGUAGE_SISWATI
, "ss" , 0 , 0 , wxLayout_LeftToRight
, "Siswati")
3800 LNG(wxLANGUAGE_SLOVAK
, "sk_SK", LANG_SLOVAK
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Slovak")
3801 LNG(wxLANGUAGE_SLOVENIAN
, "sl_SI", LANG_SLOVENIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Slovenian")
3802 LNG(wxLANGUAGE_SOMALI
, "so" , 0 , 0 , wxLayout_LeftToRight
, "Somali")
3803 LNG(wxLANGUAGE_SPANISH
, "es_ES", LANG_SPANISH
, SUBLANG_SPANISH
, wxLayout_LeftToRight
, "Spanish")
3804 LNG(wxLANGUAGE_SPANISH_ARGENTINA
, "es_AR", LANG_SPANISH
, SUBLANG_SPANISH_ARGENTINA
, wxLayout_LeftToRight
, "Spanish (Argentina)")
3805 LNG(wxLANGUAGE_SPANISH_BOLIVIA
, "es_BO", LANG_SPANISH
, SUBLANG_SPANISH_BOLIVIA
, wxLayout_LeftToRight
, "Spanish (Bolivia)")
3806 LNG(wxLANGUAGE_SPANISH_CHILE
, "es_CL", LANG_SPANISH
, SUBLANG_SPANISH_CHILE
, wxLayout_LeftToRight
, "Spanish (Chile)")
3807 LNG(wxLANGUAGE_SPANISH_COLOMBIA
, "es_CO", LANG_SPANISH
, SUBLANG_SPANISH_COLOMBIA
, wxLayout_LeftToRight
, "Spanish (Colombia)")
3808 LNG(wxLANGUAGE_SPANISH_COSTA_RICA
, "es_CR", LANG_SPANISH
, SUBLANG_SPANISH_COSTA_RICA
, wxLayout_LeftToRight
, "Spanish (Costa Rica)")
3809 LNG(wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC
, "es_DO", LANG_SPANISH
, SUBLANG_SPANISH_DOMINICAN_REPUBLIC
, wxLayout_LeftToRight
, "Spanish (Dominican republic)")
3810 LNG(wxLANGUAGE_SPANISH_ECUADOR
, "es_EC", LANG_SPANISH
, SUBLANG_SPANISH_ECUADOR
, wxLayout_LeftToRight
, "Spanish (Ecuador)")
3811 LNG(wxLANGUAGE_SPANISH_EL_SALVADOR
, "es_SV", LANG_SPANISH
, SUBLANG_SPANISH_EL_SALVADOR
, wxLayout_LeftToRight
, "Spanish (El Salvador)")
3812 LNG(wxLANGUAGE_SPANISH_GUATEMALA
, "es_GT", LANG_SPANISH
, SUBLANG_SPANISH_GUATEMALA
, wxLayout_LeftToRight
, "Spanish (Guatemala)")
3813 LNG(wxLANGUAGE_SPANISH_HONDURAS
, "es_HN", LANG_SPANISH
, SUBLANG_SPANISH_HONDURAS
, wxLayout_LeftToRight
, "Spanish (Honduras)")
3814 LNG(wxLANGUAGE_SPANISH_MEXICAN
, "es_MX", LANG_SPANISH
, SUBLANG_SPANISH_MEXICAN
, wxLayout_LeftToRight
, "Spanish (Mexican)")
3815 LNG(wxLANGUAGE_SPANISH_MODERN
, "es_ES", LANG_SPANISH
, SUBLANG_SPANISH_MODERN
, wxLayout_LeftToRight
, "Spanish (Modern)")
3816 LNG(wxLANGUAGE_SPANISH_NICARAGUA
, "es_NI", LANG_SPANISH
, SUBLANG_SPANISH_NICARAGUA
, wxLayout_LeftToRight
, "Spanish (Nicaragua)")
3817 LNG(wxLANGUAGE_SPANISH_PANAMA
, "es_PA", LANG_SPANISH
, SUBLANG_SPANISH_PANAMA
, wxLayout_LeftToRight
, "Spanish (Panama)")
3818 LNG(wxLANGUAGE_SPANISH_PARAGUAY
, "es_PY", LANG_SPANISH
, SUBLANG_SPANISH_PARAGUAY
, wxLayout_LeftToRight
, "Spanish (Paraguay)")
3819 LNG(wxLANGUAGE_SPANISH_PERU
, "es_PE", LANG_SPANISH
, SUBLANG_SPANISH_PERU
, wxLayout_LeftToRight
, "Spanish (Peru)")
3820 LNG(wxLANGUAGE_SPANISH_PUERTO_RICO
, "es_PR", LANG_SPANISH
, SUBLANG_SPANISH_PUERTO_RICO
, wxLayout_LeftToRight
, "Spanish (Puerto Rico)")
3821 LNG(wxLANGUAGE_SPANISH_URUGUAY
, "es_UY", LANG_SPANISH
, SUBLANG_SPANISH_URUGUAY
, wxLayout_LeftToRight
, "Spanish (Uruguay)")
3822 LNG(wxLANGUAGE_SPANISH_US
, "es_US", 0 , 0 , wxLayout_LeftToRight
, "Spanish (U.S.)")
3823 LNG(wxLANGUAGE_SPANISH_VENEZUELA
, "es_VE", LANG_SPANISH
, SUBLANG_SPANISH_VENEZUELA
, wxLayout_LeftToRight
, "Spanish (Venezuela)")
3824 LNG(wxLANGUAGE_SUNDANESE
, "su" , 0 , 0 , wxLayout_LeftToRight
, "Sundanese")
3825 LNG(wxLANGUAGE_SWAHILI
, "sw_KE", LANG_SWAHILI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Swahili")
3826 LNG(wxLANGUAGE_SWEDISH
, "sv_SE", LANG_SWEDISH
, SUBLANG_SWEDISH
, wxLayout_LeftToRight
, "Swedish")
3827 LNG(wxLANGUAGE_SWEDISH_FINLAND
, "sv_FI", LANG_SWEDISH
, SUBLANG_SWEDISH_FINLAND
, wxLayout_LeftToRight
, "Swedish (Finland)")
3828 LNG(wxLANGUAGE_TAGALOG
, "tl_PH", 0 , 0 , wxLayout_LeftToRight
, "Tagalog")
3829 LNG(wxLANGUAGE_TAJIK
, "tg" , 0 , 0 , wxLayout_LeftToRight
, "Tajik")
3830 LNG(wxLANGUAGE_TAMIL
, "ta" , LANG_TAMIL
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Tamil")
3831 LNG(wxLANGUAGE_TATAR
, "tt" , LANG_TATAR
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Tatar")
3832 LNG(wxLANGUAGE_TELUGU
, "te" , LANG_TELUGU
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Telugu")
3833 LNG(wxLANGUAGE_THAI
, "th_TH", LANG_THAI
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Thai")
3834 LNG(wxLANGUAGE_TIBETAN
, "bo" , 0 , 0 , wxLayout_LeftToRight
, "Tibetan")
3835 LNG(wxLANGUAGE_TIGRINYA
, "ti" , 0 , 0 , wxLayout_LeftToRight
, "Tigrinya")
3836 LNG(wxLANGUAGE_TONGA
, "to" , 0 , 0 , wxLayout_LeftToRight
, "Tonga")
3837 LNG(wxLANGUAGE_TSONGA
, "ts" , 0 , 0 , wxLayout_LeftToRight
, "Tsonga")
3838 LNG(wxLANGUAGE_TURKISH
, "tr_TR", LANG_TURKISH
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Turkish")
3839 LNG(wxLANGUAGE_TURKMEN
, "tk" , 0 , 0 , wxLayout_LeftToRight
, "Turkmen")
3840 LNG(wxLANGUAGE_TWI
, "tw" , 0 , 0 , wxLayout_LeftToRight
, "Twi")
3841 LNG(wxLANGUAGE_UIGHUR
, "ug" , 0 , 0 , wxLayout_LeftToRight
, "Uighur")
3842 LNG(wxLANGUAGE_UKRAINIAN
, "uk_UA", LANG_UKRAINIAN
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Ukrainian")
3843 LNG(wxLANGUAGE_URDU
, "ur" , LANG_URDU
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Urdu")
3844 LNG(wxLANGUAGE_URDU_INDIA
, "ur_IN", LANG_URDU
, SUBLANG_URDU_INDIA
, wxLayout_LeftToRight
, "Urdu (India)")
3845 LNG(wxLANGUAGE_URDU_PAKISTAN
, "ur_PK", LANG_URDU
, SUBLANG_URDU_PAKISTAN
, wxLayout_LeftToRight
, "Urdu (Pakistan)")
3846 LNG(wxLANGUAGE_UZBEK
, "uz" , LANG_UZBEK
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Uzbek")
3847 LNG(wxLANGUAGE_UZBEK_CYRILLIC
, "uz" , LANG_UZBEK
, SUBLANG_UZBEK_CYRILLIC
, wxLayout_LeftToRight
, "Uzbek (Cyrillic)")
3848 LNG(wxLANGUAGE_UZBEK_LATIN
, "uz" , LANG_UZBEK
, SUBLANG_UZBEK_LATIN
, wxLayout_LeftToRight
, "Uzbek (Latin)")
3849 LNG(wxLANGUAGE_VALENCIAN
, "ca_ES@valencia", 0 , 0 , wxLayout_LeftToRight
, "Valencian (Southern Catalan)")
3850 LNG(wxLANGUAGE_VIETNAMESE
, "vi_VN", LANG_VIETNAMESE
, SUBLANG_DEFAULT
, wxLayout_LeftToRight
, "Vietnamese")
3851 LNG(wxLANGUAGE_VOLAPUK
, "vo" , 0 , 0 , wxLayout_LeftToRight
, "Volapuk")
3852 LNG(wxLANGUAGE_WELSH
, "cy" , 0 , 0 , wxLayout_LeftToRight
, "Welsh")
3853 LNG(wxLANGUAGE_WOLOF
, "wo" , 0 , 0 , wxLayout_LeftToRight
, "Wolof")
3854 LNG(wxLANGUAGE_XHOSA
, "xh" , 0 , 0 , wxLayout_LeftToRight
, "Xhosa")
3855 LNG(wxLANGUAGE_YIDDISH
, "yi" , 0 , 0 , wxLayout_LeftToRight
, "Yiddish")
3856 LNG(wxLANGUAGE_YORUBA
, "yo" , 0 , 0 , wxLayout_LeftToRight
, "Yoruba")
3857 LNG(wxLANGUAGE_ZHUANG
, "za" , 0 , 0 , wxLayout_LeftToRight
, "Zhuang")
3858 LNG(wxLANGUAGE_ZULU
, "zu" , 0 , 0 , wxLayout_LeftToRight
, "Zulu")
3863 // --- --- --- generated code ends here --- --- ---
3865 #endif // wxUSE_INTL