add gitignore
[chaz/homebank] / src / language.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2014 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 /* Win32 language lookup table:
21 * Copyright (C) 2007-2008 Dieter Verfaillie <dieterv@optionexplicit.be>
22 */
23
24 #include "homebank.h"
25
26 #include <locale.h>
27 #include <glib.h>
28
29 #ifdef G_OS_WIN32
30 #define WINVER 0x0501
31 #define _WIN32_WINNT 0x0501
32 #define _WIN32_WINDOWS 0x0501
33
34 #include <windows.h>
35 #include <winnls.h>
36 #endif
37
38 #include "language.h"
39
40
41 void
42 language_init (const gchar *language)
43 {
44 #ifdef G_OS_WIN32
45 if (! language)
46 {
47 /* FIXME: This is a hack. gettext doesn't pick the right language
48 * by default on Windows, so we enforce the right one. The
49 * following code is an adaptation of Python code from
50 * pynicotine. For reasons why this approach is needed, and why
51 * the GetLocaleInfo() approach in other libs falls flat, see:
52 * http://blogs.msdn.com/b/michkap/archive/2007/04/15/2146890.aspx
53 */
54
55 switch (GetUserDefaultUILanguage())
56 {
57 case 1078:
58 language = "af"; /* Afrikaans - South Africa */
59 break;
60 case 1052:
61 language = "sq"; /* Albanian - Albania */
62 break;
63 case 1118:
64 language = "am"; /* Amharic - Ethiopia */
65 break;
66 case 1025:
67 language = "ar"; /* Arabic - Saudi Arabia */
68 break;
69 case 5121:
70 language = "ar"; /* Arabic - Algeria */
71 break;
72 case 15361:
73 language = "ar"; /* Arabic - Bahrain */
74 break;
75 case 3073:
76 language = "ar"; /* Arabic - Egypt */
77 break;
78 case 2049:
79 language = "ar"; /* Arabic - Iraq */
80 break;
81 case 11265:
82 language = "ar"; /* Arabic - Jordan */
83 break;
84 case 13313:
85 language = "ar"; /* Arabic - Kuwait */
86 break;
87 case 12289:
88 language = "ar"; /* Arabic - Lebanon */
89 break;
90 case 4097:
91 language = "ar"; /* Arabic - Libya */
92 break;
93 case 6145:
94 language = "ar"; /* Arabic - Morocco */
95 break;
96 case 8193:
97 language = "ar"; /* Arabic - Oman */
98 break;
99 case 16385:
100 language = "ar"; /* Arabic - Qatar */
101 break;
102 case 10241:
103 language = "ar"; /* Arabic - Syria */
104 break;
105 case 7169:
106 language = "ar"; /* Arabic - Tunisia */
107 break;
108 case 14337:
109 language = "ar"; /* Arabic - U.A.E. */
110 break;
111 case 9217:
112 language = "ar"; /* Arabic - Yemen */
113 break;
114 case 1067:
115 language = "hy"; /* Armenian - Armenia */
116 break;
117 case 1101:
118 language = "as"; /* Assamese */
119 break;
120 case 2092:
121 language = NULL; /* Azeri (Cyrillic) */
122 break;
123 case 1068:
124 language = NULL; /* Azeri (Latin) */
125 break;
126 case 1069:
127 language = "eu"; /* Basque */
128 break;
129 case 1059:
130 language = "be"; /* Belarusian */
131 break;
132 case 1093:
133 language = "bn"; /* Bengali (India) */
134 break;
135 case 2117:
136 language = "bn"; /* Bengali (Bangladesh) */
137 break;
138 case 5146:
139 language = "bs"; /* Bosnian (Bosnia/Herzegovina) */
140 break;
141 case 1026:
142 language = "bg"; /* Bulgarian */
143 break;
144 case 1109:
145 language = "my"; /* Burmese */
146 break;
147 case 1027:
148 language = "ca"; /* Catalan */
149 break;
150 case 1116:
151 language = NULL; /* Cherokee - United States */
152 break;
153 case 2052:
154 language = "zh"; /* Chinese - People"s Republic of China */
155 break;
156 case 4100:
157 language = "zh"; /* Chinese - Singapore */
158 break;
159 case 1028:
160 language = "zh"; /* Chinese - Taiwan */
161 break;
162 case 3076:
163 language = "zh"; /* Chinese - Hong Kong SAR */
164 break;
165 case 5124:
166 language = "zh"; /* Chinese - Macao SAR */
167 break;
168 case 1050:
169 language = "hr"; /* Croatian */
170 break;
171 case 4122:
172 language = "hr"; /* Croatian (Bosnia/Herzegovina) */
173 break;
174 case 1029:
175 language = "cs"; /* Czech */
176 break;
177 case 1030:
178 language = "da"; /* Danish */
179 break;
180 case 1125:
181 language = "dv"; /* Divehi */
182 break;
183 case 1043:
184 language = "nl"; /* Dutch - Netherlands */
185 break;
186 case 2067:
187 language = "nl"; /* Dutch - Belgium */
188 break;
189 case 1126:
190 language = NULL; /* Edo */
191 break;
192 case 1033:
193 language = "en"; /* English - United States */
194 break;
195 case 2057:
196 language = "en"; /* English - United Kingdom */
197 break;
198 case 3081:
199 language = "en"; /* English - Australia */
200 break;
201 case 10249:
202 language = "en"; /* English - Belize */
203 break;
204 case 4105:
205 language = "en"; /* English - Canada */
206 break;
207 case 9225:
208 language = "en"; /* English - Caribbean */
209 break;
210 case 15369:
211 language = "en"; /* English - Hong Kong SAR */
212 break;
213 case 16393:
214 language = "en"; /* English - India */
215 break;
216 case 14345:
217 language = "en"; /* English - Indonesia */
218 break;
219 case 6153:
220 language = "en"; /* English - Ireland */
221 break;
222 case 8201:
223 language = "en"; /* English - Jamaica */
224 break;
225 case 17417:
226 language = "en"; /* English - Malaysia */
227 break;
228 case 5129:
229 language = "en"; /* English - New Zealand */
230 break;
231 case 13321:
232 language = "en"; /* English - Philippines */
233 break;
234 case 18441:
235 language = "en"; /* English - Singapore */
236 break;
237 case 7177:
238 language = "en"; /* English - South Africa */
239 break;
240 case 11273:
241 language = "en"; /* English - Trinidad */
242 break;
243 case 12297:
244 language = "en"; /* English - Zimbabwe */
245 break;
246 case 1061:
247 language = "et"; /* Estonian */
248 break;
249 case 1080:
250 language = "fo"; /* Faroese */
251 break;
252 case 1065:
253 language = NULL; /* Farsi */
254 break;
255 case 1124:
256 language = NULL; /* Filipino */
257 break;
258 case 1035:
259 language = "fi"; /* Finnish */
260 break;
261 case 1036:
262 language = "fr"; /* French - France */
263 break;
264 case 2060:
265 language = "fr"; /* French - Belgium */
266 break;
267 case 11276:
268 language = "fr"; /* French - Cameroon */
269 break;
270 case 3084:
271 language = "fr"; /* French - Canada */
272 break;
273 case 9228:
274 language = "fr"; /* French - Democratic Rep. of Congo */
275 break;
276 case 12300:
277 language = "fr"; /* French - Cote d"Ivoire */
278 break;
279 case 15372:
280 language = "fr"; /* French - Haiti */
281 break;
282 case 5132:
283 language = "fr"; /* French - Luxembourg */
284 break;
285 case 13324:
286 language = "fr"; /* French - Mali */
287 break;
288 case 6156:
289 language = "fr"; /* French - Monaco */
290 break;
291 case 14348:
292 language = "fr"; /* French - Morocco */
293 break;
294 case 58380:
295 language = "fr"; /* French - North Africa */
296 break;
297 case 8204:
298 language = "fr"; /* French - Reunion */
299 break;
300 case 10252:
301 language = "fr"; /* French - Senegal */
302 break;
303 case 4108:
304 language = "fr"; /* French - Switzerland */
305 break;
306 case 7180:
307 language = "fr"; /* French - West Indies */
308 break;
309 case 1122:
310 language = "fy"; /* Frisian - Netherlands */
311 break;
312 case 1127:
313 language = NULL; /* Fulfulde - Nigeria */
314 break;
315 case 1071:
316 language = "mk"; /* FYRO Macedonian */
317 break;
318 case 2108:
319 language = "ga"; /* Gaelic (Ireland) */
320 break;
321 case 1084:
322 language = "gd"; /* Gaelic (Scotland) */
323 break;
324 case 1110:
325 language = "gl"; /* Galician */
326 break;
327 case 1079:
328 language = "ka"; /* Georgian */
329 break;
330 case 1031:
331 language = "de"; /* German - Germany */
332 break;
333 case 3079:
334 language = "de"; /* German - Austria */
335 break;
336 case 5127:
337 language = "de"; /* German - Liechtenstein */
338 break;
339 case 4103:
340 language = "de"; /* German - Luxembourg */
341 break;
342 case 2055:
343 language = "de"; /* German - Switzerland */
344 break;
345 case 1032:
346 language = "el"; /* Greek */
347 break;
348 case 1140:
349 language = "gn"; /* Guarani - Paraguay */
350 break;
351 case 1095:
352 language = "gu"; /* Gujarati */
353 break;
354 case 1128:
355 language = "ha"; /* Hausa - Nigeria */
356 break;
357 case 1141:
358 language = NULL; /* Hawaiian - United States */
359 break;
360 case 1037:
361 language = "he"; /* Hebrew */
362 break;
363 case 1081:
364 language = "hi"; /* Hindi */
365 break;
366 case 1038:
367 language = "hu"; /* Hungarian */
368 break;
369 case 1129:
370 language = NULL; /* Ibibio - Nigeria */
371 break;
372 case 1039:
373 language = "is"; /* Icelandic */
374 break;
375 case 1136:
376 language = "ig"; /* Igbo - Nigeria */
377 break;
378 case 1057:
379 language = "id"; /* Indonesian */
380 break;
381 case 1117:
382 language = "iu"; /* Inuktitut */
383 break;
384 case 1040:
385 language = "it"; /* Italian - Italy */
386 break;
387 case 2064:
388 language = "it"; /* Italian - Switzerland */
389 break;
390 case 1041:
391 language = "ja"; /* Japanese */
392 break;
393 case 1099:
394 language = "kn"; /* Kannada */
395 break;
396 case 1137:
397 language = "kr"; /* Kanuri - Nigeria */
398 break;
399 case 2144:
400 language = "ks"; /* Kashmiri */
401 break;
402 case 1120:
403 language = "ks"; /* Kashmiri (Arabic) */
404 break;
405 case 1087:
406 language = "kk"; /* Kazakh */
407 break;
408 case 1107:
409 language = "km"; /* Khmer */
410 break;
411 case 1111:
412 language = NULL; /* Konkani */
413 break;
414 case 1042:
415 language = "ko"; /* Korean */
416 break;
417 case 1088:
418 language = "ky"; /* Kyrgyz (Cyrillic) */
419 break;
420 case 1108:
421 language = "lo"; /* Lao */
422 break;
423 case 1142:
424 language = "la"; /* Latin */
425 break;
426 case 1062:
427 language = "lv"; /* Latvian */
428 break;
429 case 1063:
430 language = "lt"; /* Lithuanian */
431 break;
432 case 1086:
433 language = "ms"; /* Malay - Malaysia */
434 break;
435 case 2110:
436 language = "ms"; /* Malay - Brunei Darussalam */
437 break;
438 case 1100:
439 language = "ml"; /* Malayalam */
440 break;
441 case 1082:
442 language = "mt"; /* Maltese */
443 break;
444 case 1112:
445 language = NULL; /* Manipuri */
446 break;
447 case 1153:
448 language = "mi"; /* Maori - New Zealand */
449 break;
450 case 1102:
451 language = "mr"; /* Marathi */
452 break;
453 case 1104:
454 language = "mn"; /* Mongolian (Cyrillic) */
455 break;
456 case 2128:
457 language = "mn"; /* Mongolian (Mongolian) */
458 break;
459 case 1121:
460 language = "ne"; /* Nepali */
461 break;
462 case 2145:
463 language = "ne"; /* Nepali - India */
464 break;
465 case 1044:
466 language = "no"; /* Norwegian (Bokmᅢᆬl) */
467 break;
468 case 2068:
469 language = "no"; /* Norwegian (Nynorsk) */
470 break;
471 case 1096:
472 language = "or"; /* Oriya */
473 break;
474 case 1138:
475 language = "om"; /* Oromo */
476 break;
477 case 1145:
478 language = NULL; /* Papiamentu */
479 break;
480 case 1123:
481 language = "ps"; /* Pashto */
482 break;
483 case 1045:
484 language = "pl"; /* Polish */
485 break;
486 case 1046:
487 language = "pt"; /* Portuguese - Brazil */
488 break;
489 case 2070:
490 language = "pt"; /* Portuguese - Portugal */
491 break;
492 case 1094:
493 language = "pa"; /* Punjabi */
494 break;
495 case 2118:
496 language = "pa"; /* Punjabi (Pakistan) */
497 break;
498 case 1131:
499 language = "qu"; /* Quecha - Bolivia */
500 break;
501 case 2155:
502 language = "qu"; /* Quecha - Ecuador */
503 break;
504 case 3179:
505 language = "qu"; /* Quecha - Peru */
506 break;
507 case 1047:
508 language = "rm"; /* Rhaeto-Romanic */
509 break;
510 case 1048:
511 language = "ro"; /* Romanian */
512 break;
513 case 2072:
514 language = "ro"; /* Romanian - Moldava */
515 break;
516 case 1049:
517 language = "ru"; /* Russian */
518 break;
519 case 2073:
520 language = "ru"; /* Russian - Moldava */
521 break;
522 case 1083:
523 language = NULL; /* Sami (Lappish) */
524 break;
525 case 1103:
526 language = "sa"; /* Sanskrit */
527 break;
528 case 1132:
529 language = NULL; /* Sepedi */
530 break;
531 case 3098:
532 language = "sr"; /* Serbian (Cyrillic) */
533 break;
534 case 2074:
535 language = "sr"; /* Serbian (Latin) */
536 break;
537 case 1113:
538 language = "sd"; /* Sindhi - India */
539 break;
540 case 2137:
541 language = "sd"; /* Sindhi - Pakistan */
542 break;
543 case 1115:
544 language = "si"; /* Sinhalese - Sri Lanka */
545 break;
546 case 1051:
547 language = "sk"; /* Slovak */
548 break;
549 case 1060:
550 language = "sl"; /* Slovenian */
551 break;
552 case 1143:
553 language = "so"; /* Somali */
554 break;
555 case 1070:
556 language = NULL; /* Sorbian */
557 break;
558 case 3082:
559 language = "es"; /* Spanish - Spain (Modern Sort) */
560 break;
561 case 1034:
562 language = "es"; /* Spanish - Spain (Traditional Sort) */
563 break;
564 case 11274:
565 language = "es"; /* Spanish - Argentina */
566 break;
567 case 16394:
568 language = "es"; /* Spanish - Bolivia */
569 break;
570 case 13322:
571 language = "es"; /* Spanish - Chile */
572 break;
573 case 9226:
574 language = "es"; /* Spanish - Colombia */
575 break;
576 case 5130:
577 language = "es"; /* Spanish - Costa Rica */
578 break;
579 case 7178:
580 language = "es"; /* Spanish - Dominican Republic */
581 break;
582 case 12298:
583 language = "es"; /* Spanish - Ecuador */
584 break;
585 case 17418:
586 language = "es"; /* Spanish - El Salvador */
587 break;
588 case 4106:
589 language = "es"; /* Spanish - Guatemala */
590 break;
591 case 18442:
592 language = "es"; /* Spanish - Honduras */
593 break;
594 case 58378:
595 language = "es"; /* Spanish - Latin America */
596 break;
597 case 2058:
598 language = "es"; /* Spanish - Mexico */
599 break;
600 case 19466:
601 language = "es"; /* Spanish - Nicaragua */
602 break;
603 case 6154:
604 language = "es"; /* Spanish - Panama */
605 break;
606 case 15370:
607 language = "es"; /* Spanish - Paraguay */
608 break;
609 case 10250:
610 language = "es"; /* Spanish - Peru */
611 break;
612 case 20490:
613 language = "es"; /* Spanish - Puerto Rico */
614 break;
615 case 21514:
616 language = "es"; /* Spanish - United States */
617 break;
618 case 14346:
619 language = "es"; /* Spanish - Uruguay */
620 break;
621 case 8202:
622 language = "es"; /* Spanish - Venezuela */
623 break;
624 case 1072:
625 language = NULL; /* Sutu */
626 break;
627 case 1089:
628 language = "sw"; /* Swahili */
629 break;
630 case 1053:
631 language = "sv"; /* Swedish */
632 break;
633 case 2077:
634 language = "sv"; /* Swedish - Finland */
635 break;
636 case 1114:
637 language = NULL; /* Syriac */
638 break;
639 case 1064:
640 language = "tg"; /* Tajik */
641 break;
642 case 1119:
643 language = NULL; /* Tamazight (Arabic) */
644 break;
645 case 2143:
646 language = NULL; /* Tamazight (Latin) */
647 break;
648 case 1097:
649 language = "ta"; /* Tamil */
650 break;
651 case 1092:
652 language = "tt"; /* Tatar */
653 break;
654 case 1098:
655 language = "te"; /* Telugu */
656 break;
657 case 1054:
658 language = "th"; /* Thai */
659 break;
660 case 2129:
661 language = "bo"; /* Tibetan - Bhutan */
662 break;
663 case 1105:
664 language = "bo"; /* Tibetan - People"s Republic of China */
665 break;
666 case 2163:
667 language = "ti"; /* Tigrigna - Eritrea */
668 break;
669 case 1139:
670 language = "ti"; /* Tigrigna - Ethiopia */
671 break;
672 case 1073:
673 language = "ts"; /* Tsonga */
674 break;
675 case 1074:
676 language = "tn"; /* Tswana */
677 break;
678 case 1055:
679 language = "tr"; /* Turkish */
680 break;
681 case 1090:
682 language = "tk"; /* Turkmen */
683 break;
684 case 1152:
685 language = "ug"; /* Uighur - China */
686 break;
687 case 1058:
688 language = "uk"; /* Ukrainian */
689 break;
690 case 1056:
691 language = "ur"; /* Urdu */
692 break;
693 case 2080:
694 language = "ur"; /* Urdu - India */
695 break;
696 case 2115:
697 language = "uz"; /* Uzbek (Cyrillic) */
698 break;
699 case 1091:
700 language = "uz"; /* Uzbek (Latin) */
701 break;
702 case 1075:
703 language = "ve"; /* Venda */
704 break;
705 case 1066:
706 language = "vi"; /* Vietnamese */
707 break;
708 case 1106:
709 language = "cy"; /* Welsh */
710 break;
711 case 1076:
712 language = "xh"; /* Xhosa */
713 break;
714 case 1144:
715 language = NULL; /* Yi */
716 break;
717 case 1085:
718 language = "yi"; /* Yiddish */
719 break;
720 case 1130:
721 language = "yo"; /* Yoruba */
722 break;
723 case 1077:
724 language = "zu"; /* Zulu */
725 break;
726 default:
727 language = NULL;
728 }
729 }
730 #endif
731
732 /* We already set the locale according to the environment, so just
733 * return early if no language is set in gimprc.
734 */
735 if (! language)
736 return;
737
738 g_setenv ("LANGUAGE", language, TRUE);
739 setlocale (LC_ALL, "");
740 }
This page took 0.07779 seconds and 4 git commands to generate.