1 /* 2 * Copyright 2006-2008 The FLWOR Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 #ifndef ZORBA_CORE_LOCALE_H 18 #define ZORBA_CORE_LOCALE_H 19 20 #include <iostream> 21 22 #include <zorba/locale.h> 23 24 namespace zorba { 25 namespace locale { 26 27 /////////////////////////////////////////////////////////////////////////// 28 29 namespace iso3166_1 { 30 enum type { 31 unknown, 32 AD, ///< Andorra 33 AE, ///< United Arab Emirates 34 AF, ///< Afghanistan 35 AG, ///< Antigua and Barbuda 36 AI, ///< Anguilla 37 AL, ///< Albania 38 AM, ///< Armenia 39 AN, ///< Netherlands Antilles 40 AO, ///< Angola 41 AQ, ///< Antarctica 42 AR, ///< Argentina 43 AS, ///< American Samoa 44 AT, ///< Austria 45 AU, ///< Australia 46 AW, ///< Aruba 47 AX, ///< Aland Islands 48 AZ, ///< Azerbaijan 49 BA, ///< Bosnia and Herzegovina 50 BB, ///< Barbados 51 BD, ///< Bangladesh 52 BE, ///< Belgium 53 BF, ///< Burkina Faso 54 BG, ///< Bulgaria 55 BH, ///< Bahrain 56 BI, ///< Burundi 57 BJ, ///< Benin 58 BL, ///< Saint Barthelemy 59 BM, ///< Bermuda 60 BN, ///< Brunei Darussalam 61 BO, ///< Bolivia 62 BR, ///< Brazil 63 BS, ///< Bahamas 64 BT, ///< Bhutan 65 BV, ///< Bouvet Island 66 BW, ///< Botswana 67 BY, ///< Belarus 68 BZ, ///< Belize 69 CA, ///< Canada 70 CC, ///< Cocos Islands 71 CD, ///< Congo 72 CF, ///< Central African Republic 73 CG, ///< Congo 74 CH, ///< Switzerland 75 CI, ///< Cote D'Ivoire 76 CK, ///< Cook Islands 77 CL, ///< Chile 78 CM, ///< Cameroon 79 CN, ///< China 80 CO, ///< Colombia 81 CR, ///< Costa Rica 82 CU, ///< Cuba 83 CV, ///< Cape Verde 84 CX, ///< Christmas Island 85 CY, ///< Cyprus 86 CZ, ///< Czech Republic 87 DE, ///< Germany 88 DJ, ///< Djibouti 89 DK, ///< Denmark 90 DM, ///< Dominica 91 DO, ///< Dominican Republic 92 DZ, ///< Algeria 93 EC, ///< Ecuador 94 EE, ///< Estonia 95 EG, ///< Egypt 96 EH, ///< Western Sahara 97 ER, ///< Eritrea 98 ES, ///< Spain 99 ET, ///< Ethiopia 100 FI, ///< Finland 101 FJ, ///< Fiji 102 FK, ///< Falkland Islands 103 FM, ///< Micronesia 104 FO, ///< Faroe Islands 105 FR, ///< France 106 GA, ///< Gabon 107 GB, ///< United Kingdom 108 GD, ///< Grenada 109 GE, ///< Georgia 110 GF, ///< French Guiana 111 GG, ///< Guernsey 112 GH, ///< Ghana 113 GI, ///< Gibraltar 114 GL, ///< Greenland 115 GM, ///< Gambia 116 GN, ///< Guinea 117 GP, ///< Guadeloupe 118 GQ, ///< Equatorial Guinea 119 GR, ///< Greece 120 GS, ///< South Georgia and the South Sandwich Islands 121 GT, ///< Guatemala 122 GU, ///< Guam 123 GW, ///< Guinea-Bissau 124 GY, ///< Guyana 125 HK, ///< Hong Kong 126 HM, ///< Heard Island and Mcdonald Islands 127 HN, ///< Honduras 128 HR, ///< Croatia 129 HT, ///< Haiti 130 HU, ///< Hungary 131 ID, ///< Indonesia 132 IE, ///< Ireland 133 IL, ///< Israel 134 IM, ///< Isle of Man 135 IN_, ///< India [without '_', it clashes with an identifier on Windows] 136 IO, ///< British Indian Ocean Territory 137 IQ, ///< Iraq 138 IR, ///< Iran 139 IS, ///< Iceland 140 IT, ///< Italy 141 JE, ///< Jersey 142 JM, ///< Jamaica 143 JO, ///< Jordan 144 JP, ///< Japan 145 KE, ///< Kenya 146 KG, ///< Kyrgyzstan 147 KH, ///< Cambodia 148 KI, ///< Kiribati 149 KM, ///< Comoros 150 KN, ///< Saint Kitts and Nevis 151 KP, ///< Korea (Democratic People's Republic) 152 KR, ///< Korea 153 KW, ///< Kuwait 154 KY, ///< Cayman Islands 155 KZ, ///< Kazakhstan 156 LA, ///< Lao 157 LB, ///< Lebanon 158 LC, ///< Saint Lucia 159 LI, ///< Liechtenstein 160 LK, ///< Sri Lanka 161 LR, ///< Liberia 162 LS, ///< Lesotho 163 LT, ///< Lithuania 164 LU, ///< Luxembourg 165 LV, ///< Latvia 166 LY, ///< Libyan Arab Jamahiriya 167 MA, ///< Morocco 168 MC, ///< Monaco 169 MD, ///< Moldova 170 ME, ///< Montenegro 171 MF, ///< Saint Martin 172 MG, ///< Madagascar 173 MH, ///< Marshall Islands 174 MK, ///< Macedonia 175 ML, ///< Mali 176 MM, ///< Myanmar 177 MN, ///< Mongolia 178 MO, ///< Macao 179 MP, ///< Northern Mariana Islands 180 MQ, ///< Martinique 181 MR, ///< Mauritania 182 MS, ///< Montserrat 183 MT, ///< Malta 184 MU, ///< Mauritius 185 MV, ///< Maldives 186 MW, ///< Malawi 187 MX, ///< Mexico 188 MY, ///< Malaysia 189 MZ, ///< Mozambique 190 NA, ///< Namibia 191 NC, ///< New Caledonia 192 NE, ///< Niger 193 NF, ///< Norfolk Island 194 NG, ///< Nigeria 195 NI, ///< Nicaragua 196 NL, ///< Netherlands 197 NO, ///< Norway 198 NP, ///< Nepal 199 NR, ///< Nauru 200 NU, ///< Niue 201 NZ, ///< New Zealand 202 OM, ///< Oman 203 PA, ///< Panama 204 PE, ///< Peru 205 PF, ///< French Polynesia 206 PG, ///< Papua New Guinea 207 PH, ///< Philippines 208 PK, ///< Pakistan 209 PL, ///< Poland 210 PM, ///< Saint Pierre and Miquelon 211 PN, ///< Pitcairn 212 PR, ///< Puerto Rico 213 PS, ///< Palestinian Territory 214 PT, ///< Portugal 215 PW, ///< Palau 216 PY, ///< Paraguay 217 QA, ///< Qatar 218 RE, ///< Reunion 219 RO, ///< Romania 220 RS, ///< Serbia 221 RU, ///< Russian Federation 222 RW, ///< Rwanda 223 SA, ///< Saudi Arabia 224 SB, ///< Solomon Islands 225 SC, ///< Seychelles 226 SD, ///< Sudan 227 SE, ///< Sweden 228 SG, ///< Singapore 229 SH, ///< Saint Helena 230 SI, ///< Slovenia 231 SJ, ///< Svalbard and Jan Mayen 232 SK, ///< Slovakia 233 SL, ///< Sierra Leone 234 SM, ///< San Marino 235 SN, ///< Senegal 236 SO, ///< Somalia 237 SR, ///< Suriname 238 ST, ///< Sao Tome and Principe 239 SV, ///< El Salvador 240 SY, ///< Syria 241 SZ, ///< Swaziland 242 TC, ///< Turks and Caicos Islands 243 TD, ///< Chad 244 TF, ///< French Southern Territories 245 TG, ///< Togo 246 TH, ///< Thailand 247 TJ, ///< Tajikistan 248 TK, ///< Tokelau 249 TL, ///< Timor-Leste 250 TM, ///< Turkmenistan 251 TN, ///< Tunisia 252 TO, ///< Tonga 253 TR, ///< Turkey 254 TT, ///< Trinidad and Tobago 255 TV, ///< Tuvalu 256 TW, ///< Taiwan 257 TZ, ///< Tanzania 258 UA, ///< Ukraine 259 UG, ///< Uganda 260 UM, ///< United States Minor Outlying Islands 261 US, ///< United States 262 UY, ///< Uruguay 263 UZ, ///< Uzbekistan 264 VA, ///< Vatican 265 VC, ///< Saint Vincent and the Grenadines 266 VE, ///< Venezuela 267 VG, ///< Virgin Islands (British) 268 VI, ///< Virgin Islands (USA) 269 VN, ///< Viet Nam 270 VU, ///< Vanuatu 271 WF, ///< Wallis and Futuna 272 WS, ///< Samoa 273 YE, ///< Yemen 274 YT, ///< Mayotte 275 ZA, ///< South Africa 276 ZM, ///< Zambia 277 ZW, ///< Zimbabwe 278 NUM_ENTRIES 279 }; 280 extern char const *const string_of[]; 281 282 /** 283 * Emits an iso3166_1::type to an ostream. 284 * 285 * @param o The ostream to emit to. 286 * @param t The type to emit. 287 * @return Returns \a o. 288 */ 289 inline std::ostream& operator<<( std::ostream &o, type t ) { 290 return o << string_of[ t ]; 291 } 292 293 /** 294 * Finds the ISO 3166-1 country code enumeration from the given string. 295 * 296 * @param country An ISO 3166-1 country code. 297 * @return Returns said enumeration or \c unknown. 298 */ 299 type find( char const *country ); 300 } 301 302 /////////////////////////////////////////////////////////////////////////// 303 304 namespace iso639_1 { 305 extern char const *const string_of[]; 306 307 /** 308 * Emits an iso639_1::type to an ostream. 309 * 310 * @param o The ostream to emit to. 311 * @param t The type to emit. 312 * @return Returns \a o. 313 */ 314 inline std::ostream& operator<<( std::ostream &o, type t ) { 315 return o << string_of[ t ]; 316 } 317 318 /** 319 * Finds the ISO 639-1 language code enumeration from the given string. 320 * 321 * @param lang An ISO 639-1 langauge code. 322 * @return Returns said enumeration or \c unknown. 323 */ 324 type find( char const *lang ); 325 } 326 327 /////////////////////////////////////////////////////////////////////////// 328 329 namespace iso639_2 { 330 enum type { 331 unknown, 332 aar, ///< Afar 333 abk, ///< Abkhazian 334 afr, ///< Afrikaans 335 aka, ///< Akan 336 alb, ///< Albanian 337 amh, ///< Amharic 338 ara, ///< Arabic 339 arg, ///< Aragonese 340 arm, ///< Armenian 341 asm_, ///< Assamese [without '_', it's a C++ keyword] 342 ava, ///< Avaric 343 ave, ///< Avestan 344 aym, ///< Aymara 345 aze, ///< Azerbaijani 346 bak, ///< Bashkir 347 bam, ///< Bambara 348 baq, ///< Basque 349 bel, ///< Belarusian 350 ben, ///< Bengali 351 bih, ///< Bihari 352 bis, ///< Bislama 353 bos, ///< Bosnian 354 bre, ///< Breton 355 bul, ///< Bulgarian 356 bur, ///< Burmese 357 cat, ///< Catalan 358 cha, ///< Chamorro 359 che, ///< Chechen 360 chi, ///< Chinese 361 chu, ///< Church Slavic; Old Slavonic; Church Slavonic 362 cym, ///< Welsh 363 dan, ///< Danish 364 deu, ///< German (T) 365 div, ///< Divehi; Dhivehi; Maldivian 366 dut, ///< Dutch (B) 367 dzo, ///< Dzongkha 368 ell, ///< Modern Greek 369 eng, ///< English 370 epo, ///< Esperanto 371 est, ///< Estonian 372 ewe, ///< Ewe 373 fao, ///< Faroese 374 fij, ///< Fijian 375 fin, ///< Finnish 376 fra, ///< French (T) 377 fre, ///< French (B) 378 fry, ///< Western Frisian 379 ful, ///< Fulah 380 geo, ///< Georgian 381 ger, ///< German (B) 382 gla, ///< Scottish Gaelic; Gaelic 383 gle, ///< Irish 384 glg, ///< Galician 385 glv, ///< Manx 386 gre, ///< Modern Greek 387 grn, ///< Guarani 388 guj, ///< Gujarati 389 hat, ///< Haitian Creole; Haitian 390 hau, ///< Hausa 391 heb, ///< Hebrew 392 her, ///< Herero 393 hin, ///< Hindi 394 hmo, ///< Hiri Motu 395 hrv, ///< Croatian 396 hun, ///< Hungarian 397 ibo, ///< Igbo 398 ice, ///< Icelandic 399 ido, ///< Ido 400 iku, ///< Inuktitut 401 ile, ///< Interlingue; Occidental 402 ina, ///< Interlingua 403 ind, ///< Indonesian 404 ipk, ///< Inupiaq 405 isl, ///< Icelandic 406 ita, ///< Italian 407 jav, ///< Javanese 408 jpn, ///< Japanese 409 kal, ///< Kalaallisut; Greenlandic 410 kan, ///< Kannada 411 kas, ///< Kashmiri 412 kat, ///< Georgian 413 kau, ///< Kanuri 414 kaz, ///< Kazakh 415 khm, ///< Central Khmer 416 kik, ///< Kikuyu; Gikuyu 417 kin, ///< Kinyarwanda 418 kir, ///< Kirghiz; Kyrgyz 419 kom, ///< Komi 420 kon, ///< Kongo 421 kor, ///< Korean 422 kua, ///< Kuanyama; Kwanyama 423 kur, ///< Kurdish 424 lao, ///< Lao 425 lat, ///< Latin 426 lav, ///< Latvian 427 lim, ///< Limburgan; Limburger; Limburgish 428 lin, ///< Lingala 429 lit, ///< Lithuanian 430 ltz, ///< Luxembourgish; Letzeburgesch 431 lub, ///< Luba-Katanga 432 mya, ///< Burmese 433 nld, ///< Dutch (T) 434 nor, ///< Norwegian 435 nya, ///< Chichewa; Chewa; Nyanja 436 por, ///< Portuguese 437 ron, ///< Romanian (T) 438 rum, ///< Romanian (B) 439 rus, ///< Russian 440 spa, ///< Spanish 441 swe, ///< Swedish 442 tur, ///< Turkish 443 ven, ///< Venda 444 vie, ///< Vietnamese 445 vol, ///< Volapuk 446 wel, ///< Welsh 447 wln, ///< Walloon 448 wol, ///< Wolof 449 xho, ///< Xhosa 450 yid, ///< Yiddish 451 yor, ///< Yoruba 452 zha, ///< Zhuang; Chuang 453 zho, ///< Chinese 454 zul, ///< Zulu 455 NUM_ENTRIES 456 }; 457 extern char const *const string_of[]; 458 459 /** 460 * Emits an iso639_2::type to an ostream. 461 * 462 * @param o The ostream to emit to. 463 * @param t The type to emit. 464 * @return Returns \a o. 465 */ 466 inline std::ostream& operator<<( std::ostream &o, type t ) { 467 return o << string_of[ t ]; 468 } 469 470 /** 471 * Finds the ISO 639-2 language code enumeration from the given string. 472 * 473 * @param lang An ISO 639-2 langauge code. 474 * @return Returns said enumeration or \c unknown. 475 */ 476 type find( char const *lang ); 477 } 478 479 /////////////////////////////////////////////////////////////////////////// 480 481 /** 482 * Finds the ISO 639-1 language code enumeration from the given string. 483 * 484 * @param lang Either an ISO 639-1 or an ISO 639-2 langauge code. 485 * @return Returns said enumeration or \c unknown. 486 */ 487 iso639_1::type find_lang( char const *lang ); 488 489 /** 490 * Gets the ISO 3166-1 country code enumeration for the host system. 491 * 492 * @return Returns said enumeration or \c unknown. 493 */ 494 iso3166_1::type get_host_country(); 495 496 /** 497 * Gets the ISO 639-1 language code enumeration for the host system. 498 * 499 * @return Returns said enumeration defaulting to \c en. 500 */ 501 iso639_1::type get_host_lang(); 502 503 /////////////////////////////////////////////////////////////////////////// 504 505 } // namespace locale 506 } // namespace zorba 507 508 #undef DEF_OSTREAM_INSERT_OPERATOR 509 510 #endif /* ZORBA_CORE_LOCALE_H */ 511 /* vim:set et sw=2 ts=2: */ 512