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