Skip to content

Instantly share code, notes, and snippets.

@proxpero
Created March 19, 2018 13:18
Show Gist options
  • Save proxpero/4c8e38a33844460663df3de141a8e726 to your computer and use it in GitHub Desktop.
Save proxpero/4c8e38a33844460663df3de141a8e726 to your computer and use it in GitHub Desktop.
A Swift 4.0 enum representing ISO 639-1 codes (used to classify languages)
// taken 2018-03-19 from wikipedia. https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
public enum Iso639_1: String {
case ab = "AB"
case aa = "AA"
case af = "AF"
case ak = "AK"
case sq = "SQ"
case am = "AM"
case ar = "AR"
case an = "AN"
case hy = "HY"
case `as` = "AS"
case av = "AV"
case ae = "AE"
case ay = "AY"
case az = "AZ"
case bm = "BM"
case ba = "BA"
case eu = "EU"
case be = "BE"
case bn = "BN"
case bh = "BH"
case bi = "BI"
case bs = "BS"
case br = "BR"
case bg = "BG"
case my = "MY"
case ca = "CA"
case ch = "CH"
case ce = "CE"
case ny = "NY"
case zh = "ZH"
case cv = "CV"
case kw = "KW"
case co = "CO"
case cr = "CR"
case hr = "HR"
case cs = "CS"
case da = "DA"
case dv = "DV"
case nl = "NL"
case dz = "DZ"
case en = "EN"
case eo = "EO"
case et = "ET"
case ee = "EE"
case fo = "FO"
case fj = "FJ"
case fi = "FI"
case fr = "FR"
case ff = "FF"
case gl = "GL"
case ka = "KA"
case de = "DE"
case el = "EL"
case gn = "GN"
case gu = "GU"
case ht = "HT"
case ha = "HA"
case he = "HE"
case hz = "HZ"
case hi = "HI"
case ho = "HO"
case hu = "HU"
case ia = "IA"
case id = "ID"
case ie = "IE"
case ga = "GA"
case ig = "IG"
case ik = "IK"
case io = "IO"
case `is` = "IS"
case it = "IT"
case iu = "IU"
case ja = "JA"
case jv = "JV"
case kl = "KL"
case kn = "KN"
case kr = "KR"
case ks = "KS"
case kk = "KK"
case km = "KM"
case ki = "KI"
case rw = "RW"
case ky = "KY"
case kv = "KV"
case kg = "KG"
case ko = "KO"
case ku = "KU"
case kj = "KJ"
case la = "LA"
case lb = "LB"
case lg = "LG"
case li = "LI"
case ln = "LN"
case lo = "LO"
case lt = "LT"
case lu = "LU"
case lv = "LV"
case gv = "GV"
case mk = "MK"
case mg = "MG"
case ms = "MS"
case ml = "ML"
case mt = "MT"
case mi = "MI"
case mr = "MR"
case mh = "MH"
case mn = "MN"
case na = "NA"
case nv = "NV"
case nd = "ND"
case ne = "NE"
case ng = "NG"
case nb = "NB"
case nn = "NN"
case no = "NO"
case ii = "II"
case nr = "NR"
case oc = "OC"
case oj = "OJ"
case cu = "CU"
case om = "OM"
case or = "OR"
case os = "OS"
case pa = "PA"
case pi = "PI"
case fa = "FA"
case pox = "POX"
case pl = "PL"
case ps = "PS"
case pt = "PT"
case qu = "QU"
case rm = "RM"
case rn = "RN"
case ro = "RO"
case ru = "RU"
case sa = "SA"
case sc = "SC"
case sd = "SD"
case se = "SE"
case sm = "SM"
case sg = "SG"
case sr = "SR"
case gd = "GD"
case sn = "SN"
case si = "SI"
case sk = "SK"
case sl = "SL"
case so = "SO"
case st = "ST"
case es = "ES"
case su = "SU"
case sw = "SW"
case ss = "SS"
case sv = "SV"
case ta = "TA"
case te = "TE"
case tg = "TG"
case th = "TH"
case ti = "TI"
case bo = "BO"
case tk = "TK"
case tl = "TL"
case tn = "TN"
case to = "TO"
case tr = "TR"
case ts = "TS"
case tt = "TT"
case tw = "TW"
case ty = "TY"
case ug = "UG"
case uk = "UK"
case ur = "UR"
case uz = "UZ"
case ve = "VE"
case vi = "VI"
case vo = "VO"
case wa = "WA"
case cy = "CY"
case wo = "WO"
case fy = "FY"
case xh = "XH"
case yi = "YI"
case yo = "YO"
case za = "ZA"
case zu = "ZU"
}
extension Iso639_1 {
public static var all: [Iso639_1] {
return [.ab, .aa, .af, .ak, .sq, .am, .ar, .an, .hy, .as, .av, .ae, .ay, .az, .bm, .ba, .eu, .be, .bn, .bh, .bi, .bs, .br, .bg, .my, .ca, .ch, .ce, .ny, .zh, .cv, .kw, .co, .cr, .hr, .cs, .da, .dv, .nl, .dz, .en, .eo, .et, .ee, .fo, .fj, .fi, .fr, .ff, .gl, .ka, .de, .el, .gn, .gu, .ht, .ha, .he, .hz, .hi, .ho, .hu, .ia, .id, .ie, .ga, .ig, .ik, .io, .is, .it, .iu, .ja, .jv, .kl, .kn, .kr, .ks, .kk, .km, .ki, .rw, .ky, .kv, .kg, .ko, .ku, .kj, .la, .lb, .lg, .li, .ln, .lo, .lt, .lu, .lv, .gv, .mk, .mg, .ms, .ml, .mt, .mi, .mr, .mh, .mn, .na, .nv, .nd, .ne, .ng, .nb, .nn, .no, .ii, .nr, .oc, .oj, .cu, .om, .or, .os, .pa, .pi, .fa, .pox, .pl, .ps, .pt, .qu, .rm, .rn, .ro, .ru, .sa, .sc, .sd, .se, .sm, .sg, .sr, .gd, .sn, .si, .sk, .sl, .so, .st, .es, .su, .sw, .ss, .sv, .ta, .te, .tg, .th, .ti, .bo, .tk, .tl, .tn, .to, .tr, .ts, .tt, .tw, .ty, .ug, .uk, .ur, .uz, .ve, .vi, .vo, .wa, .cy, .wo, .fy, .xh, .yi, .yo, .za, .zu]
}
public var language: String {
switch self {
case .ab: return "Abkhazian"
case .aa: return "Afar"
case .af: return "Afrikaans"
case .ak: return "Akan"
case .sq: return "Albanian"
case .am: return "Amharic"
case .ar: return "Arabic"
case .an: return "Aragonese"
case .hy: return "Armenian"
case .as: return "Assamese"
case .av: return "Avaric"
case .ae: return "Avestan"
case .ay: return "Aymara"
case .az: return "Azerbaijani"
case .bm: return "Bambara"
case .ba: return "Bashkir"
case .eu: return "Basque"
case .be: return "Belarusian"
case .bn: return "Bengali"
case .bh: return "Bihari languages"
case .bi: return "Bislama"
case .bs: return "Bosnian"
case .br: return "Breton"
case .bg: return "Bulgarian"
case .my: return "Burmese"
case .ca: return "Catalan, Valencian"
case .ch: return "Chamorro"
case .ce: return "Chechen"
case .ny: return "Chichewa, Chewa, Nyanja"
case .zh: return "Chinese"
case .cv: return "Chuvash"
case .kw: return "Cornish"
case .co: return "Corsican"
case .cr: return "Cree"
case .hr: return "Croatian"
case .cs: return "Czech"
case .da: return "Danish"
case .dv: return "Divehi, Dhivehi, Maldivian"
case .nl: return "Dutch, Flemish"
case .dz: return "Dzongkha"
case .en: return "English"
case .eo: return "Esperanto"
case .et: return "Estonian"
case .ee: return "Ewe"
case .fo: return "Faroese"
case .fj: return "Fijian"
case .fi: return "Finnish"
case .fr: return "French"
case .ff: return "Fulah"
case .gl: return "Galician"
case .ka: return "Georgian"
case .de: return "German"
case .el: return "Greek (modern),"
case .gn: return "Guaraní"
case .gu: return "Gujarati"
case .ht: return "Haitian, Haitian Creole"
case .ha: return "Hausa"
case .he: return "Hebrew (modern),"
case .hz: return "Herero"
case .hi: return "Hindi"
case .ho: return "Hiri Motu"
case .hu: return "Hungarian"
case .ia: return "Interlingua"
case .id: return "Indonesian"
case .ie: return "Interlingue"
case .ga: return "Irish"
case .ig: return "Igbo"
case .ik: return "Inupiaq"
case .io: return "Ido"
case .is: return "Icelandic"
case .it: return "Italian"
case .iu: return "Inuktitut"
case .ja: return "Japanese"
case .jv: return "Javanese"
case .kl: return "Kalaallisut, Greenlandic"
case .kn: return "Kannada"
case .kr: return "Kanuri"
case .ks: return "Kashmiri"
case .kk: return "Kazakh"
case .km: return "Central Khmer"
case .ki: return "Kikuyu, Gikuyu"
case .rw: return "Kinyarwanda"
case .ky: return "Kirghiz, Kyrgyz"
case .kv: return "Komi"
case .kg: return "Kongo"
case .ko: return "Korean"
case .ku: return "Kurdish"
case .kj: return "Kuanyama, Kwanyama"
case .la: return "Latin"
case .lb: return "Luxembourgish, Letzeburgesch"
case .lg: return "Ganda"
case .li: return "Limburgan, Limburger, Limburgish"
case .ln: return "Lingala"
case .lo: return "Lao"
case .lt: return "Lithuanian"
case .lu: return "Luba-Katanga"
case .lv: return "Latvian"
case .gv: return "Manx"
case .mk: return "Macedonian"
case .mg: return "Malagasy"
case .ms: return "Malay"
case .ml: return "Malayalam"
case .mt: return "Maltese"
case .mi: return "Maori"
case .mr: return "Marathi"
case .mh: return "Marshallese"
case .mn: return "Mongolian"
case .na: return "Nauru"
case .nv: return "Navajo, Navaho"
case .nd: return "North Ndebele"
case .ne: return "Nepali"
case .ng: return "Ndonga"
case .nb: return "Norwegian Bokmål"
case .nn: return "Norwegian Nynorsk"
case .no: return "Norwegian"
case .ii: return "Sichuan Yi, Nuosu"
case .nr: return "South Ndebele"
case .oc: return "Occitan"
case .oj: return "Ojibwa"
case .cu: return "Church Slavic, Church Slavonic, Old Church Slavonic, Old Slavonic, Old Bulgarian"
case .om: return "Oromo"
case .or: return "Oriya"
case .os: return "Ossetian, Ossetic"
case .pa: return "Panjabi, Punjabi"
case .pi: return "Pali"
case .fa: return "Persian"
case .pox: return "Polabian"
case .pl: return "Polish"
case .ps: return "Pashto, Pushto"
case .pt: return "Portuguese"
case .qu: return "Quechua"
case .rm: return "Romansh"
case .rn: return "Rundi"
case .ro: return "Romanian, Moldavian, Moldovan"
case .ru: return "Russian"
case .sa: return "Sanskrit"
case .sc: return "Sardinian"
case .sd: return "Sindhi"
case .se: return "Northern Sami"
case .sm: return "Samoan"
case .sg: return "Sango"
case .sr: return "Serbian"
case .gd: return "Gaelic, Scottish Gaelic"
case .sn: return "Shona"
case .si: return "Sinhala, Sinhalese"
case .sk: return "Slovak"
case .sl: return "Slovenian"
case .so: return "Somali"
case .st: return "Southern Sotho"
case .es: return "Spanish, Castilian"
case .su: return "Sundanese"
case .sw: return "Swahili"
case .ss: return "Swati"
case .sv: return "Swedish"
case .ta: return "Tamil"
case .te: return "Telugu"
case .tg: return "Tajik"
case .th: return "Thai"
case .ti: return "Tigrinya"
case .bo: return "Tibetan"
case .tk: return "Turkmen"
case .tl: return "Tagalog"
case .tn: return "Tswana"
case .to: return "Tonga (Tonga Islands),"
case .tr: return "Turkish"
case .ts: return "Tsonga"
case .tt: return "Tatar"
case .tw: return "Twi"
case .ty: return "Tahitian"
case .ug: return "Uighur, Uyghur"
case .uk: return "Ukrainian"
case .ur: return "Urdu"
case .uz: return "Uzbek"
case .ve: return "Venda"
case .vi: return "Vietnamese"
case .vo: return "Volapük"
case .wa: return "Walloon"
case .cy: return "Welsh"
case .wo: return "Wolof"
case .fy: return "Western Frisian"
case .xh: return "Xhosa"
case .yi: return "Yiddish"
case .yo: return "Yoruba"
case .za: return "Zhuang, Chuang"
case .zu: return "Zulu"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment