1 /************************************************************************/
2 /* */
3 /* Translation back and forth between windows language code and LANG */
4 /* */
5 /************************************************************************/
6
7 # include "appUtilConfig.h"
8 # include <string.h>
9
10 # include "utilWindowsLanguageCode.h"
11
12 # define GENERATE 0
13
14 typedef struct LanguageCode
15 {
16 int lcCode;
17 const char * lcLang;
18
19 int lcCodeIndex;
20 # if GENERATE
21 int lcSource;
22 # endif
23 } LanguageCode;
24
25 /************************************************************************/
26 /* */
27 /* Language Codes sorted by string. */
28 /* */
29 /* The lcCodeIndex field is an inverse sort index for the Code value */
30 /* */
31 /************************************************************************/
32
33 # if GENERATE
34 static LanguageCode LanguageCodes[]=
35 # else
36 static const LanguageCode LanguageCodes[]=
37 # endif
38 {
39 { 54, "af", 4 }, /* 0x0036 */
40 { 1078, "af-ZA", 34 }, /* 0x0436 */
41 { 94, "am", 50 }, /* 0x005e */
42 { 1118, "am-ET", 384 }, /* 0x045e */
43 { 1, "ar", 55 }, /* 0x0001 */
44 { 14337, "ar-AE", 59 }, /* 0x3801 */
45 { 15361, "ar-BH", 61 }, /* 0x3c01 */
46 { 5121, "ar-DZ", 71 }, /* 0x1401 */
47 { 3073, "ar-EG", 73 }, /* 0x0c01 */
48 { 2049, "ar-IQ", 92 }, /* 0x0801 */
49 { 11265, "ar-JO", 120 }, /* 0x2c01 */
50 { 13313, "ar-KW", 126 }, /* 0x3401 */
51 { 12289, "ar-LB", 161 }, /* 0x3001 */
52 { 4097, "ar-LY", 169 }, /* 0x1001 */
53 { 6145, "ar-MA", 180 }, /* 0x1801 */
54 { 8193, "ar-OM", 182 }, /* 0x2001 */
55 { 16385, "ar-QA", 190 }, /* 0x4001 */
56 { 1025, "ar-SA", 202 }, /* 0x0401 */
57 { 10241, "ar-SY", 244 }, /* 0x2801 */
58 { 7169, "ar-TN", 249 }, /* 0x1c01 */
59 { 9217, "ar-YE", 260 }, /* 0x2401 */
60 { 122, "arn", 267 }, /* 0x007a */
61 { 1146, "arn-CL", 276 }, /* 0x047a */
62 { 77, "as", 278 }, /* 0x004d */
63 { 1101, "as-IN", 281 }, /* 0x044d */
64 { 44, "az", 165 }, /* 0x002c */
65 { 29740, "az-Cyrl", 298 }, /* 0x742c */
66 { 2092, "az-Cyrl-AZ", 313 }, /* 0x082c */
67 { 30764, "az-Latn", 327 }, /* 0x782c */
68 { 1068, "az-Latn-AZ", 341 }, /* 0x042c */
69 { 109, "ba", 351 }, /* 0x006d */
70 { 1133, "ba-RU", 363 }, /* 0x046d */
71 { 35, "be", 174 }, /* 0x0023 */
72 { 1059, "be-BY", 361 }, /* 0x0423 */
73 { 2, "bg", 32 }, /* 0x0002 */
74 { 1026, "bg-BG", 300 }, /* 0x0402 */
75 { 1126, "bin-NG", 114 }, /* 0x0466 */
76 { 69, "bn", 215 }, /* 0x0045 */
77 { 2117, "bn-BD", 213 }, /* 0x0845 */
78 { 1093, "bn-IN", 338 }, /* 0x0445 */
79 { 81, "bo", 118 }, /* 0x0051 */
80 { 2129, "bo-BT", 372 }, /* 0x0851 */
81 { 1105, "bo-CN", 171 }, /* 0x0451 */
82 { 126, "br", 25 }, /* 0x007e */
83 { 1150, "br-FR", 116 }, /* 0x047e */
84 { 30746, "bs", 168 }, /* 0x781a */
85 { 25626, "bs-Cyrl", 219 }, /* 0x641a */
86 { 8218, "bs-Cyrl-BA", 349 }, /* 0x201a */
87 { 26650, "bs-Latn", 377 }, /* 0x681a */
88 { 5146, "bs-Latn-BA", 389 }, /* 0x141a */
89 { 3, "ca", 0 }, /* 0x0003 */
90 { 1027, "ca-ES", 192 }, /* 0x0403 */
91 { 1116, "chr-US", 124 }, /* 0x045c */
92 { 131, "co", 163 }, /* 0x0083 */
93 { 1155, "co-FR", 236 }, /* 0x0483 */
94 { 5, "cs", 292 }, /* 0x0005 */
95 { 1029, "cs-CZ", 145 }, /* 0x0405 */
96 { 82, "cy", 233 }, /* 0x0052 */
97 { 1106, "cy-GB", 194 }, /* 0x0452 */
98 { 6, "da", 207 }, /* 0x0006 */
99 { 1030, "da-DK", 330 }, /* 0x0406 */
100 { 7, "de", 345 }, /* 0x0007 */
101 { 3079, "de-AT", 366 }, /* 0x0c07 */
102 { 2055, "de-CH", 354 }, /* 0x0807 */
103 { 1031, "de-DE", 37 }, /* 0x0407 */
104 { 5127, "de-LI", 256 }, /* 0x1407 */
105 { 4103, "de-LU", 155 }, /* 0x1007 */
106 { 31790, "dsb", 254 }, /* 0x7c2e */
107 { 2094, "dsb-DE", 334 }, /* 0x082e */
108 { 101, "dv", 336 }, /* 0x0065 */
109 { 1125, "dv-MV", 200 }, /* 0x0465 */
110 { 8, "el", 221 }, /* 0x0008 */
111 { 1032, "el-GR", 23 }, /* 0x0408 */
112 { 9, "en", 231 }, /* 0x0009 */
113 { 3081, "en-AU", 286 }, /* 0x0c09 */
114 { 10249, "en-BZ", 223 }, /* 0x2809 */
115 { 4105, "en-CA", 40 }, /* 0x1009 */
116 { 9225, "en-CB", 57 }, /* 0x2409 */
117 { 2057, "en-GB", 198 }, /* 0x0809 */
118 { 15369, "en-HK", 211 }, /* 0x3c09 */
119 { 14345, "en-ID", 150 }, /* 0x3809 */
120 { 6153, "en-IE", 204 }, /* 0x1809 */
121 { 16393, "en-IN", 332 }, /* 0x4009 */
122 { 8201, "en-JM", 296 }, /* 0x2009 */
123 { 17417, "en-MY", 185 }, /* 0x4409 */
124 { 5129, "en-NZ", 2 }, /* 0x1409 */
125 { 13321, "en-PH", 356 }, /* 0x3409 */
126 { 18441, "en-SG", 241 }, /* 0x4809 */
127 { 11273, "en-TT", 143 }, /* 0x2c09 */
128 { 1033, "en-US", 265 }, /* 0x0409 */
129 { 7177, "en-ZA", 122 }, /* 0x1c09 */
130 { 12297, "en-ZW", 69 }, /* 0x3009 */
131 { 10, "es", 157 }, /* 0x000a */
132 { 11274, "es-AR", 379 }, /* 0x2c0a */
133 { 16394, "es-BO", 272 }, /* 0x400a */
134 { 13322, "es-CL", 250 }, /* 0x340a */
135 { 9226, "es-CO", 30 }, /* 0x240a */
136 { 5130, "es-CR", 209 }, /* 0x140a */
137 { 7178, "es-DO", 196 }, /* 0x1c0a */
138 { 12298, "es-EC", 176 }, /* 0x300a */
139 { 3082, "es-ES", 178 }, /* 0x0c0a */
140 { 1034, "es-ES_tradnl", 21 }, /* 0x040a */
141 { 4106, "es-GT", 229 }, /* 0x100a */
142 { 18442, "es-HN", 43 }, /* 0x480a */
143 { 2058, "es-MX", 359 }, /* 0x080a */
144 { 19466, "es-NI", 217 }, /* 0x4c0a */
145 { 6154, "es-PA", 252 }, /* 0x180a */
146 { 10250, "es-PE", 53 }, /* 0x280a */
147 { 20490, "es-PR", 153 }, /* 0x500a */
148 { 15370, "es-PY", 288 }, /* 0x3c0a */
149 { 17418, "es-SV", 270 }, /* 0x440a */
150 { 21514, "es-US", 284 }, /* 0x540a */
151 { 14346, "es-UY", 375 }, /* 0x380a */
152 { 8202, "es-VE", 263 }, /* 0x200a */
153 { 37, "et", 148 }, /* 0x0025 */
154 { 1061, "et-EE", 17 }, /* 0x0425 */
155 { 45, "eu", 35 }, /* 0x002d */
156 { 1069, "eu-ES", 51 }, /* 0x042d */
157 { 41, "fa", 388 }, /* 0x0029 */
158 { 1065, "fa-IR", 56 }, /* 0x0429 */
159 { 11, "fi", 60 }, /* 0x000b */
160 { 1035, "fi-FI", 64 }, /* 0x040b */
161 { 100, "fil", 72 }, /* 0x0064 */
162 { 1124, "fil-PH", 89 }, /* 0x0464 */
163 { 56, "fo", 101 }, /* 0x0038 */
164 { 1080, "fo-FO", 121 }, /* 0x0438 */
165 { 12, "fr", 133 }, /* 0x000c */
166 { 2060, "fr-BE", 162 }, /* 0x080c */
167 { 3084, "fr-CA", 170 }, /* 0x0c0c */
168 { 9228, "fr-CG", 181 }, /* 0x240c */
169 { 4108, "fr-CH", 184 }, /* 0x100c */
170 { 12300, "fr-CI", 191 }, /* 0x300c */
171 { 11276, "fr-CM", 203 }, /* 0x2c0c */
172 { 1036, "fr-FR", 246 }, /* 0x040c */
173 { 15372, "fr-HT", 240 }, /* 0x3c0c */
174 { 5132, "fr-LU", 261 }, /* 0x140c */
175 { 14348, "fr-MA", 268 }, /* 0x380c */
176 { 6156, "fr-MC", 277 }, /* 0x180c */
177 { 13324, "fr-ML", 280 }, /* 0x340c */
178 { 8204, "fr-RE", 283 }, /* 0x200c */
179 { 10252, "fr-SN", 167 }, /* 0x280c */
180 { 7180, "fr-West Indies", 299 }, /* 0x1c0c */
181 { 1127, "fuv-NG", 314 }, /* 0x0467 */
182 { 98, "fy", 329 }, /* 0x0062 */
183 { 1122, "fy-NL", 342 }, /* 0x0462 */
184 { 60, "ga", 352 }, /* 0x003c */
185 { 2108, "ga-IE", 365 }, /* 0x083c */
186 { 1138, "gaz-ET", 175 }, /* 0x0472 */
187 { 145, "gd", 362 }, /* 0x0091 */
188 { 1169, "gd-GB", 33 }, /* 0x0491 */
189 { 86, "gl", 301 }, /* 0x0056 */
190 { 1110, "gl-ES", 115 }, /* 0x0456 */
191 { 1140, "gn-PY", 216 }, /* 0x0474 */
192 { 132, "gsw", 214 }, /* 0x0084 */
193 { 1156, "gsw-FR", 340 }, /* 0x0484 */
194 { 71, "gu", 119 }, /* 0x0047 */
195 { 1095, "gu-IN", 373 }, /* 0x0447 */
196 { 104, "ha", 172 }, /* 0x0068 */
197 { 31848, "ha-Latn", 29 }, /* 0x7c68 */
198 { 1128, "ha-Latn-NG", 117 }, /* 0x0468 */
199 { 1141, "haw-US", 374 }, /* 0x0475 */
200 { 13, "he", 220 }, /* 0x000d */
201 { 1037, "he-IL", 326 }, /* 0x040d */
202 { 57, "hi", 353 }, /* 0x0039 */
203 { 1081, "hi-IN", 350 }, /* 0x0439 */
204 { 26, "hr", 371 }, /* 0x001a */
205 { 4122, "hr-BA", 378 }, /* 0x101a */
206 { 1050, "hr-HR", 390 }, /* 0x041a */
207 { 46, "hsb", 1 }, /* 0x002e */
208 { 14, "hu", 193 }, /* 0x000e */
209 { 1038, "hu-HU", 125 }, /* 0x040e */
210 { 43, "hy", 164 }, /* 0x002b */
211 { 1067, "hy-AM", 237 }, /* 0x042b */
212 { 1129, "ibb-NG", 294 }, /* 0x0469 */
213 { 33, "id", 235 }, /* 0x0021 */
214 { 1057, "id-ID", 195 }, /* 0x0421 */
215 { 112, "ig", 208 }, /* 0x0070 */
216 { 1136, "ig-NG", 331 }, /* 0x0470 */
217 { 120, "ii", 346 }, /* 0x0078 */
218 { 1144, "ii-CN", 370 }, /* 0x0478 */
219 { 15, "is", 355 }, /* 0x000f */
220 { 1039, "is-IS", 39 }, /* 0x040f */
221 { 16, "it", 257 }, /* 0x0010 */
222 { 2064, "it-CH", 156 }, /* 0x0810 */
223 { 1040, "it-IT", 255 }, /* 0x0410 */
224 { 93, "iu", 335 }, /* 0x005d */
225 { 30813, "iu-Cans", 337 }, /* 0x785d */
226 { 1117, "iu-Cans-CA", 201 }, /* 0x045d */
227 { 31837, "iu-Latn", 222 }, /* 0x7c5d */
228 { 2141, "iu-Latn-CA", 24 }, /* 0x085d */
229 { 17, "ja", 232 }, /* 0x0011 */
230 { 1041, "ja-JP", 287 }, /* 0x0411 */
231 { 55, "ka", 225 }, /* 0x0037 */
232 { 1079, "ka-GE", 42 }, /* 0x0437 */
233 { 63, "kk", 58 }, /* 0x003f */
234 { 1087, "kk-KZ", 199 }, /* 0x043f */
235 { 111, "kl", 212 }, /* 0x006f */
236 { 1135, "kl-GL", 238 }, /* 0x046f */
237 { 83, "km", 151 }, /* 0x0053 */
238 { 1107, "km-KH", 205 }, /* 0x0453 */
239 { 75, "kn", 228 }, /* 0x004b */
240 { 1099, "kn-IN", 290 }, /* 0x044b */
241 { 18, "ko", 333 }, /* 0x0012 */
242 { 1042, "ko-KR", 297 }, /* 0x0412 */
243 { 87, "kok", 52 }, /* 0x0057 */
244 { 1111, "kok-IN", 187 }, /* 0x0457 */
245 { 1137, "kr-NG", 3 }, /* 0x0471 */
246 { 64, "ky", 347 }, /* 0x0040 */
247 { 1088, "ky-KG", 243 }, /* 0x0440 */
248 { 110, "lb", 144 }, /* 0x006e */
249 { 1134, "lb-LU", 266 }, /* 0x046e */
250 { 84, "lo", 123 }, /* 0x0054 */
251 { 1108, "lo-LA", 70 }, /* 0x0454 */
252 { 39, "lt", 36 }, /* 0x0027 */
253 { 1063, "lt-LT", 142 }, /* 0x0427 */
254 { 38, "lv", 159 }, /* 0x0026 */
255 { 1062, "lv-LV", 173 }, /* 0x0426 */
256 { 129, "mi", 380 }, /* 0x0081 */
257 { 1153, "mi-NZ", 273 }, /* 0x0481 */
258 { 47, "mk", 251 }, /* 0x002f */
259 { 1071, "mk-MK", 31 }, /* 0x042f */
260 { 76, "ml", 210 }, /* 0x004c */
261 { 1100, "ml-IN", 197 }, /* 0x044c */
262 { 80, "mn", 177 }, /* 0x0050 */
263 { 30800, "mn-Cyrl", 206 }, /* 0x7850 */
264 { 1104, "mn-MN", 147 }, /* 0x0450 */
265 { 31824, "mn-Mong", 343 }, /* 0x7c50 */
266 { 2128, "mn-Mong-CN", 152 }, /* 0x0850 */
267 { 1112, "mni", 160 }, /* 0x0458 */
268 { 124, "moh", 312 }, /* 0x007c */
269 { 1148, "moh-CA", 179 }, /* 0x047c */
270 { 78, "mr", 259 }, /* 0x004e */
271 { 1102, "mr-IN", 22 }, /* 0x044e */
272 { 62, "ms", 230 }, /* 0x003e */
273 { 2110, "ms-BN", 44 }, /* 0x083e */
274 { 1086, "ms-MY", 360 }, /* 0x043e */
275 { 58, "mt", 218 }, /* 0x003a */
276 { 1082, "mt-MT", 253 }, /* 0x043a */
277 { 1109, "my-MM", 54 }, /* 0x0455 */
278 { 31764, "nb", 154 }, /* 0x7c14 */
279 { 1044, "nb-NO", 289 }, /* 0x0414 */
280 { 97, "ne", 271 }, /* 0x0061 */
281 { 2145, "ne-IN", 285 }, /* 0x0861 */
282 { 1121, "ne-NP", 376 }, /* 0x0461 */
283 { 19, "nl", 264 }, /* 0x0013 */
284 { 2067, "nl-BE", 262 }, /* 0x0813 */
285 { 1043, "nl-NL", 149 }, /* 0x0413 */
286 { 30740, "nn", 9 }, /* 0x7814 */
287 { 2068, "nn-NO", 382 }, /* 0x0814 */
288 { 20, "no", 63 }, /* 0x0014 */
289 { 108, "nso", 78 }, /* 0x006c */
290 { 1132, "nso-ZA", 104 }, /* 0x046c */
291 { 130, "oc", 127 }, /* 0x0082 */
292 { 1154, "oc-FR", 183 }, /* 0x0482 */
293 { 72, "or", 245 }, /* 0x0048 */
294 { 1096, "or-IN", 248 }, /* 0x0448 */
295 { 70, "pa", 269 }, /* 0x0046 */
296 { 1094, "pa-IN", 279 }, /* 0x0446 */
297 { 2118, "pa-PK", 282 }, /* 0x0846 */
298 { 1145, "pap-AN", 323 }, /* 0x0479 */
299 { 21, "pl", 328 }, /* 0x0015 */
300 { 1045, "pl-PL", 364 }, /* 0x0415 */
301 { 1165, "plt-MG", 27 }, /* 0x048d */
302 { 140, "prs", 68 }, /* 0x008c */
303 { 1164, "prs-AF", 295 }, /* 0x048c */
304 { 99, "ps", 146 }, /* 0x0063 */
305 { 1123, "ps-AF", 234 }, /* 0x0463 */
306 { 22, "pt", 368 }, /* 0x0016 */
307 { 1046, "pt-BR", 38 }, /* 0x0416 */
308 { 2070, "pt-PT", 258 }, /* 0x0816 */
309 { 134, "qut", 227 }, /* 0x0086 */
310 { 1158, "qut-GT", 41 }, /* 0x0486 */
311 { 107, "quz", 291 }, /* 0x006b */
312 { 1131, "quz-BO", 189 }, /* 0x046b */
313 { 2155, "quz-EC", 358 }, /* 0x086b */
314 { 3179, "quz-PE", 242 }, /* 0x0c6b */
315 { 23, "rm", 274 }, /* 0x0017 */
316 { 1047, "rm-CH", 344 }, /* 0x0417 */
317 { 24, "ro", 8 }, /* 0x0018 */
318 { 2072, "ro-MO", 383 }, /* 0x0818 */
319 { 1048, "ro-RO", 62 }, /* 0x0418 */
320 { 25, "ru", 74 }, /* 0x0019 */
321 { 2073, "ru-MO", 100 }, /* 0x0819 */
322 { 1049, "ru-RU", 128 }, /* 0x0419 */
323 { 135, "rw", 318 }, /* 0x0087 */
324 { 1159, "rw-RW", 293 }, /* 0x0487 */
325 { 79, "sa", 348 }, /* 0x004f */
326 { 1103, "sa-IN", 275 }, /* 0x044f */
327 { 133, "sah", 13 }, /* 0x0085 */
328 { 1157, "sah-RU", 387 }, /* 0x0485 */
329 { 1113, "sd-IN", 66 }, /* 0x0459 */
330 { 2137, "sd-PK", 76 }, /* 0x0859 */
331 { 59, "se", 102 }, /* 0x003b */
332 { 3131, "se-FI", 130 }, /* 0x0c3b */
333 { 1083, "se-NO", 166 }, /* 0x043b */
334 { 2107, "se-SE", 306 }, /* 0x083b */
335 { 91, "si", 7 }, /* 0x005b */
336 { 1115, "si-LK", 386 }, /* 0x045b */
337 { 27, "sk", 65 }, /* 0x001b */
338 { 1051, "sk-SK", 85 }, /* 0x041b */
339 { 36, "sl", 97 }, /* 0x0024 */
340 { 1060, "sl-SI", 135 }, /* 0x0424 */
341 { 30779, "sma", 49 }, /* 0x783b */
342 { 6203, "sma-NO", 307 }, /* 0x183b */
343 { 7227, "sma-SE", 14 }, /* 0x1c3b */
344 { 31803, "smj", 81 }, /* 0x7c3b */
345 { 4155, "smj-NO", 106 }, /* 0x103b */
346 { 5179, "smj-SE", 137 }, /* 0x143b */
347 { 28731, "smn", 322 }, /* 0x703b */
348 { 9275, "smn-FI", 303 }, /* 0x243b */
349 { 29755, "sms", 19 }, /* 0x743b */
350 { 8251, "sms-FI", 90 }, /* 0x203b */
351 { 1143, "so-SO", 98 }, /* 0x0477 */
352 { 28, "sq", 141 }, /* 0x001c */
353 { 1052, "sq-AL", 317 }, /* 0x041c */
354 { 31770, "sr", 304 }, /* 0x7c1a */
355 { 27674, "sr-Cyrl", 15 }, /* 0x6c1a */
356 { 7194, "sr-Cyrl-BA", 83 }, /* 0x1c1a */
357 { 3098, "sr-Cyrl-CS", 113 }, /* 0x0c1a */
358 { 12314, "sr-Cyrl-ME", 139 }, /* 0x301a */
359 { 10266, "sr-Cyrl-RS", 47 }, /* 0x281a */
360 { 28698, "sr-Latn", 311 }, /* 0x701a */
361 { 6170, "sr-Latn-BA", 20 }, /* 0x181a */
362 { 2074, "sr-Latn-CS", 77 }, /* 0x081a */
363 { 11290, "sr-Latn-ME", 96 }, /* 0x2c1a */
364 { 9242, "sr-Latn-RS", 129 }, /* 0x241a */
365 { 1072, "st-ZA", 325 }, /* 0x0430 */
366 { 29, "sv", 309 }, /* 0x001d */
367 { 2077, "sv-FI", 18 }, /* 0x081d */
368 { 1053, "sv-SE", 75 }, /* 0x041d */
369 { 65, "sw", 107 }, /* 0x0041 */
370 { 1089, "sw-KE", 140 }, /* 0x0441 */
371 { 90, "syr", 320 }, /* 0x005a */
372 { 1114, "syr-SY", 10 }, /* 0x045a */
373 { 73, "ta", 88 }, /* 0x0049 */
374 { 1097, "ta-IN", 93 }, /* 0x0449 */
375 { 74, "te", 132 }, /* 0x004a */
376 { 1098, "te-IN", 324 }, /* 0x044a */
377 { 40, "tg", 12 }, /* 0x0028 */
378 { 31784, "tg-Cyrl", 91 }, /* 0x7c28 */
379 { 1064, "tg-Cyrl-TJ", 99 }, /* 0x0428 */
380 { 30, "th", 131 }, /* 0x001e */
381 { 1054, "th-TH", 319 }, /* 0x041e */
382 { 1139, "ti-ER", 11 }, /* 0x0473 */
383 { 2163, "ti-ET", 86 }, /* 0x0873 */
384 { 66, "tk", 95 }, /* 0x0042 */
385 { 1090, "tk-TM", 138 }, /* 0x0442 */
386 { 1119, "tmz", 5 }, /* 0x045f */
387 { 3167, "tmz-MA", 80 }, /* 0x0c5f */
388 { 50, "tn", 112 }, /* 0x0032 */
389 { 1074, "tn-ZA", 136 }, /* 0x0432 */
390 { 31, "tr", 6 }, /* 0x001f */
391 { 1055, "tr-TR", 79 }, /* 0x041f */
392 { 1073, "ts-ZA", 109 }, /* 0x0431 */
393 { 68, "tt", 134 }, /* 0x0044 */
394 { 1092, "tt-RU", 16 }, /* 0x0444 */
395 { 95, "tzm", 82 }, /* 0x005f */
396 { 31839, "tzm-Latn", 94 }, /* 0x7c5f */
397 { 2143, "tzm-Latn-DZ", 84 }, /* 0x085f */
398 { 128, "ug", 110 }, /* 0x0080 */
399 { 1152, "ug-CN", 87 }, /* 0x0480 */
400 { 34, "uk", 103 }, /* 0x0022 */
401 { 1058, "uk-UA", 105 }, /* 0x0422 */
402 { 32, "ur", 108 }, /* 0x0020 */
403 { 2080, "ur-IN", 111 }, /* 0x0820 */
404 { 1056, "ur-PK", 46 }, /* 0x0420 */
405 { 67, "uz", 48 }, /* 0x0043 */
406 { 30787, "uz-Cyrl", 316 }, /* 0x7843 */
407 { 2115, "uz-Cyrl-UZ", 321 }, /* 0x0843 */
408 { 31811, "uz-Latn", 308 }, /* 0x7c43 */
409 { 1091, "uz-Latn-UZ", 26 }, /* 0x0443 */
410 { 1075, "ven-ZA", 310 }, /* 0x0433 */
411 { 42, "vi", 381 }, /* 0x002a */
412 { 1066, "vi-VN", 247 }, /* 0x042a */
413 { 1070, "wen-DE", 45 }, /* 0x042e */
414 { 136, "wo", 28 }, /* 0x0088 */
415 { 1160, "wo-SN", 302 }, /* 0x0488 */
416 { 52, "xh", 367 }, /* 0x0034 */
417 { 1076, "xh-ZA", 224 }, /* 0x0434 */
418 { 106, "yo", 186 }, /* 0x006a */
419 { 1130, "yo-NG", 385 }, /* 0x046a */
420 { 30724, "zh", 239 }, /* 0x7804 */
421 { 2052, "zh-CN", 315 }, /* 0x0804 */
422 { 3076, "zh-HK", 339 }, /* 0x0c04 */
423 { 4, "zh-Hans", 67 }, /* 0x0004 */
424 { 31748, "zh-Hant", 305 }, /* 0x7c04 */
425 { 5124, "zh-MO", 369 }, /* 0x1404 */
426 { 4100, "zh-SG", 226 }, /* 0x1004 */
427 { 1028, "zh-TW", 188 }, /* 0x0404 */
428 { 53, "zu", 357 }, /* 0x0035 */
429 { 1077, "zu-ZA", 158 }, /* 0x0435 */
430 };
431
432 static const int LanguageCodeCount= sizeof(LanguageCodes)/sizeof(LanguageCode);
433
utilLangForLanguageCode(int code)434 const char * utilLangForLanguageCode( int code )
435 {
436 int l= 0, r= LanguageCodeCount, m= ( l+ r )/ 2;
437
438 while( l < m )
439 {
440 if ( LanguageCodes[LanguageCodes[m].lcCodeIndex].lcCode <= code )
441 { l= m; }
442 else{ r= m; }
443
444 m= ( l+ r )/ 2;
445 }
446
447 if ( code != LanguageCodes[LanguageCodes[m].lcCodeIndex].lcCode )
448 { return (const char *)0; }
449 else{ return LanguageCodes[LanguageCodes[m].lcCodeIndex].lcLang; }
450 }
451
utilLanguageCodeForLang(const char * lang)452 int utilLanguageCodeForLang( const char * lang )
453 {
454 int l= 0, r= LanguageCodeCount, m= ( l+ r )/ 2;
455
456 while( l < m )
457 {
458 if ( strcmp( LanguageCodes[m].lcLang, lang ) <= 0 )
459 { l= m; }
460 else{ r= m; }
461
462 m= ( l+ r )/ 2;
463 }
464
465 if ( strcmp( lang, LanguageCodes[m].lcLang ) != 0 )
466 { return -1; }
467 else{ return LanguageCodes[m].lcCode; }
468 }
469
470 # if GENERATE
471
utilCompareLanguageCodesByNumber(const void * v1,const void * v2)472 static int utilCompareLanguageCodesByNumber( const void * v1,
473 const void * v2 )
474 {
475 const LanguageCode * lc1= (const LanguageCode *)v1;
476 const LanguageCode * lc2= (const LanguageCode *)v2;
477
478 return lc1->lcCode- lc2->lcCode;
479 }
480
utilCompareLanguageCodesByString(const void * v1,const void * v2)481 static int utilCompareLanguageCodesByString( const void * v1,
482 const void * v2 )
483 {
484 const LanguageCode * lc1= (const LanguageCode *)v1;
485 const LanguageCode * lc2= (const LanguageCode *)v2;
486
487 return strcmp( lc1->lcLang, lc2->lcLang );
488 }
489
main(int argc,char ** argv)490 int main( int argc, char ** argv )
491 {
492 int i;
493 const char * tabs= "\t\t\t\t";
494
495 qsort( LanguageCodes, LanguageCodeCount, sizeof(LanguageCode),
496 utilCompareLanguageCodesByNumber );
497
498 for ( i= 0; i < sizeof(LanguageCodes)/sizeof(LanguageCode); i++ )
499 {
500 LanguageCode * lc= &(LanguageCodes[i]);
501
502 lc->lcSource= i;
503 lc->lcCodeIndex= i;
504 }
505
506 qsort( LanguageCodes, LanguageCodeCount, sizeof(LanguageCode),
507 utilCompareLanguageCodesByString );
508
509 for ( i= 0; i < sizeof(LanguageCodes)/sizeof(LanguageCode); i++ )
510 {
511 LanguageCode * lc= &(LanguageCodes[i]);
512
513 LanguageCodes[lc->lcSource].lcCodeIndex= i;
514 }
515
516 for ( i= 0; i < LanguageCodeCount; i++ )
517 {
518 const LanguageCode * lc= &(LanguageCodes[i]);
519 const char * lang;
520 int code;
521
522 lang= utilLangForLanguageCode( lc->lcCode );
523 code= utilLanguageCodeForLang( lc->lcLang );
524
525 if ( code != lc->lcCode )
526 {
527 fprintf( stderr, "@%3d: %d != %d\n", i, code, lc->lcCode );
528 abort();
529 }
530
531 if ( ! lang )
532 {
533 fprintf( stderr, "@%3d: \"%s\" -> NULL\n", i, lc->lcLang );
534 abort();
535 }
536
537 if ( strcmp( lang, lc->lcLang ) )
538 {
539 fprintf( stderr, "@ %3d: \"%s\" != \"%s\"\n",
540 i, lang, lc->lcLang );
541 abort();
542 }
543 }
544
545 if ( utilLanguageCodeForLang( "AA" ) >= 0 )
546 { fprintf( stderr, "\"AA\"\n" ); abort(); }
547 if ( utilLanguageCodeForLang( "zzz" ) >= 0 )
548 { fprintf( stderr, "\"zzz\"\n" ); abort(); }
549 if ( utilLanguageCodeForLang( "ukz" ) >= 0 )
550 { fprintf( stderr, "\"ukz\"\n" ); abort(); }
551
552 if ( utilLangForLanguageCode( 0 ) )
553 { fprintf( stderr, "0\n" ); abort(); }
554 if ( utilLangForLanguageCode( 32767 ) )
555 { fprintf( stderr, "32767\n" ); abort(); }
556 if ( utilLangForLanguageCode( 1000 ) )
557 { fprintf( stderr, "1000\n" ); abort(); }
558
559 for ( i= 0; i < LanguageCodeCount; i++ )
560 {
561 int col;
562 const LanguageCode * lc= &(LanguageCodes[i]);
563 const LanguageCode * lcOut= lc;
564
565 /* lcOut= &(LanguageCodes[lc->lcCodeIndex]); */
566
567 col= 4+ 2+ 5+ 3+ strlen( lcOut->lcLang )+ 2;
568
569 col= col / 8;
570
571 printf( " { %5d, \"%s\",%s%4d }, /* 0x%04x */\n",
572 lcOut->lcCode,
573 lcOut->lcLang,
574 tabs+ col,
575 lcOut->lcCodeIndex,
576 LanguageCodes[i].lcCode);
577 }
578
579 return 0;
580 }
581
582 # endif
583