1 module nxt.languages; 2 3 @safe pure: 4 5 import nxt.conv_ex : toDefaulted; 6 7 /** Language Code according to ISO 639-1 plus computer languages. 8 * 9 * See_Also: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 10 * See_Also: http://www.mathguide.de/info/tools/languagecode.html 11 * See_Also: http://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx 12 */ 13 enum Lang 14 { 15 unknown, 16 nullValue = unknown, // `OpenHashMapOrSet` null support 17 holeValue, // `OpenHashMapOrSet` hole support 18 19 en, english = en, /// English 20 en_US, american_english = en_US, /// American. English 21 en_GB, british_english = en_GB, /// British English 22 en_CA, canadian_english = en_CA, /// Canadian English 23 // ac, /// TODO? 24 // ace, /// TODO? 25 // ai, /// TODO? 26 // ain, /// TODO? 27 af, afrikaans = af, afr = afrikaans, /// Afrikaans 28 ar, arabic = ar, /// Arabic 29 // ary, /// TODO? 30 // arc, /// TODO? 31 ae, avestan = ae, /// Avestan Iran (extinct) 32 ak, akan = ak, /// Akan 33 // akk, /// TODO? 34 an, aragonese = an, /// Aragonese 35 // ang, /// TODO? 36 as, assamese = as, /// Assamese 37 // ase, /// TODO? 38 // ast, /// TODO? 39 // ax, /// TODO? 40 az, azerbaijani = az, azeri = azerbaijani, /// Azerbaijani (Azeri) 41 hy, armenian = hy, /// Armenian: Armenia 42 eu, basque = eu, /// Basque: Spain, France 43 ba, baskhir = ba, /// Baskhir: Volga, Urals, Central Asia 44 // ban, /// TODO? 45 be, belarusian = be, /// Belarusian 46 // bj, /// TODO? 47 bn, bengali = bn, /// Bengali (Bangla): Bangladesh, India 48 br, breton = br, /// Breton: France 49 bs, bosnian = bs, /// Bosnian 50 bg, bulgarian = bg, bul = bulgarian, /// Bulgarian 51 bo, tibetan = bo, /// Tibetan 52 // bp, /// TODO? 53 // bt, /// TODO? 54 my, burmese = my, /// Burmese: Myanmar 55 zh, chinese = zh, /// Chinese (Mandarin, Putonghua): China, Singapore 56 crh, crimean = crh, /// Crimean Tatar 57 hr, croatian = hr, /// Croatian: Croatia 58 // cr, /// TODO? 59 ca, catalan = ca, valencian = catalan, cat = valencian, /// Catalan/Valencian (Spain) 60 cy, welch = cy, welsh = welch, cym = welsh, /// Welch: Wales, Heddwch, Tangnefedd 61 cs, czech = cs, ces = czech, /// Czech: Czech Republic 62 // csb, /// TODO? 63 da, danish = da, dan = danish, /// Danish: Denmark, Greenland 64 // ds, /// TODO? 65 // dsb, /// TODO? 66 nl, dutch = nl, flemish = dutch, /// Dutch (Flemish): Netherlands, Belgium 67 eo, esperanto = eo, /// Esperanto 68 et, estonian = et, /// Estonian 69 fi, finnish = fi, fin = finnish, /// Finnish: Finland, Sweden, Russia 70 fj, fijian = fj, /// Fijian: Fiji 71 fo, faroese = fo, /// Faroese (Faeroese): Faroe Islands 72 // fu, /// TODO? 73 fr, french = fr, fra = french, /// French: France, Belgium, Canada, Caribbean, West Africa, Polynesia 74 fr_ch, swiss_french, /// French (Switzerland) 75 gl, galician = gl, gallegan = galician, /// Galician (Gallegan): Spain, Portugal 76 gv, manx = gv, /// Manx: Isle of Man 77 de, german = de, deu = german, /// German: Germany, Austria, Switzerland, Liechtenstein, Italy, Belgium 78 el, greek = el, ell = greek, /// Greek: Greece, Cyprus 79 ha, hausa = ha, /// Hausa: Nigeria 80 haw, hawaiian = haw, /// Hawaiian: Hawaii 81 he, hebrew = he, /// Hebrew: Israel 82 // hs, /// TODO? 83 // hsb, /// TODO? 84 hi, hindi = hi, /// Hindi: India, Nepal, Uganda, Suriname 85 hu, hungarian = hu, /// Hungarian: Hungary, Romania, Slovakia 86 is_, icelandic = is_, /// Icelandic 87 io, ido = io, /// Ido: Nigeria 88 id, indonesian = id, /// Indonesian (Bahasa): Indonesia 89 ga, irish = ga, /// Irish: Ireland 90 it, italian = it, ita = italian, /// Italian: Italy, Switzerland 91 ja, japanese = ja, /// Japanese, 日本語: Japan 92 ka, georgian = ka, /// Georgian: Georgia 93 ku, kurdish = ku, /// Kurdish: Kurdistan (Turkey, Syria, Iran, Iraq) 94 kn, kannada = kn, /// Kannada: India 95 kk, kazakh = kk, /// Kazakh: Kazakhstan 96 km, khmer = km, /// Khmer: Cambodia 97 ko, korean = ko, /// Korean: Korea 98 ky, kirghiz = ky, kyrgyz = kirghiz, /// Kirghiz (Kyrgyz): Kirghizstan, China 99 lo, lao = lo, /// Lao: Laos 100 la, latin = la, lat = latin, /// Latin: Rome (extinct) 101 lt, lithuanian = lt, /// Lithuanian: Lithuania 102 lv, latvian = lv, /// Latvian: Latvia 103 jbo, /// lojban = jbo, /// Lojban 104 mk, macedonian = mk, /// Macedonian: Macedonia 105 nan, southern_min = nan, min_nan = southern_min, /// Min Nan: https://en.wikipedia.org/wiki/Southern_Min 106 mg, malagasy = mg, malgache = malagasy, /// Malagasy (Malgache): Madagascar 107 mn, mongolian = mn, /// Mongolian: Mongolia 108 ms, malay = ms, zsm = malay, /// Malay: Malaysia 109 mt, maltese = mt, /// Maltese: Malta 110 ne, nepali = ne, /// Nepali: Nepal 111 no, norwegian = no, nob = norwegian, /// Norwegian: Norway 112 ps, pashto = ps, /// Pashto: Afghanistan, Iran, Pakistan 113 fa, persian = fa, farsi = persian, /// Persian (Farsi): Iran, Iraq, Afghanistan, Pakistan, Azerbaijan 114 oc, occitan = oc, /// Occitan (Provençal, Languedocian): France 115 pl, polish = pl, /// Polish 116 pt, portuguese = pt, por = portuguese, /// Portuguese: Portugal, Brazil, Angola, Mozambique, Cape Verde, Guinea-Bissau 117 pt_BR, brazilian_portuguese = pt_BR, /// Brazilian Portuguese 118 ro, romanian = ro, /// Romanian: Romania, Hungary 119 ru, russian = ru, rus = russian, /// Russian 120 sa, sanskrit = sa, /// Sanskrit: India (extinct, liturgical) 121 // sc, /// TODO? 122 // scn, /// TODO? 123 si, sinhalese = si, /// Sinhalese: Sri Lanka 124 sm, samoan = sm, /// Samoan: Samoa 125 sco, scots = sco, /// Scots: Scotland 126 sq, albanian = sq, /// Albanian: Albania, Kosovo 127 // se, /// TODO? 128 // sy, /// TODO? 129 // syc, /// TODO? 130 te, telugu = te, /// Telugu: India 131 tl, tagalog = tl, pilipino = tagalog, /// Tagalog (Pilipino): Philippines 132 // tp, /// TODO? 133 // tpi, /// TODO? 134 gd, scottish_gaelic = gd, /// Scottish Gaelic: Scotland 135 sr, serbian = sr, /// Serbian: Serbia, Montenegro, Bosnia 136 sk, slovak = sk, slk = slovak, /// Slovak: Slovak Republic 137 sl, slovene = sl, slovenian = slovene, slv = slovenian, /// Slovene, Slovenian: Slovenia, Austria, Italy 138 es, spanish = es, spa = spanish, /// Spanish 139 // es_ar, spanishArgentina = es_ar, 140 // es_bo, spanishBolivia = es_bo, 141 sw, swahili = sw, swa = swahili, /// Swahili: East Africa 142 sv, swedish = sv, swe = swedish, /// Swedish 143 asv, ancientSwedish = asv, /// Ancient Swedish 144 tg, tajik = tg, /// Tajik: Tajikistan, Afghanistan 145 ta, tamil = ta, tam = tamil, /// Tamil: India 146 th, thai = th, tha = thai, /// Thai: Thailand 147 tr, turkish = tr, tur = turkish, /// Turkish: Turkey, Cyprus 148 tk, turkmen = tk, /// Turkmen: Turkmenistan, Afghanistan 149 uk, ukrainian = uk, ukr = ukrainian, /// Ukrainian 150 ur, urdu = ur, /// Urdu: Pakistan, India, Central Asia 151 uz, uzbek = uz, /// Uzbek: Uzbekistan, Central Asia, China 152 vi, vietnamese = vi, vie = vietnamese, /// Vietnamese: Viet Nam 153 vo, volapuk = vo, /// Volapük 154 wa, waloon = wa, wln = waloon, /// Waloon: Belgium 155 yi, yiddish = yi, yid = yiddish, /// Yiddish: Israel, USA, Russia 156 157 aa, afar = aa,/// Afar Ethiopia, Eritrea, Djibouti Salaamata 158 ab, abkhaz = ab,/// Abkhaz Caucasus needed! 159 afa, luganda = afa,/// Luganda Uganda Emirembe 160 akk, akkadian = akk,/// Akkadian Mesopotamia (extinct) (Salmu) 161 alg, abenaki = alg,/// Abenaki North America Okikiamgenoka, Kamignokawôgan 162 am, amharic = am,/// Amharic Ethopia, Egypt ሰላም (salām) 163 ang, /// Anglo Saxon (Old English) England (extinct) ᚠᚱᛁᚦ (friþ), Frið 164 arw, arawak = arw,/// Arawak Suriname, Guyana, Venezuela needed! 165 arc, aramaic = arc,/// Aramaic (Syriac, Assyrian) Iraq, Iran, Syria, and liturgical ܫܠܡܐ (shlamaa) 166 arn, mapundungun = arn,/// Mapundungun Chile Uvchin, Tügkülen 167 art, /// lojban = art,/// Lojban panpi 168 ast, asturian = ast,/// Asturian Spain Paz 169 at, haiti_creole = at, kreyol = haiti_creole, /// Haiti / Guiana Creole (Kreyol) Caribbean Lapè 170 aus, olkola = aus,/// Olkola Australia Erray 171 /// aus, /// Pintupi-Luritja Australia Yatanpa 172 /// aus, /// Wagiman Australia Nyimbur-ma 173 /// aus, /// Warlpiri Australia Iawa-nyinami 174 av, avar = av,/// Avar Caucasus Рекъел (reqel) 175 ay, aymara = ay,/// Aymara Bolivia Hacaña 176 bai, dschang = bai, yemba = dschang, /// Dschang (Yemba) Cameroon Mbwɛ´né 177 bas, basaa = bas,/// Basaa Cameroon SàN 178 bat, old_prussian = bat, sudovian = old_prussian, jatvingian = sudovian, /// Old Prussian, Sudovian (Jatvingian) Baltic (extinct) Pakajan 179 btk, batak = btk,/// Batak Indonesia Pardamean 180 bem, bemba = bem,/// Bemba Zambia Mutenden, Ukwikala mu 181 bh, bihari = bh,/// Bihari India needed! 182 bi, bislama = bi,/// Bislama Vanuatu Pís 183 bla, blackfoot = bla,/// Blackfoot North America Innaihtsi'iyi 184 bm, bambara = bm,/// Bambara Mali Here, Errébé 185 cai, /// Ch'ol (Tumbalá) Chiapas (Mexico) Ñʌch'chocoya 186 car, caribe = car,/// Caribe Venezuala, Suriname needed! 187 ce, chechen = ce,/// Chechen Chechnya (Caucasus) Машар (mashar) 188 ceb, cebuano = ceb,/// Cebuano Philippines Kalinaw, Kahusayan 189 ch, chamorro = ch,/// Chamorro Guam Minaggen 190 cho, choctaw = cho,/// Choctaw North America Achukma 191 chk, chuuk = chk,/// Chuuk Truk Kunammwey 192 chr, cherokee = chr,/// Cherokee (Tsalagi) North America ᏙᎯᏱ (dohiyi) 193 chy, cheyenne = chy,/// Cheyenne North America Nanomonsetôtse 194 co, corsican = co,/// Corsican Corsica (France) Pace 195 cop, coptic = cop,/// Coptic Egypt (extinct) and liturgical Ϩιρηνη (hirīnī) 196 cpe, /// Afro-Seminole North America needed! 197 cpf, cajun_french = cpf, acadian = cajun_french, /// Cajun French (Acadian, Kreyol Lwiziyen) Louisiana (USA) needed! 198 cr, cree = cr,/// Cree North America Wetaskiwin, Papayatik 199 crp, fanagolo = crp,/// Fanagolo South Africa Kutula 200 cu, /// Old Church Slavonic Eastern Europe (liturgical) Ми́ръ (mírə) 201 cv, chuvash = cv,/// Chuvash Russia needed! 202 del, lenape = del,/// Lenape (Delaware) North America Achwangundowagan 203 dua, duala = dua,/// Duala Cameroon Musango 204 dra, brahui = dra,/// Brahui Pakistan, Afghanistan, Iran (âsûdaî) 205 dv, divehi = dv,/// Divehi (Maldivian) Maldives ސުޅަ (sulha) 206 dz, dzongkha = dz,/// Dzongkha Bhutan གཞི་བདེ (gzhi-bde) 207 ee, ewe = ee,/// Ewe (Évé) West Africa Ŋutifafa 208 efi, efik = efi,/// Efik Nigeria Emem 209 enm, middle_english = enm, /// Middle English England (extinct) Pes, Pise, Pees, ... 210 ff, fula = ff, falani = fula, /// Fula (Falani) West Africa Jam 211 fiu, karelian = fiu,/// Karelian Russia, Finland Rauhu, Vienosti 212 fon, benin = fon,/// Fon Benin Fifâ 213 fro, /// Old French France Pais 214 fur, friulian = fur, frulan = friulian, /// Friulian (Frulan) Friuli (Italy) Pâs 215 fy, frisian = fy,/// Frisian Germany, Netherlands Frede 216 gez, /// Ge'ez Ethiopia, Eritrea (liturgical) ሰላም (salām) 217 gmh, /// Middle High German Central Europe (extinct) Vride 218 gn, guarani = gn,/// Guarani Bolivia, Paraguay, Brazil Apĭrĭvé, Ñerane'i, Py'aguapy 219 goh, /// Old High German Central Europe (extinct) Fridu 220 got, gothic = got,/// Gothic Central Europe (extinct) 221 grc, ancient_greek = grc,/// Ancient Greek Miditerranean (extinct) and liturgical Εἰρήνη (eirḗnē) 222 gu, gujarati = gu,/// Gujarati India, Pakistan શાંતિ (śānti) 223 hil, hiligaynon = hil,/// Hiligaynon (Ilongo) Philippines Paghidait 224 hmn, hmong = hmn,/// Hmong China, Viet Nam, Laos, Thailand Kev tiaj tus 225 ho, hiri_motu = ho,/// Hiri Motu Papua New Guinea Taim billong sikan 226 hz, herero = hz,/// Herero Southern Africa needed! 227 ia, interlingua = ia,/// Interlingua Pace 228 ie, interlingue = ie,/// Interlingue Pace 229 ig, igbo = ig,/// Igbo (Ibo) Nigeria Udo 230 ii, sichuan_yi = ii,/// Sichuan Yi China ꄮꐽ (te-njo) 231 in_, 232 ik, /// Iñupiaq Alaska Kiñuiñak, Tutqiun 233 ilo, ilocano = ilo,/// Ilocano Philippines Kappia 234 inh, ingush = inh,/// Ingush Ingutia (Caucasus) Машар (mashar) 235 iu, inuktitut = iu,/// Inuktitut Canada ᓴᐃᒻᒪᓯᒪᓂᖅ (saimmasimaniq) 236 jpr, /// Judeo-Persian (Bukharic) Mideast, Central Asia needed! 237 jrb, /// Judeo-Arabic Mideast, North Africa needed! 238 jv, javanese = jv,/// Javanese Indonesia Rukun 239 kab, kabyle = kab,/// Kabyle Algeria Lahna 240 kg, kongo = kg,/// Kongo Congo Kikœndi 241 ki, kikuyu = ki, gikuyu = kikuyu, /// Kikuyu (Gikuyu) Kenya Thayu 242 kj, kwanyama = kj, kuanyama = kwanyama, /// Kwanyama (Kuanyama) Angola, Namibia needed! 243 kl, greenlandic = kl, kalaallisut = greenlandic, /// Greenlandic (Kalaallisut) Greenland Irqigsiniq, Erĸigsineĸ 244 kos, kosraean = kos,/// Kosraean Micronesia Mihs 245 kr, kanuri = kr,/// Kanuri Niger, Nigeria needed! 246 ks, kashmiri = ks,/// Kashmiri Kashmir (India, Pakistan) امن (amn) 247 kv, komi = kv,/// Komi Russian Arctic needed! 248 kw, cornish = kw,/// Cornish Cornwall (extinct) Cres 249 lad, ladino = lad,/// Ladino (Judeo-Spanish) Turkey, Israel, North Africa Pas, פאש 250 lb, luxemburgish = lb,/// Luxemburgish (Lëtzebuergesch) Luxembourg Fridd, Fridden 251 lg, ganda = lg,/// Ganda Niger, Congo needed! 252 li, limburgan = li,/// Limburgan (Limburgish) Belgium Vreij 253 ln, lingala = ln,/// Lingala Congo Kímía 254 lol, mongo_nkundu = lol,/// Mongo-Nkundu Congo Bóoto 255 loz, lozi = loz,/// Lozi Zambia Nala 256 lu, luba_katanga = lu,/// Luba-Katanga Niger, Congo needed! 257 man, mandinka = man,/// Mandinka Senegal, Gambia, Guinea-Bissau Kayiroo 258 map, bisaya = map,/// Bisaya Brunei Kalinaw 259 mh, marshallese = mh,/// Marshallese Marshall Islands Ainemon 260 mi, maori = mi,/// Maori New Zealand Rangima'arie, Nohopuku, Rongo 261 mic, micmac = mic,/// Micmac North America Wôntôkóde 262 mis, ainu = mis,/// Ainu Japan アプンノ, あぷんの (apunno) 263 ml, malayalam = ml,/// Malayalam India സമാധാനം (samaadhaanam) 264 mno, manobo = mno,/// Manobo Philippines Linew 265 mo, moldavian = mo,/// Moldavian (Moldavan) Moldava Pace, Паче (pace) 266 mos, mossi = mos,/// Mossi (Moré) Burkina Faso Lâfí 267 mr, marathi = mr,/// Marathi India शांतता (śāntātā), शांती (śāntī) 268 mus, muskogee = mus,/// Muskogee (Creek) North America Ittimokla 269 myn, kekchi = myn,/// Kekchi Guatemala, Belize Tuktuquil usilal 270 na, nauruan = na,/// Nauruan Nauru Iow 271 nah, /// Náhuatl (Aztec) Mexico, Guatemala Tlamatcanemiliztli, Mocehuia 272 nd, north_ndebele = nd,/// North Ndebele Zimbabwe needed! 273 nds, old_saxon = nds, saxony = old_saxon, /// Old Saxon Saxony (extinct) Friðu 274 ng, ndonga = ng,/// Ndonga Angola, Namibia needed! 275 non, old_norse = non,/// Old Norse Scandinavia (extinct) ᚠᚱᛁᚦᚱ, Friðr 276 nr, south_ndebele = nr,/// South Ndebele Zimbabwe, Botswana needed! 277 nv, navajo = nv,/// Navajo (Navaho) North America K'é, Hozo 278 ny, chichewa = ny,/// Chichewa (Chewa, Nyanja) Malawi M'tendere 279 // om, oromo = om,/// Oromo Ethiopia, Kenya Nagaya, ነገየ (nagaya) 280 or, oriya = or,/// Oriya India needed! 281 // os, ossetic = os, ossetian = ossetic, /// Ossetic (Ossetian) Georgia, Russia needed! 282 oto, otomi = oto,/// Otomi Mexico Hmetho 283 pa, panjabi = pa, punjab = panjabi, /// Panjabi (Punjab) Pakistan, India ਸ਼ਾਂਤੀ (śānti) 284 // paa, /// Ekari Indonesia Muka-Muka 285 // pag, /// Pangasinan Philippines Kareenan 286 // pam, /// Pampangan (Kapampangan) Philippines Kapayapan 287 // pap, /// Papiamentu Netherlands Antilles Pas 288 // pau, /// Palauan Palau Búdech 289 // pi, /// Pali India Sāma, Santi 290 // qu, /// Quechua Peru Anka Kay, Qasikay, Aligu, Sonqo Tiaykuy 291 // rap, /// Rapanui Chile Kiba-kiba, Pava 292 // rm, /// Raeto-Romance (Romansch) Switzerland Pasch 293 // rn, /// Rundi (Kirundi, Urundi) Burundi Amahoro 294 // rom, /// Romany (Gypsy, Tsigane) Europe, South America, etc Smirom 295 // rw, /// Kinyarwanda (Rwanda, Ruanda) Rwanda Nimuhóre, Amahoro 296 // sd, /// Sindhi Pakistan, India शांति, شانت (śanti) 297 // sg, /// Sango Central African Republic needed! 298 // sn, /// Shona Zimbabwe Runyaro, Dendemaro 299 // so, /// Somali Somalia, Djibouti, Ethiopia Nabáda 300 // ss, /// Swati (Siswati) Swaziland Kuthála 301 // st, /// Southern Sotho (Sesotho, Sesuthu) South Africa Kgotso, Khotso 302 // su, /// Sundanese Indonesia needed! 303 // ti, /// Tigrinya (Tigrigna) Eritrea ሰላም (salām) 304 // tli, /// Tlingit North America Li-k'ei 305 // tn, /// Tswana (Setswana) Botswana Khotso, Kagiso 306 // to, /// Tonga Zambia Malino, Melino 307 // ts, /// Tsonga South Africa needed! 308 // tt, /// Tatar Russia Тынычлык (tınıçlık) 309 // tw, /// Twi West Africa Asomdwee 310 // ty, /// Tahitian Tahiti Hau 311 // ug, /// Uighur (Uygur) China, Central Asia تىنچلىق (tinçlik) 312 // ve, /// Venda South Africa needed! 313 // wen, /// Upper Sorbian (Wendish) Germany Pokoj 314 // wo, /// Wolof West Africa Jàmm 315 // xh, /// Xhosa South Africa, Botswana Uxolo 316 // yo, /// Yoruba Nigeria, Benin, Togo Alaáfía 317 // ypk, /// Yu'pik Alaska, Canada Kiñuiñak 318 // za, /// Chuang (Zhuang) China needed! 319 // zap, /// Zapotec Mexico Layeni, Binlo 320 // zu, /// Zulu Southern Africa Isithangami, Ukuthula 321 322 /** International Phonetic Alphabet (IPA) 323 https:///en.wikipedia.org/wiki/International_Phonetic_Alphabet */ 324 ipa, 325 326 /// Programming Languages. 327 c, firstFormal = c, 328 cxx, 329 objectiveC, 330 objectiveCxx, 331 cSharp, 332 d, 333 go, 334 java, 335 ada, 336 rust, 337 swift, 338 fortran, 339 modelica, 340 341 lastFormal = modelica, 342 343 /// Academic Languages 344 math, /// "Mathematics is the only truly universal language" 345 physics, 346 347 regularExpression, regexp = regularExpression, 348 } 349 // pragma(msg, cast(uint)Lang.regularExpression); 350 351 /** Return true if programming language $(D lang) is case-sensitive. */ 352 bool isCaseSensitive(Lang lang) @safe pure @nogc nothrow 353 { 354 return !(lang == Lang.bg || 355 lang == Lang.ada); 356 // import std.algorithm.comparison: among; 357 // return cast(bool)lang.among!(Lang.bg, Lang.ada); 358 } 359 360 /** Return true if $(D lang) is a formal (computer) language. */ 361 bool isFormal(Lang lang) @safe pure @nogc nothrow 362 { 363 pragma(inline, true); 364 return (lang >= Lang.firstFormal && 365 lang <= Lang.lastFormal); 366 } 367 368 /** TODO Remove when `__traits(documentation)` is merged 369 */ 370 string toSpoken(Lang lang, Lang spokenLang = Lang.init) @safe pure nothrow // TODO @nogc 371 { 372 with (Lang) 373 { 374 switch (lang) 375 { 376 case unknown: return `??`; 377 case en: return `English`; // 英語 378 case en_US: return `American English`; 379 case en_GB: return `British English`; 380 case en_CA: return `Canadian English`; 381 case af: return `Afrikaans`; 382 case ar: return `Arabic`; 383 case ae: return `Avestan`; 384 case ak: return `Akan`; 385 case an: return `Aragonese`; 386 case as: return `Assamese`; 387 case az: return `Azerbaijani`; 388 case hy: return `Armenian`; 389 case eu: return `Basque`; 390 case ba: return `Baskhir`; 391 case be: return `Belarusian`; 392 case bn: return `Bengali`; 393 case br: return `Breton`; 394 case bs: return `Bosnian`; 395 case bg: return `Bulgarian`; 396 case bo: return `Tibetan`; 397 case my: return `Burmese`; 398 case zh: return `Chinese Mandarin`; 399 case crh: return `Crimean Tatar`; 400 case hr: return `Croatian`; 401 case ca: return `Catalan`; 402 case cy: return `Welch`; 403 case cs: return `Czech`; 404 case da: return `Danish`; 405 case nl: return `Dutch`; 406 case eo: return `Esperanto`; 407 case et: return `Estonian`; 408 case fi: return `Finnish`; 409 case fj: return `Fiji`; 410 case fo: return `Faroese`; 411 case fr: return `French`; 412 case fr_ch: return `French (Switzerland)`; 413 case gl: return `Galician`; 414 case gv: return `Manx`; 415 case de: return `German`; 416 case el: return `Greek`; 417 case grc: return `Ancient Greek`; 418 case ha: return `Hausa`; 419 case he: return `Hebrew`; 420 case hi: return `Hindi`; 421 case hu: return `Hungarian`; 422 case is_: return `Icelandic`; 423 case io: return `Ido`; 424 case id: return `Indonesian`; 425 case ga: return `Irish`; 426 case it: return `Italian`; 427 case ja: return `Japanese`; // 日本語 428 case ka: return `Georgian`; 429 case ku: return `Kurdish`; 430 case kn: return `Kannada`; 431 case kk: return `Kazakh`; 432 case km: return `Khmer`; 433 case ko: return `Korean`; 434 case ky: return `Kyrgyz`; 435 case lo: return `Lao`; 436 case la: return `Latin`; 437 case lt: return `Lithuanian`; 438 case lv: return `Latvian`; 439 case jbo: return `Lojban`; 440 case mk: return `Macedonian`; 441 case nan: return `Min Nan`; 442 case mg: return `Malagasy`; 443 case mn: return `Mongolian`; 444 case ms: return `Malay`; 445 case mt: return `Maltese`; 446 case ne: return `Nepali`; 447 case no: return `Norwegian`; 448 case ps: return `Pashto`; 449 case fa: return `Persian`; 450 case oc: return `Occitan`; 451 case pl: return `Polish`; 452 case pt: return `Portuguese`; 453 case pt_BR: return `Brazilian Portuguese`; 454 case ro: return `Romanian`; 455 case ru: return `Russian`; 456 case sa: return `Sanskrit`; 457 case si: return `Sinhalese`; 458 case sm: return `Samoan`; 459 case sco: return `Scots`; 460 case sq: return `Albanian`; 461 case te: return `Tegulu`; 462 case tl: return `Tagalog`; 463 case gd: return `Scottish Gaelic`; 464 case sr: return `Serbian`; 465 case sk: return `Slovak`; 466 case sl: return `Slovene`; 467 case es: return `Spanish`; 468 case sw: return `Swahili`; 469 case sv: return `Swedish`; 470 case asv: return `Ancient Swedish`; 471 case tg: return `Tajik`; 472 case ta: return `Tamil`; 473 case th: return `Thai`; 474 case tr: return `Turkish`; 475 case tk: return `Turkmen`; 476 case uk: return `Ukrainian`; 477 case ur: return `Urdu`; 478 case uz: return `Uzbek`; 479 case vi: return `Vietnamese`; 480 case vo: return `Volapük`; 481 case wa: return `Waloon`; 482 case yi: return `Yiddish`; 483 case akk: return `Akkadian`; 484 case ce: return `Chechen`; 485 case co: return `Corsican`; 486 case fur: return `Friulian`; 487 case gu: return `Gujarati`; 488 case hil: return `Hiligaynon`; 489 case haw: return `Hawaiian`; 490 491 case ipa: return `International Phonetic Alphabet`; 492 493 case c: return `C`; 494 case cxx: return `C++`; 495 case cSharp: return `C#`; 496 case objectiveC: return `Objective-C`; 497 case objectiveCxx: return `Objective-C++`; 498 case d: return `D`; 499 case go: return `Go`; 500 case java: return `Java`; 501 case ada: return `Ada`; 502 case rust: return `Rust`; 503 case swift: return `Swift`; 504 case fortran: return `Fortran`; 505 case modelica: return `Modelica`; 506 507 case math: return `mathematics`; 508 case physics: return `physics`; 509 case regularExpression: return `regular expression`; 510 511 default: 512 import nxt.enum_ex : toStringFaster; 513 return lang.toStringFaster; 514 } 515 } 516 } 517 518 Lang decodeLang(const scope const(char)[] lang) @safe pure nothrow @nogc 519 { 520 switch (lang) 521 { 522 case `is`: 523 return Lang.is_; 524 case `in`: 525 return Lang.in_; 526 default: 527 return typeof(return)(lang.toDefaulted!Lang(Lang.unknown)); 528 } 529 } 530 531 /// 532 @safe pure unittest 533 { 534 assert(`sv`.decodeLang == Lang.sv); 535 } 536 537 Lang decodeLangDefaulted(const scope const(char)[] lang, 538 Lang defaultLang) @safe pure nothrow @nogc 539 { 540 switch (lang) 541 { 542 case `is`: 543 return Lang.is_; 544 case `in`: 545 return Lang.in_; 546 default: 547 return typeof(return)(lang.toDefaulted!Lang(defaultLang)); 548 } 549 } 550 551 /// 552 @safe pure nothrow unittest 553 { 554 assert(`_`.decodeLangDefaulted(Lang.unknown) == Lang.unknown); 555 assert(`_`.decodeLangDefaulted(Lang.en) == Lang.en); 556 assert(`sv`.decodeLangDefaulted(Lang.unknown) == Lang.sv); 557 assert(`en`.decodeLangDefaulted(Lang.unknown) == Lang.en); 558 } 559 560 /// 561 @safe pure nothrow /*TODO @nogc*/ unittest 562 { 563 assert(Lang.unknown.toSpoken == `??`); 564 assert(Lang.c.toSpoken == `C`); 565 assert(Lang.cxx.toSpoken == `C++`); 566 assert(Lang.d.toSpoken == `D`); 567 assert(Lang.java.toSpoken == `Java`); 568 } 569 570 string toHTML(Lang lang) @safe pure nothrow /*TODO @nogc*/ 571 { 572 return lang.toSpoken; 573 } 574 575 /// 576 string toMathML(Lang lang) @safe pure nothrow /*TODO @nogc*/ 577 { 578 return lang.toHTML; 579 } 580 581 /** Markup Lang */ 582 enum MarkupLang : ubyte 583 { 584 unknown, // Unknown: ? 585 HTML, 586 MathML 587 } 588 589 /** Check if `lang` capitalize all its nouns include common nouns. 590 */ 591 bool capitalizesCommonNoun(Lang lang) @safe pure nothrow @nogc 592 { 593 return lang == Lang.de; 594 } 595 596 /// 597 @safe pure nothrow @nogc unittest 598 { 599 assert(Lang.de.capitalizesCommonNoun); 600 assert(!Lang.en.capitalizesCommonNoun); 601 }