You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

localename.c 30KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. /* Determine the current selected locale.
  2. Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU Library General Public License as published
  5. by the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  14. USA. */
  15. /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
  16. /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
  17. #ifdef HAVE_CONFIG_H
  18. # include <config.h>
  19. #endif
  20. #include <stdlib.h>
  21. #include <locale.h>
  22. #if defined _WIN32 || defined __WIN32__
  23. # undef WIN32 /* avoid warning on mingw32 */
  24. # define WIN32
  25. #endif
  26. #ifdef WIN32
  27. # define WIN32_LEAN_AND_MEAN
  28. # include <windows.h>
  29. /* List of language codes, sorted by value:
  30. 0x01 LANG_ARABIC
  31. 0x02 LANG_BULGARIAN
  32. 0x03 LANG_CATALAN
  33. 0x04 LANG_CHINESE
  34. 0x05 LANG_CZECH
  35. 0x06 LANG_DANISH
  36. 0x07 LANG_GERMAN
  37. 0x08 LANG_GREEK
  38. 0x09 LANG_ENGLISH
  39. 0x0a LANG_SPANISH
  40. 0x0b LANG_FINNISH
  41. 0x0c LANG_FRENCH
  42. 0x0d LANG_HEBREW
  43. 0x0e LANG_HUNGARIAN
  44. 0x0f LANG_ICELANDIC
  45. 0x10 LANG_ITALIAN
  46. 0x11 LANG_JAPANESE
  47. 0x12 LANG_KOREAN
  48. 0x13 LANG_DUTCH
  49. 0x14 LANG_NORWEGIAN
  50. 0x15 LANG_POLISH
  51. 0x16 LANG_PORTUGUESE
  52. 0x17 LANG_RHAETO_ROMANCE
  53. 0x18 LANG_ROMANIAN
  54. 0x19 LANG_RUSSIAN
  55. 0x1a LANG_CROATIAN == LANG_SERBIAN
  56. 0x1b LANG_SLOVAK
  57. 0x1c LANG_ALBANIAN
  58. 0x1d LANG_SWEDISH
  59. 0x1e LANG_THAI
  60. 0x1f LANG_TURKISH
  61. 0x20 LANG_URDU
  62. 0x21 LANG_INDONESIAN
  63. 0x22 LANG_UKRAINIAN
  64. 0x23 LANG_BELARUSIAN
  65. 0x24 LANG_SLOVENIAN
  66. 0x25 LANG_ESTONIAN
  67. 0x26 LANG_LATVIAN
  68. 0x27 LANG_LITHUANIAN
  69. 0x28 LANG_TAJIK
  70. 0x29 LANG_FARSI
  71. 0x2a LANG_VIETNAMESE
  72. 0x2b LANG_ARMENIAN
  73. 0x2c LANG_AZERI
  74. 0x2d LANG_BASQUE
  75. 0x2e LANG_SORBIAN
  76. 0x2f LANG_MACEDONIAN
  77. 0x30 LANG_SUTU
  78. 0x31 LANG_TSONGA
  79. 0x32 LANG_TSWANA
  80. 0x33 LANG_VENDA
  81. 0x34 LANG_XHOSA
  82. 0x35 LANG_ZULU
  83. 0x36 LANG_AFRIKAANS
  84. 0x37 LANG_GEORGIAN
  85. 0x38 LANG_FAEROESE
  86. 0x39 LANG_HINDI
  87. 0x3a LANG_MALTESE
  88. 0x3b LANG_SAAMI
  89. 0x3c LANG_GAELIC
  90. 0x3d LANG_YIDDISH
  91. 0x3e LANG_MALAY
  92. 0x3f LANG_KAZAK
  93. 0x40 LANG_KYRGYZ
  94. 0x41 LANG_SWAHILI
  95. 0x42 LANG_TURKMEN
  96. 0x43 LANG_UZBEK
  97. 0x44 LANG_TATAR
  98. 0x45 LANG_BENGALI
  99. 0x46 LANG_PUNJABI
  100. 0x47 LANG_GUJARATI
  101. 0x48 LANG_ORIYA
  102. 0x49 LANG_TAMIL
  103. 0x4a LANG_TELUGU
  104. 0x4b LANG_KANNADA
  105. 0x4c LANG_MALAYALAM
  106. 0x4d LANG_ASSAMESE
  107. 0x4e LANG_MARATHI
  108. 0x4f LANG_SANSKRIT
  109. 0x50 LANG_MONGOLIAN
  110. 0x51 LANG_TIBETAN
  111. 0x52 LANG_WELSH
  112. 0x53 LANG_CAMBODIAN
  113. 0x54 LANG_LAO
  114. 0x55 LANG_BURMESE
  115. 0x56 LANG_GALICIAN
  116. 0x57 LANG_KONKANI
  117. 0x58 LANG_MANIPURI
  118. 0x59 LANG_SINDHI
  119. 0x5a LANG_SYRIAC
  120. 0x5b LANG_SINHALESE
  121. 0x5c LANG_CHEROKEE
  122. 0x5d LANG_INUKTITUT
  123. 0x5e LANG_AMHARIC
  124. 0x5f LANG_TAMAZIGHT
  125. 0x60 LANG_KASHMIRI
  126. 0x61 LANG_NEPALI
  127. 0x62 LANG_FRISIAN
  128. 0x63 LANG_PASHTO
  129. 0x64 LANG_TAGALOG
  130. 0x65 LANG_DIVEHI
  131. 0x66 LANG_EDO
  132. 0x67 LANG_FULFULDE
  133. 0x68 LANG_HAUSA
  134. 0x69 LANG_IBIBIO
  135. 0x6a LANG_YORUBA
  136. 0x70 LANG_IGBO
  137. 0x71 LANG_KANURI
  138. 0x72 LANG_OROMO
  139. 0x73 LANG_TIGRINYA
  140. 0x74 LANG_GUARANI
  141. 0x75 LANG_HAWAIIAN
  142. 0x76 LANG_LATIN
  143. 0x77 LANG_SOMALI
  144. 0x78 LANG_YI
  145. 0x79 LANG_PAPIAMENTU
  146. */
  147. /* Mingw headers don't have latest language and sublanguage codes. */
  148. # ifndef LANG_AFRIKAANS
  149. # define LANG_AFRIKAANS 0x36
  150. # endif
  151. # ifndef LANG_ALBANIAN
  152. # define LANG_ALBANIAN 0x1c
  153. # endif
  154. # ifndef LANG_AMHARIC
  155. # define LANG_AMHARIC 0x5e
  156. # endif
  157. # ifndef LANG_ARABIC
  158. # define LANG_ARABIC 0x01
  159. # endif
  160. # ifndef LANG_ARMENIAN
  161. # define LANG_ARMENIAN 0x2b
  162. # endif
  163. # ifndef LANG_ASSAMESE
  164. # define LANG_ASSAMESE 0x4d
  165. # endif
  166. # ifndef LANG_AZERI
  167. # define LANG_AZERI 0x2c
  168. # endif
  169. # ifndef LANG_BASQUE
  170. # define LANG_BASQUE 0x2d
  171. # endif
  172. # ifndef LANG_BELARUSIAN
  173. # define LANG_BELARUSIAN 0x23
  174. # endif
  175. # ifndef LANG_BENGALI
  176. # define LANG_BENGALI 0x45
  177. # endif
  178. # ifndef LANG_BURMESE
  179. # define LANG_BURMESE 0x55
  180. # endif
  181. # ifndef LANG_CAMBODIAN
  182. # define LANG_CAMBODIAN 0x53
  183. # endif
  184. # ifndef LANG_CATALAN
  185. # define LANG_CATALAN 0x03
  186. # endif
  187. # ifndef LANG_CHEROKEE
  188. # define LANG_CHEROKEE 0x5c
  189. # endif
  190. # ifndef LANG_DIVEHI
  191. # define LANG_DIVEHI 0x65
  192. # endif
  193. # ifndef LANG_EDO
  194. # define LANG_EDO 0x66
  195. # endif
  196. # ifndef LANG_ESTONIAN
  197. # define LANG_ESTONIAN 0x25
  198. # endif
  199. # ifndef LANG_FAEROESE
  200. # define LANG_FAEROESE 0x38
  201. # endif
  202. # ifndef LANG_FARSI
  203. # define LANG_FARSI 0x29
  204. # endif
  205. # ifndef LANG_FRISIAN
  206. # define LANG_FRISIAN 0x62
  207. # endif
  208. # ifndef LANG_FULFULDE
  209. # define LANG_FULFULDE 0x67
  210. # endif
  211. # ifndef LANG_GAELIC
  212. # define LANG_GAELIC 0x3c
  213. # endif
  214. # ifndef LANG_GALICIAN
  215. # define LANG_GALICIAN 0x56
  216. # endif
  217. # ifndef LANG_GEORGIAN
  218. # define LANG_GEORGIAN 0x37
  219. # endif
  220. # ifndef LANG_GUARANI
  221. # define LANG_GUARANI 0x74
  222. # endif
  223. # ifndef LANG_GUJARATI
  224. # define LANG_GUJARATI 0x47
  225. # endif
  226. # ifndef LANG_HAUSA
  227. # define LANG_HAUSA 0x68
  228. # endif
  229. # ifndef LANG_HAWAIIAN
  230. # define LANG_HAWAIIAN 0x75
  231. # endif
  232. # ifndef LANG_HEBREW
  233. # define LANG_HEBREW 0x0d
  234. # endif
  235. # ifndef LANG_HINDI
  236. # define LANG_HINDI 0x39
  237. # endif
  238. # ifndef LANG_IBIBIO
  239. # define LANG_IBIBIO 0x69
  240. # endif
  241. # ifndef LANG_IGBO
  242. # define LANG_IGBO 0x70
  243. # endif
  244. # ifndef LANG_INDONESIAN
  245. # define LANG_INDONESIAN 0x21
  246. # endif
  247. # ifndef LANG_INUKTITUT
  248. # define LANG_INUKTITUT 0x5d
  249. # endif
  250. # ifndef LANG_KANNADA
  251. # define LANG_KANNADA 0x4b
  252. # endif
  253. # ifndef LANG_KANURI
  254. # define LANG_KANURI 0x71
  255. # endif
  256. # ifndef LANG_KASHMIRI
  257. # define LANG_KASHMIRI 0x60
  258. # endif
  259. # ifndef LANG_KAZAK
  260. # define LANG_KAZAK 0x3f
  261. # endif
  262. # ifndef LANG_KONKANI
  263. # define LANG_KONKANI 0x57
  264. # endif
  265. # ifndef LANG_KYRGYZ
  266. # define LANG_KYRGYZ 0x40
  267. # endif
  268. # ifndef LANG_LAO
  269. # define LANG_LAO 0x54
  270. # endif
  271. # ifndef LANG_LATIN
  272. # define LANG_LATIN 0x76
  273. # endif
  274. # ifndef LANG_LATVIAN
  275. # define LANG_LATVIAN 0x26
  276. # endif
  277. # ifndef LANG_LITHUANIAN
  278. # define LANG_LITHUANIAN 0x27
  279. # endif
  280. # ifndef LANG_MACEDONIAN
  281. # define LANG_MACEDONIAN 0x2f
  282. # endif
  283. # ifndef LANG_MALAY
  284. # define LANG_MALAY 0x3e
  285. # endif
  286. # ifndef LANG_MALAYALAM
  287. # define LANG_MALAYALAM 0x4c
  288. # endif
  289. # ifndef LANG_MALTESE
  290. # define LANG_MALTESE 0x3a
  291. # endif
  292. # ifndef LANG_MANIPURI
  293. # define LANG_MANIPURI 0x58
  294. # endif
  295. # ifndef LANG_MARATHI
  296. # define LANG_MARATHI 0x4e
  297. # endif
  298. # ifndef LANG_MONGOLIAN
  299. # define LANG_MONGOLIAN 0x50
  300. # endif
  301. # ifndef LANG_NEPALI
  302. # define LANG_NEPALI 0x61
  303. # endif
  304. # ifndef LANG_ORIYA
  305. # define LANG_ORIYA 0x48
  306. # endif
  307. # ifndef LANG_OROMO
  308. # define LANG_OROMO 0x72
  309. # endif
  310. # ifndef LANG_PAPIAMENTU
  311. # define LANG_PAPIAMENTU 0x79
  312. # endif
  313. # ifndef LANG_PASHTO
  314. # define LANG_PASHTO 0x63
  315. # endif
  316. # ifndef LANG_PUNJABI
  317. # define LANG_PUNJABI 0x46
  318. # endif
  319. # ifndef LANG_RHAETO_ROMANCE
  320. # define LANG_RHAETO_ROMANCE 0x17
  321. # endif
  322. # ifndef LANG_SAAMI
  323. # define LANG_SAAMI 0x3b
  324. # endif
  325. # ifndef LANG_SANSKRIT
  326. # define LANG_SANSKRIT 0x4f
  327. # endif
  328. # ifndef LANG_SERBIAN
  329. # define LANG_SERBIAN 0x1a
  330. # endif
  331. # ifndef LANG_SINDHI
  332. # define LANG_SINDHI 0x59
  333. # endif
  334. # ifndef LANG_SINHALESE
  335. # define LANG_SINHALESE 0x5b
  336. # endif
  337. # ifndef LANG_SLOVAK
  338. # define LANG_SLOVAK 0x1b
  339. # endif
  340. # ifndef LANG_SOMALI
  341. # define LANG_SOMALI 0x77
  342. # endif
  343. # ifndef LANG_SORBIAN
  344. # define LANG_SORBIAN 0x2e
  345. # endif
  346. # ifndef LANG_SUTU
  347. # define LANG_SUTU 0x30
  348. # endif
  349. # ifndef LANG_SWAHILI
  350. # define LANG_SWAHILI 0x41
  351. # endif
  352. # ifndef LANG_SYRIAC
  353. # define LANG_SYRIAC 0x5a
  354. # endif
  355. # ifndef LANG_TAGALOG
  356. # define LANG_TAGALOG 0x64
  357. # endif
  358. # ifndef LANG_TAJIK
  359. # define LANG_TAJIK 0x28
  360. # endif
  361. # ifndef LANG_TAMAZIGHT
  362. # define LANG_TAMAZIGHT 0x5f
  363. # endif
  364. # ifndef LANG_TAMIL
  365. # define LANG_TAMIL 0x49
  366. # endif
  367. # ifndef LANG_TATAR
  368. # define LANG_TATAR 0x44
  369. # endif
  370. # ifndef LANG_TELUGU
  371. # define LANG_TELUGU 0x4a
  372. # endif
  373. # ifndef LANG_THAI
  374. # define LANG_THAI 0x1e
  375. # endif
  376. # ifndef LANG_TIBETAN
  377. # define LANG_TIBETAN 0x51
  378. # endif
  379. # ifndef LANG_TIGRINYA
  380. # define LANG_TIGRINYA 0x73
  381. # endif
  382. # ifndef LANG_TSONGA
  383. # define LANG_TSONGA 0x31
  384. # endif
  385. # ifndef LANG_TSWANA
  386. # define LANG_TSWANA 0x32
  387. # endif
  388. # ifndef LANG_TURKMEN
  389. # define LANG_TURKMEN 0x42
  390. # endif
  391. # ifndef LANG_UKRAINIAN
  392. # define LANG_UKRAINIAN 0x22
  393. # endif
  394. # ifndef LANG_URDU
  395. # define LANG_URDU 0x20
  396. # endif
  397. # ifndef LANG_UZBEK
  398. # define LANG_UZBEK 0x43
  399. # endif
  400. # ifndef LANG_VENDA
  401. # define LANG_VENDA 0x33
  402. # endif
  403. # ifndef LANG_VIETNAMESE
  404. # define LANG_VIETNAMESE 0x2a
  405. # endif
  406. # ifndef LANG_WELSH
  407. # define LANG_WELSH 0x52
  408. # endif
  409. # ifndef LANG_XHOSA
  410. # define LANG_XHOSA 0x34
  411. # endif
  412. # ifndef LANG_YI
  413. # define LANG_YI 0x78
  414. # endif
  415. # ifndef LANG_YIDDISH
  416. # define LANG_YIDDISH 0x3d
  417. # endif
  418. # ifndef LANG_YORUBA
  419. # define LANG_YORUBA 0x6a
  420. # endif
  421. # ifndef LANG_ZULU
  422. # define LANG_ZULU 0x35
  423. # endif
  424. # ifndef SUBLANG_ARABIC_SAUDI_ARABIA
  425. # define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
  426. # endif
  427. # ifndef SUBLANG_ARABIC_IRAQ
  428. # define SUBLANG_ARABIC_IRAQ 0x02
  429. # endif
  430. # ifndef SUBLANG_ARABIC_EGYPT
  431. # define SUBLANG_ARABIC_EGYPT 0x03
  432. # endif
  433. # ifndef SUBLANG_ARABIC_LIBYA
  434. # define SUBLANG_ARABIC_LIBYA 0x04
  435. # endif
  436. # ifndef SUBLANG_ARABIC_ALGERIA
  437. # define SUBLANG_ARABIC_ALGERIA 0x05
  438. # endif
  439. # ifndef SUBLANG_ARABIC_MOROCCO
  440. # define SUBLANG_ARABIC_MOROCCO 0x06
  441. # endif
  442. # ifndef SUBLANG_ARABIC_TUNISIA
  443. # define SUBLANG_ARABIC_TUNISIA 0x07
  444. # endif
  445. # ifndef SUBLANG_ARABIC_OMAN
  446. # define SUBLANG_ARABIC_OMAN 0x08
  447. # endif
  448. # ifndef SUBLANG_ARABIC_YEMEN
  449. # define SUBLANG_ARABIC_YEMEN 0x09
  450. # endif
  451. # ifndef SUBLANG_ARABIC_SYRIA
  452. # define SUBLANG_ARABIC_SYRIA 0x0a
  453. # endif
  454. # ifndef SUBLANG_ARABIC_JORDAN
  455. # define SUBLANG_ARABIC_JORDAN 0x0b
  456. # endif
  457. # ifndef SUBLANG_ARABIC_LEBANON
  458. # define SUBLANG_ARABIC_LEBANON 0x0c
  459. # endif
  460. # ifndef SUBLANG_ARABIC_KUWAIT
  461. # define SUBLANG_ARABIC_KUWAIT 0x0d
  462. # endif
  463. # ifndef SUBLANG_ARABIC_UAE
  464. # define SUBLANG_ARABIC_UAE 0x0e
  465. # endif
  466. # ifndef SUBLANG_ARABIC_BAHRAIN
  467. # define SUBLANG_ARABIC_BAHRAIN 0x0f
  468. # endif
  469. # ifndef SUBLANG_ARABIC_QATAR
  470. # define SUBLANG_ARABIC_QATAR 0x10
  471. # endif
  472. # ifndef SUBLANG_AZERI_LATIN
  473. # define SUBLANG_AZERI_LATIN 0x01
  474. # endif
  475. # ifndef SUBLANG_AZERI_CYRILLIC
  476. # define SUBLANG_AZERI_CYRILLIC 0x02
  477. # endif
  478. # ifndef SUBLANG_BENGALI_INDIA
  479. # define SUBLANG_BENGALI_INDIA 0x00
  480. # endif
  481. # ifndef SUBLANG_BENGALI_BANGLADESH
  482. # define SUBLANG_BENGALI_BANGLADESH 0x01
  483. # endif
  484. # ifndef SUBLANG_CHINESE_MACAU
  485. # define SUBLANG_CHINESE_MACAU 0x05
  486. # endif
  487. # ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
  488. # define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
  489. # endif
  490. # ifndef SUBLANG_ENGLISH_JAMAICA
  491. # define SUBLANG_ENGLISH_JAMAICA 0x08
  492. # endif
  493. # ifndef SUBLANG_ENGLISH_CARIBBEAN
  494. # define SUBLANG_ENGLISH_CARIBBEAN 0x09
  495. # endif
  496. # ifndef SUBLANG_ENGLISH_BELIZE
  497. # define SUBLANG_ENGLISH_BELIZE 0x0a
  498. # endif
  499. # ifndef SUBLANG_ENGLISH_TRINIDAD
  500. # define SUBLANG_ENGLISH_TRINIDAD 0x0b
  501. # endif
  502. # ifndef SUBLANG_ENGLISH_ZIMBABWE
  503. # define SUBLANG_ENGLISH_ZIMBABWE 0x0c
  504. # endif
  505. # ifndef SUBLANG_ENGLISH_PHILIPPINES
  506. # define SUBLANG_ENGLISH_PHILIPPINES 0x0d
  507. # endif
  508. # ifndef SUBLANG_ENGLISH_INDONESIA
  509. # define SUBLANG_ENGLISH_INDONESIA 0x0e
  510. # endif
  511. # ifndef SUBLANG_ENGLISH_HONGKONG
  512. # define SUBLANG_ENGLISH_HONGKONG 0x0f
  513. # endif
  514. # ifndef SUBLANG_ENGLISH_INDIA
  515. # define SUBLANG_ENGLISH_INDIA 0x10
  516. # endif
  517. # ifndef SUBLANG_ENGLISH_MALAYSIA
  518. # define SUBLANG_ENGLISH_MALAYSIA 0x11
  519. # endif
  520. # ifndef SUBLANG_ENGLISH_SINGAPORE
  521. # define SUBLANG_ENGLISH_SINGAPORE 0x12
  522. # endif
  523. # ifndef SUBLANG_FRENCH_LUXEMBOURG
  524. # define SUBLANG_FRENCH_LUXEMBOURG 0x05
  525. # endif
  526. # ifndef SUBLANG_FRENCH_MONACO
  527. # define SUBLANG_FRENCH_MONACO 0x06
  528. # endif
  529. # ifndef SUBLANG_FRENCH_WESTINDIES
  530. # define SUBLANG_FRENCH_WESTINDIES 0x07
  531. # endif
  532. # ifndef SUBLANG_FRENCH_REUNION
  533. # define SUBLANG_FRENCH_REUNION 0x08
  534. # endif
  535. # ifndef SUBLANG_FRENCH_CONGO
  536. # define SUBLANG_FRENCH_CONGO 0x09
  537. # endif
  538. # ifndef SUBLANG_FRENCH_SENEGAL
  539. # define SUBLANG_FRENCH_SENEGAL 0x0a
  540. # endif
  541. # ifndef SUBLANG_FRENCH_CAMEROON
  542. # define SUBLANG_FRENCH_CAMEROON 0x0b
  543. # endif
  544. # ifndef SUBLANG_FRENCH_COTEDIVOIRE
  545. # define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
  546. # endif
  547. # ifndef SUBLANG_FRENCH_MALI
  548. # define SUBLANG_FRENCH_MALI 0x0d
  549. # endif
  550. # ifndef SUBLANG_FRENCH_MOROCCO
  551. # define SUBLANG_FRENCH_MOROCCO 0x0e
  552. # endif
  553. # ifndef SUBLANG_FRENCH_HAITI
  554. # define SUBLANG_FRENCH_HAITI 0x0f
  555. # endif
  556. # ifndef SUBLANG_GERMAN_LUXEMBOURG
  557. # define SUBLANG_GERMAN_LUXEMBOURG 0x04
  558. # endif
  559. # ifndef SUBLANG_GERMAN_LIECHTENSTEIN
  560. # define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
  561. # endif
  562. # ifndef SUBLANG_KASHMIRI_INDIA
  563. # define SUBLANG_KASHMIRI_INDIA 0x02
  564. # endif
  565. # ifndef SUBLANG_MALAY_MALAYSIA
  566. # define SUBLANG_MALAY_MALAYSIA 0x01
  567. # endif
  568. # ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
  569. # define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
  570. # endif
  571. # ifndef SUBLANG_NEPALI_INDIA
  572. # define SUBLANG_NEPALI_INDIA 0x02
  573. # endif
  574. # ifndef SUBLANG_PUNJABI_INDIA
  575. # define SUBLANG_PUNJABI_INDIA 0x00
  576. # endif
  577. # ifndef SUBLANG_PUNJABI_PAKISTAN
  578. # define SUBLANG_PUNJABI_PAKISTAN 0x01
  579. # endif
  580. # ifndef SUBLANG_ROMANIAN_ROMANIA
  581. # define SUBLANG_ROMANIAN_ROMANIA 0x00
  582. # endif
  583. # ifndef SUBLANG_ROMANIAN_MOLDOVA
  584. # define SUBLANG_ROMANIAN_MOLDOVA 0x01
  585. # endif
  586. # ifndef SUBLANG_SERBIAN_LATIN
  587. # define SUBLANG_SERBIAN_LATIN 0x02
  588. # endif
  589. # ifndef SUBLANG_SERBIAN_CYRILLIC
  590. # define SUBLANG_SERBIAN_CYRILLIC 0x03
  591. # endif
  592. # ifndef SUBLANG_SINDHI_INDIA
  593. # define SUBLANG_SINDHI_INDIA 0x00
  594. # endif
  595. # ifndef SUBLANG_SINDHI_PAKISTAN
  596. # define SUBLANG_SINDHI_PAKISTAN 0x01
  597. # endif
  598. # ifndef SUBLANG_SPANISH_GUATEMALA
  599. # define SUBLANG_SPANISH_GUATEMALA 0x04
  600. # endif
  601. # ifndef SUBLANG_SPANISH_COSTA_RICA
  602. # define SUBLANG_SPANISH_COSTA_RICA 0x05
  603. # endif
  604. # ifndef SUBLANG_SPANISH_PANAMA
  605. # define SUBLANG_SPANISH_PANAMA 0x06
  606. # endif
  607. # ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
  608. # define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
  609. # endif
  610. # ifndef SUBLANG_SPANISH_VENEZUELA
  611. # define SUBLANG_SPANISH_VENEZUELA 0x08
  612. # endif
  613. # ifndef SUBLANG_SPANISH_COLOMBIA
  614. # define SUBLANG_SPANISH_COLOMBIA 0x09
  615. # endif
  616. # ifndef SUBLANG_SPANISH_PERU
  617. # define SUBLANG_SPANISH_PERU 0x0a
  618. # endif
  619. # ifndef SUBLANG_SPANISH_ARGENTINA
  620. # define SUBLANG_SPANISH_ARGENTINA 0x0b
  621. # endif
  622. # ifndef SUBLANG_SPANISH_ECUADOR
  623. # define SUBLANG_SPANISH_ECUADOR 0x0c
  624. # endif
  625. # ifndef SUBLANG_SPANISH_CHILE
  626. # define SUBLANG_SPANISH_CHILE 0x0d
  627. # endif
  628. # ifndef SUBLANG_SPANISH_URUGUAY
  629. # define SUBLANG_SPANISH_URUGUAY 0x0e
  630. # endif
  631. # ifndef SUBLANG_SPANISH_PARAGUAY
  632. # define SUBLANG_SPANISH_PARAGUAY 0x0f
  633. # endif
  634. # ifndef SUBLANG_SPANISH_BOLIVIA
  635. # define SUBLANG_SPANISH_BOLIVIA 0x10
  636. # endif
  637. # ifndef SUBLANG_SPANISH_EL_SALVADOR
  638. # define SUBLANG_SPANISH_EL_SALVADOR 0x11
  639. # endif
  640. # ifndef SUBLANG_SPANISH_HONDURAS
  641. # define SUBLANG_SPANISH_HONDURAS 0x12
  642. # endif
  643. # ifndef SUBLANG_SPANISH_NICARAGUA
  644. # define SUBLANG_SPANISH_NICARAGUA 0x13
  645. # endif
  646. # ifndef SUBLANG_SPANISH_PUERTO_RICO
  647. # define SUBLANG_SPANISH_PUERTO_RICO 0x14
  648. # endif
  649. # ifndef SUBLANG_SWEDISH_FINLAND
  650. # define SUBLANG_SWEDISH_FINLAND 0x02
  651. # endif
  652. # ifndef SUBLANG_TAMAZIGHT_ARABIC
  653. # define SUBLANG_TAMAZIGHT_ARABIC 0x01
  654. # endif
  655. # ifndef SUBLANG_TAMAZIGHT_LATIN
  656. # define SUBLANG_TAMAZIGHT_LATIN 0x02
  657. # endif
  658. # ifndef SUBLANG_TIGRINYA_ETHIOPIA
  659. # define SUBLANG_TIGRINYA_ETHIOPIA 0x00
  660. # endif
  661. # ifndef SUBLANG_TIGRINYA_ERITREA
  662. # define SUBLANG_TIGRINYA_ERITREA 0x01
  663. # endif
  664. # ifndef SUBLANG_URDU_PAKISTAN
  665. # define SUBLANG_URDU_PAKISTAN 0x01
  666. # endif
  667. # ifndef SUBLANG_URDU_INDIA
  668. # define SUBLANG_URDU_INDIA 0x02
  669. # endif
  670. # ifndef SUBLANG_UZBEK_LATIN
  671. # define SUBLANG_UZBEK_LATIN 0x01
  672. # endif
  673. # ifndef SUBLANG_UZBEK_CYRILLIC
  674. # define SUBLANG_UZBEK_CYRILLIC 0x02
  675. # endif
  676. #endif
  677. /* XPG3 defines the result of 'setlocale (category, NULL)' as:
  678. "Directs 'setlocale()' to query 'category' and return the current
  679. setting of 'local'."
  680. However it does not specify the exact format. Neither do SUSV2 and
  681. ISO C 99. So we can use this feature only on selected systems (e.g.
  682. those using GNU C Library). */
  683. #if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
  684. # define HAVE_LOCALE_NULL
  685. #endif
  686. /* Determine the current locale's name, and canonicalize it into XPG syntax
  687. language[_territory[.codeset]][@modifier]
  688. The codeset part in the result is not reliable; the locale_charset()
  689. should be used for codeset information instead.
  690. The result must not be freed; it is statically allocated. */
  691. const char *
  692. _nl_locale_name (int category, const char *categoryname)
  693. {
  694. const char *retval;
  695. #ifndef WIN32
  696. /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
  697. On some systems this can be done by the 'setlocale' function itself. */
  698. # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
  699. retval = setlocale (category, NULL);
  700. # else
  701. /* Setting of LC_ALL overwrites all other. */
  702. retval = getenv ("LC_ALL");
  703. if (retval == NULL || retval[0] == '\0')
  704. {
  705. /* Next comes the name of the desired category. */
  706. retval = getenv (categoryname);
  707. if (retval == NULL || retval[0] == '\0')
  708. {
  709. /* Last possibility is the LANG environment variable. */
  710. retval = getenv ("LANG");
  711. if (retval == NULL || retval[0] == '\0')
  712. /* We use C as the default domain. POSIX says this is
  713. implementation defined. */
  714. retval = "C";
  715. }
  716. }
  717. # endif
  718. return retval;
  719. #else /* WIN32 */
  720. /* Return an XPG style locale name language[_territory][@modifier].
  721. Don't even bother determining the codeset; it's not useful in this
  722. context, because message catalogs are not specific to a single
  723. codeset. */
  724. LCID lcid;
  725. LANGID langid;
  726. int primary, sub;
  727. /* Let the user override the system settings through environment
  728. variables, as on POSIX systems. */
  729. retval = getenv ("LC_ALL");
  730. if (retval != NULL && retval[0] != '\0')
  731. return retval;
  732. retval = getenv (categoryname);
  733. if (retval != NULL && retval[0] != '\0')
  734. return retval;
  735. retval = getenv ("LANG");
  736. if (retval != NULL && retval[0] != '\0')
  737. return retval;
  738. /* Use native Win32 API locale ID. */
  739. lcid = GetThreadLocale ();
  740. /* Strip off the sorting rules, keep only the language part. */
  741. langid = LANGIDFROMLCID (lcid);
  742. /* Split into language and territory part. */
  743. primary = PRIMARYLANGID (langid);
  744. sub = SUBLANGID (langid);
  745. /* Dispatch on language.
  746. See also http://www.unicode.org/unicode/onlinedat/languages.html .
  747. For details about languages, see http://www.ethnologue.com/ . */
  748. switch (primary)
  749. {
  750. case LANG_AFRIKAANS: return "af_ZA";
  751. case LANG_ALBANIAN: return "sq_AL";
  752. case LANG_AMHARIC: return "am_ET";
  753. case LANG_ARABIC:
  754. switch (sub)
  755. {
  756. case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
  757. case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
  758. case SUBLANG_ARABIC_EGYPT: return "ar_EG";
  759. case SUBLANG_ARABIC_LIBYA: return "ar_LY";
  760. case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
  761. case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
  762. case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
  763. case SUBLANG_ARABIC_OMAN: return "ar_OM";
  764. case SUBLANG_ARABIC_YEMEN: return "ar_YE";
  765. case SUBLANG_ARABIC_SYRIA: return "ar_SY";
  766. case SUBLANG_ARABIC_JORDAN: return "ar_JO";
  767. case SUBLANG_ARABIC_LEBANON: return "ar_LB";
  768. case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
  769. case SUBLANG_ARABIC_UAE: return "ar_AE";
  770. case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
  771. case SUBLANG_ARABIC_QATAR: return "ar_QA";
  772. }
  773. return "ar";
  774. case LANG_ARMENIAN: return "hy_AM";
  775. case LANG_ASSAMESE: return "as_IN";
  776. case LANG_AZERI:
  777. switch (sub)
  778. {
  779. /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
  780. case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
  781. case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
  782. }
  783. return "az";
  784. case LANG_BASQUE:
  785. return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
  786. case LANG_BELARUSIAN: return "be_BY";
  787. case LANG_BENGALI:
  788. switch (sub)
  789. {
  790. case SUBLANG_BENGALI_INDIA: return "bn_IN";
  791. case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
  792. }
  793. return "bn";
  794. case LANG_BULGARIAN: return "bg_BG";
  795. case LANG_BURMESE: return "my_MM";
  796. case LANG_CAMBODIAN: return "km_KH";
  797. case LANG_CATALAN: return "ca_ES";
  798. case LANG_CHEROKEE: return "chr_US";
  799. case LANG_CHINESE:
  800. switch (sub)
  801. {
  802. case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
  803. case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
  804. case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
  805. case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
  806. case SUBLANG_CHINESE_MACAU: return "zh_MO";
  807. }
  808. return "zh";
  809. case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
  810. * What used to be called Serbo-Croatian
  811. * should really now be two separate
  812. * languages because of political reasons.
  813. * (Says tml, who knows nothing about Serbian
  814. * or Croatian.)
  815. * (I can feel those flames coming already.)
  816. */
  817. switch (sub)
  818. {
  819. case SUBLANG_DEFAULT: return "hr_HR";
  820. case SUBLANG_SERBIAN_LATIN: return "sr_CS";
  821. case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
  822. }
  823. return "hr";
  824. case LANG_CZECH: return "cs_CZ";
  825. case LANG_DANISH: return "da_DK";
  826. case LANG_DIVEHI: return "dv_MV";
  827. case LANG_DUTCH:
  828. switch (sub)
  829. {
  830. case SUBLANG_DUTCH: return "nl_NL";
  831. case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
  832. }
  833. return "nl";
  834. case LANG_EDO: return "bin_NG";
  835. case LANG_ENGLISH:
  836. switch (sub)
  837. {
  838. /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
  839. * English was the language spoken in England.
  840. * Oh well.
  841. */
  842. case SUBLANG_ENGLISH_US: return "en_US";
  843. case SUBLANG_ENGLISH_UK: return "en_GB";
  844. case SUBLANG_ENGLISH_AUS: return "en_AU";
  845. case SUBLANG_ENGLISH_CAN: return "en_CA";
  846. case SUBLANG_ENGLISH_NZ: return "en_NZ";
  847. case SUBLANG_ENGLISH_EIRE: return "en_IE";
  848. case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
  849. case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
  850. case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
  851. case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
  852. case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
  853. case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
  854. case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
  855. case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
  856. case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
  857. case SUBLANG_ENGLISH_INDIA: return "en_IN";
  858. case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
  859. case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
  860. }
  861. return "en";
  862. case LANG_ESTONIAN: return "et_EE";
  863. case LANG_FAEROESE: return "fo_FO";
  864. case LANG_FARSI: return "fa_IR";
  865. case LANG_FINNISH: return "fi_FI";
  866. case LANG_FRENCH:
  867. switch (sub)
  868. {
  869. case SUBLANG_FRENCH: return "fr_FR";
  870. case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
  871. case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
  872. case SUBLANG_FRENCH_SWISS: return "fr_CH";
  873. case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
  874. case SUBLANG_FRENCH_MONACO: return "fr_MC";
  875. case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
  876. case SUBLANG_FRENCH_REUNION: return "fr_RE";
  877. case SUBLANG_FRENCH_CONGO: return "fr_CG";
  878. case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
  879. case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
  880. case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
  881. case SUBLANG_FRENCH_MALI: return "fr_ML";
  882. case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
  883. case SUBLANG_FRENCH_HAITI: return "fr_HT";
  884. }
  885. return "fr";
  886. case LANG_FRISIAN: return "fy_NL";
  887. case LANG_FULFULDE:
  888. /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */
  889. return "ff_NG";
  890. case LANG_GAELIC:
  891. switch (sub)
  892. {
  893. case 0x01: /* SCOTTISH */ return "gd_GB";
  894. case 0x02: /* IRISH */ return "ga_IE";
  895. }
  896. return "C";
  897. case LANG_GALICIAN: return "gl_ES";
  898. case LANG_GEORGIAN: return "ka_GE";
  899. case LANG_GERMAN:
  900. switch (sub)
  901. {
  902. case SUBLANG_GERMAN: return "de_DE";
  903. case SUBLANG_GERMAN_SWISS: return "de_CH";
  904. case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
  905. case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
  906. case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
  907. }
  908. return "de";
  909. case LANG_GREEK: return "el_GR";
  910. case LANG_GUARANI: return "gn_PY";
  911. case LANG_GUJARATI: return "gu_IN";
  912. case LANG_HAUSA: return "ha_NG";
  913. case LANG_HAWAIIAN:
  914. /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
  915. or Hawaii Creole English ("cpe_US", 600000 speakers)? */
  916. return "cpe_US";
  917. case LANG_HEBREW: return "he_IL";
  918. case LANG_HINDI: return "hi_IN";
  919. case LANG_HUNGARIAN: return "hu_HU";
  920. case LANG_IBIBIO: return "nic_NG";
  921. case LANG_ICELANDIC: return "is_IS";
  922. case LANG_IGBO: return "ig_NG";
  923. case LANG_INDONESIAN: return "id_ID";
  924. case LANG_INUKTITUT: return "iu_CA";
  925. case LANG_ITALIAN:
  926. switch (sub)
  927. {
  928. case SUBLANG_ITALIAN: return "it_IT";
  929. case SUBLANG_ITALIAN_SWISS: return "it_CH";
  930. }
  931. return "it";
  932. case LANG_JAPANESE: return "ja_JP";
  933. case LANG_KANNADA: return "kn_IN";
  934. case LANG_KANURI: return "kr_NG";
  935. case LANG_KASHMIRI:
  936. switch (sub)
  937. {
  938. case SUBLANG_DEFAULT: return "ks_PK";
  939. case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
  940. }
  941. return "ks";
  942. case LANG_KAZAK: return "kk_KZ";
  943. case LANG_KONKANI:
  944. /* FIXME: Adjust this when such locales appear on Unix. */
  945. return "kok_IN";
  946. case LANG_KOREAN: return "ko_KR";
  947. case LANG_KYRGYZ: return "ky_KG";
  948. case LANG_LAO: return "lo_LA";
  949. case LANG_LATIN: return "la_VA";
  950. case LANG_LATVIAN: return "lv_LV";
  951. case LANG_LITHUANIAN: return "lt_LT";
  952. case LANG_MACEDONIAN: return "mk_MK";
  953. case LANG_MALAY:
  954. switch (sub)
  955. {
  956. case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
  957. case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
  958. }
  959. return "ms";
  960. case LANG_MALAYALAM: return "ml_IN";
  961. case LANG_MALTESE: return "mt_MT";
  962. case LANG_MANIPURI:
  963. /* FIXME: Adjust this when such locales appear on Unix. */
  964. return "mni_IN";
  965. case LANG_MARATHI: return "mr_IN";
  966. case LANG_MONGOLIAN:
  967. return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
  968. case LANG_NEPALI:
  969. switch (sub)
  970. {
  971. case SUBLANG_DEFAULT: return "ne_NP";
  972. case SUBLANG_NEPALI_INDIA: return "ne_IN";
  973. }
  974. return "ne";
  975. case LANG_NORWEGIAN:
  976. switch (sub)
  977. {
  978. case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
  979. case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
  980. }
  981. return "no";
  982. case LANG_ORIYA: return "or_IN";
  983. case LANG_OROMO: return "om_ET";
  984. case LANG_PAPIAMENTU: return "pap_AN";
  985. case LANG_PASHTO:
  986. return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
  987. case LANG_POLISH: return "pl_PL";
  988. case LANG_PORTUGUESE:
  989. switch (sub)
  990. {
  991. case SUBLANG_PORTUGUESE: return "pt_PT";
  992. /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
  993. Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
  994. case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
  995. }
  996. return "pt";
  997. case LANG_PUNJABI:
  998. switch (sub)
  999. {
  1000. case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
  1001. case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
  1002. }
  1003. return "pa";
  1004. case LANG_RHAETO_ROMANCE: return "rm_CH";
  1005. case LANG_ROMANIAN:
  1006. switch (sub)
  1007. {
  1008. case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
  1009. case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
  1010. }
  1011. return "ro";
  1012. case LANG_RUSSIAN:
  1013. return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
  1014. case LANG_SAAMI: /* actually Northern Sami */ return "se_NO";
  1015. case LANG_SANSKRIT: return "sa_IN";
  1016. case LANG_SINDHI:
  1017. switch (sub)
  1018. {
  1019. case SUBLANG_SINDHI_INDIA: return "sd_IN";
  1020. case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
  1021. }
  1022. return "sd";
  1023. case LANG_SINHALESE: return "si_LK";
  1024. case LANG_SLOVAK: return "sk_SK";
  1025. case LANG_SLOVENIAN: return "sl_SI";
  1026. case LANG_SOMALI: return "so_SO";
  1027. case LANG_SORBIAN:
  1028. /* FIXME: Adjust this when such locales appear on Unix. */
  1029. return "wen_DE";
  1030. case LANG_SPANISH:
  1031. switch (sub)
  1032. {
  1033. case SUBLANG_SPANISH: return "es_ES";
  1034. case SUBLANG_SPANISH_MEXICAN: return "es_MX";
  1035. case SUBLANG_SPANISH_MODERN:
  1036. return "es_ES@modern"; /* not seen on Unix */
  1037. case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
  1038. case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
  1039. case SUBLANG_SPANISH_PANAMA: return "es_PA";
  1040. case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
  1041. case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
  1042. case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
  1043. case SUBLANG_SPANISH_PERU: return "es_PE";
  1044. case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
  1045. case SUBLANG_SPANISH_ECUADOR: return "es_EC";
  1046. case SUBLANG_SPANISH_CHILE: return "es_CL";
  1047. case SUBLANG_SPANISH_URUGUAY: return "es_UY";
  1048. case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
  1049. case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
  1050. case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
  1051. case SUBLANG_SPANISH_HONDURAS: return "es_HN";
  1052. case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
  1053. case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
  1054. }
  1055. return "es";
  1056. case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
  1057. case LANG_SWAHILI: return "sw_KE";
  1058. case LANG_SWEDISH:
  1059. switch (sub)
  1060. {
  1061. case SUBLANG_DEFAULT: return "sv_SE";
  1062. case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
  1063. }
  1064. return "sv";
  1065. case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */
  1066. case LANG_TAGALOG: return "tl_PH";
  1067. case LANG_TAJIK: return "tg_TJ";
  1068. case LANG_TAMAZIGHT:
  1069. switch (sub)
  1070. {
  1071. /* FIXME: Adjust this when Tamazight locales appear on Unix. */
  1072. case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
  1073. case SUBLANG_TAMAZIGHT_LATIN: return "ber_MA@latin";
  1074. }
  1075. return "ber_MA";
  1076. case LANG_TAMIL:
  1077. return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
  1078. case LANG_TATAR: return "tt_RU";
  1079. case LANG_TELUGU: return "te_IN";
  1080. case LANG_THAI: return "th_TH";
  1081. case LANG_TIBETAN: return "bo_CN";
  1082. case LANG_TIGRINYA:
  1083. switch (sub)
  1084. {
  1085. case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
  1086. case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
  1087. }
  1088. return "ti";
  1089. case LANG_TSONGA: return "ts_ZA";
  1090. case LANG_TSWANA: return "tn_BW";
  1091. case LANG_TURKISH: return "tr_TR";
  1092. case LANG_TURKMEN: return "tk_TM";
  1093. case LANG_UKRAINIAN: return "uk_UA";
  1094. case LANG_URDU:
  1095. switch (sub)
  1096. {
  1097. case SUBLANG_URDU_PAKISTAN: return "ur_PK";
  1098. case SUBLANG_URDU_INDIA: return "ur_IN";
  1099. }
  1100. return "ur";
  1101. case LANG_UZBEK:
  1102. switch (sub)
  1103. {
  1104. case SUBLANG_UZBEK_LATIN: return "uz_UZ";
  1105. case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
  1106. }
  1107. return "uz";
  1108. case LANG_VENDA: return "ve_ZA";
  1109. case LANG_VIETNAMESE: return "vi_VN";
  1110. case LANG_WELSH: return "cy_GB";
  1111. case LANG_XHOSA: return "xh_ZA";
  1112. case LANG_YI: return "sit_CN";
  1113. case LANG_YIDDISH: return "yi_IL";
  1114. case LANG_YORUBA: return "yo_NG";
  1115. case LANG_ZULU: return "zu_ZA";
  1116. default: return "C";
  1117. }
  1118. #endif
  1119. }