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