Commit 9aef49e5 authored by Bjørnar Hansen's avatar Bjørnar Hansen Committed by Bjørnar Hansen
Browse files

Open source release.

parents
dist/
dist/l-sandbox/
cabal.sandbox.config
*.swp
*.o
*.hi
module Data.ISO639
( ISO639 (..)
, ISO639'1 (..)
, ISO639'2 (..)
, iso639'1ToLanguage
, languageToISO639'1
, iso639'2ToLanguage
, languageToISO639'2
) where
import Prelude (Show, Read, Eq, Ord, Enum, String, map, ($))
#if MIN_VERSION_base(4,3,0)
import Data.Tuple (swap)
#else
import Data.Tuple.HT (swap)
#endif
import Data.Map (Map)
import qualified Data.Map as M
-- | ISO649 codes.
-- TODO: ISO639'1 NO == ISO639'2 NOR
-- TODO: fromString
data ISO639 = ISO639'1 ISO639'1
| ISO639'2 ISO639'2
deriving (Show, Ord, Eq)
-- | ISO639-1 language codes.
data ISO639'1 = AA -- ^ Afar
| AB -- ^ Abkhazian
| AE -- ^ Avestan
| AF -- ^ Afrikaans
| AK -- ^ Akan
| AM -- ^ Amharic
| AN -- ^ Aragonese
| AR -- ^ Arabic
| AS -- ^ Assamese
| AV -- ^ Avaric
| AY -- ^ Aymara
| AZ -- ^ Azerbaijani
| BA -- ^ Bashkir
| BE -- ^ Belarusian
| BG -- ^ Bulgarian
| BH -- ^ Bihari languages
| BI -- ^ Bislama
| BM -- ^ Bambara
| BN -- ^ Bengali
| BO -- ^ Tibetan
| BR -- ^ Breton
| BS -- ^ Bosnian
| CA -- ^ Catalan
| CE -- ^ Chechen
| CH -- ^ Chamorro
| CO -- ^ Corsican
| CR -- ^ Cree
| CS -- ^ Czech
| CU -- ^ Church Slavic
| CV -- ^ Chuvash
| CY -- ^ Welsh
| DA -- ^ Danish
| DE -- ^ German
| DV -- ^ Dhivehi
| DZ -- ^ Dzongkha
| EE -- ^ Ewe
| EL -- ^ Modern Greek
| EN -- ^ English
| EO -- ^ Esperanto
| ES -- ^ Spanish
| ET -- ^ Estonian
| EU -- ^ Basque
| FA -- ^ Persian
| FF -- ^ Fulah
| FI -- ^ Finnish
| FJ -- ^ Fijian
| FO -- ^ Faroese
| FR -- ^ French
| FY -- ^ Western Frisian
| GA -- ^ Irish
| GD -- ^ Scottish Gaelic
| GL -- ^ Galician
| GN -- ^ Guarani
| GU -- ^ Gujarati
| GV -- ^ Manx
| HA -- ^ Hausa
| HE -- ^ Hebrew
| HI -- ^ Hindi
| HO -- ^ Hiri Motu
| HR -- ^ Croatian
| HT -- ^ Haitian
| HU -- ^ Hungarian
| HY -- ^ Armenian
| HZ -- ^ Herero
| IA -- ^ Interlingua
| ID -- ^ Indonesian
| IE -- ^ Interlingue
| IG -- ^ Igbo
| II -- ^ Sichuan Yi
| IK -- ^ Inupiaq
| IO -- ^ Ido
| IS -- ^ Icelandic
| IT -- ^ Italian
| IU -- ^ Inuktitut
| JA -- ^ Japanese
| JV -- ^ Javanese
| KA -- ^ Georgian
| KG -- ^ Kongo
| KI -- ^ Kikuyu
| KJ -- ^ Kuanyama
| KK -- ^ Kazakh
| KL -- ^ Kalaallisut
| KM -- ^ Central Khmer
| KN -- ^ Kannada
| KO -- ^ Korean
| KR -- ^ Kanuri
| KS -- ^ Kashmiri
| KU -- ^ Kurdish
| KV -- ^ Komi
| KW -- ^ Cornish
| KY -- ^ Kirghiz
| LA -- ^ Latin
| LB -- ^ Luxembourgish
| LG -- ^ Ganda
| LI -- ^ Limburgan
| LN -- ^ Lingala
| LO -- ^ Lao
| LT -- ^ Lithuanian
| LU -- ^ Luba-Katanga
| LV -- ^ Latvian
| MG -- ^ Malagasy
| MH -- ^ Marshallese
| MI -- ^ Maori
| MK -- ^ Macedonian
| ML -- ^ Malayalam
| MN -- ^ Mongolian
| MR -- ^ Marathi
| MS -- ^ Malay
| MT -- ^ Maltese
| MY -- ^ Burmese
| NA -- ^ Nauru
| NB -- ^ Norwegian Bokmål
| ND -- ^ North Ndebele
| NE -- ^ Nepali
| NG -- ^ Ndonga
| NL -- ^ Dutch
| NN -- ^ Norwegian Nynorsk
| NO -- ^ Norwegian
| NR -- ^ South Ndebele
| NV -- ^ Navajo
| NY -- ^ Nyanja
| OC -- ^ Occitan
| OJ -- ^ Ojibwa
| OM -- ^ Oromo
| OR -- ^ Oriya
| OS -- ^ Ossetian
| PA -- ^ Panjabi
| PI -- ^ Pali
| PL -- ^ Polish
| PS -- ^ Pushto
| PT -- ^ Portuguese
| QU -- ^ Quechua
| RM -- ^ Romansh
| RN -- ^ Rundi
| RO -- ^ Romanian
| RU -- ^ Russian
| RW -- ^ Kinyarwanda
| SA -- ^ Sanskrit
| SC -- ^ Sardinian
| SD -- ^ Sindhi
| SE -- ^ Northern Sami
| SG -- ^ Sango
| SH -- ^ Serbo-Croatian
| SI -- ^ Sinhala
| SK -- ^ Slovak
| SL -- ^ Slovenian
| SM -- ^ Samoan
| SN -- ^ Shona
| SO -- ^ Somali
| SQ -- ^ Albanian
| SR -- ^ Serbian
| SS -- ^ Swati
| ST -- ^ Southern Sotho
| SU -- ^ Sundanese
| SV -- ^ Swedish
| SW -- ^ Swahili
| TA -- ^ Tamil
| TE -- ^ Telugu
| TG -- ^ Tajik
| TH -- ^ Thai
| TI -- ^ Tigrinya
| TK -- ^ Turkmen
| TL -- ^ Tagalog
| TN -- ^ Tswana
| TO -- ^ Tonga
| TR -- ^ Turkish
| TS -- ^ Tsonga
| TT -- ^ Tatar
| TW -- ^ Twi
| TY -- ^ Tahitian
| UG -- ^ Uighur
| UK -- ^ Ukrainian
| UR -- ^ Urdu
| UZ -- ^ Uzbek
| VE -- ^ Venda
| VI -- ^ Vietnamese
| VO -- ^ Volapük
| WA -- ^ Walloon
| WO -- ^ Wolof
| XH -- ^ Xhosa
| YI -- ^ Yiddish
| YO -- ^ Yoruba
| ZA -- ^ Zhuang
| ZH -- ^ Chinese
| ZU -- ^ Zulu
deriving (Show, Read, Eq, Ord, Enum)
-- | Conversion table from ISO639-1 language code to language name.
iso639'1ToLanguage :: Map ISO639'1 String
iso639'1ToLanguage = M.fromList table
-- | Conversion table from a language name to an ISO639-1 code.
languageToISO639'1 :: Map String ISO639'1
languageToISO639'1 = M.fromList $ map swap table
-- | Mapping.
table :: [(ISO639'1, String)]
table = [ (AA, "Afar")
, (AB, "Abkhazian")
, (AE, "Avestan")
, (AF, "Afrikaans")
, (AK, "Akan")
, (AM, "Amharic")
, (AN, "Aragonese")
, (AR, "Arabic")
, (AS, "Assamese")
, (AV, "Avaric")
, (AY, "Aymara")
, (AZ, "Azerbaijani")
, (BA, "Bashkir")
, (BE, "Belarusian")
, (BG, "Bulgarian")
, (BH, "Bihari languages")
, (BI, "Bislama")
, (BM, "Bambara")
, (BN, "Bengali")
, (BO, "Tibetan")
, (BR, "Breton")
, (BS, "Bosnian")
, (CA, "Catalan")
, (CE, "Chechen")
, (CH, "Chamorro")
, (CO, "Corsican")
, (CR, "Cree")
, (CS, "Czech")
, (CU, "Church Slavic")
, (CV, "Chuvash")
, (CY, "Welsh")
, (DA, "Danish")
, (DE, "German")
, (DV, "Dhivehi")
, (DZ, "Dzongkha")
, (EE, "Ewe")
, (EL, "Modern Greek")
, (EN, "English")
, (EO, "Esperanto")
, (ES, "Spanish")
, (ET, "Estonian")
, (EU, "Basque")
, (FA, "Persian")
, (FF, "Fulah")
, (FI, "Finnish")
, (FJ, "Fijian")
, (FO, "Faroese")
, (FR, "French")
, (FY, "Western Frisian")
, (GA, "Irish")
, (GD, "Scottish Gaelic")
, (GL, "Galician")
, (GN, "Guarani")
, (GU, "Gujarati")
, (GV, "Manx")
, (HA, "Hausa")
, (HE, "Hebrew")
, (HI, "Hindi")
, (HO, "Hiri Motu")
, (HR, "Croatian")
, (HT, "Haitian")
, (HU, "Hungarian")
, (HY, "Armenian")
, (HZ, "Herero")
, (IA, "Interlingua")
, (ID, "Indonesian")
, (IE, "Interlingue")
, (IG, "Igbo")
, (II, "Sichuan Yi")
, (IK, "Inupiaq")
, (IO, "Ido")
, (IS, "Icelandic")
, (IT, "Italian")
, (IU, "Inuktitut")
, (JA, "Japanese")
, (JV, "Javanese")
, (KA, "Georgian")
, (KG, "Kongo")
, (KI, "Kikuyu")
, (KJ, "Kuanyama")
, (KK, "Kazakh")
, (KL, "Kalaallisut")
, (KM, "Central Khmer")
, (KN, "Kannada")
, (KO, "Korean")
, (KR, "Kanuri")
, (KS, "Kashmiri")
, (KU, "Kurdish")
, (KV, "Komi")
, (KW, "Cornish")
, (KY, "Kirghiz")
, (LA, "Latin")
, (LB, "Luxembourgish")
, (LG, "Ganda")
, (LI, "Limburgan")
, (LN, "Lingala")
, (LO, "Lao")
, (LT, "Lithuanian")
, (LU, "Luba-Katanga")
, (LV, "Latvian")
, (MG, "Malagasy")
, (MH, "Marshallese")
, (MI, "Maori")
, (MK, "Macedonian")
, (ML, "Malayalam")
, (MN, "Mongolian")
, (MR, "Marathi")
, (MS, "Malay")
, (MT, "Maltese")
, (MY, "Burmese")
, (NA, "Nauru")
, (NB, "Norwegian Bokmål")
, (ND, "North Ndebele")
, (NE, "Nepali")
, (NG, "Ndonga")
, (NL, "Dutch")
, (NN, "Norwegian Nynorsk")
, (NO, "Norwegian")
, (NR, "South Ndebele")
, (NV, "Navajo")
, (NY, "Nyanja")
, (OC, "Occitan")
, (OJ, "Ojibwa")
, (OM, "Oromo")
, (OR, "Oriya")
, (OS, "Ossetian")
, (PA, "Panjabi")
, (PI, "Pali")
, (PL, "Polish")
, (PS, "Pushto")
, (PT, "Portuguese")
, (QU, "Quechua")
, (RM, "Romansh")
, (RN, "Rundi")
, (RO, "Romanian")
, (RU, "Russian")
, (RW, "Kinyarwanda")
, (SA, "Sanskrit")
, (SC, "Sardinian")
, (SD, "Sindhi")
, (SE, "Northern Sami")
, (SG, "Sango")
, (SH, "Serbo-Croatian")
, (SI, "Sinhala")
, (SK, "Slovak")
, (SL, "Slovenian")
, (SM, "Samoan")
, (SN, "Shona")
, (SO, "Somali")
, (SQ, "Albanian")
, (SR, "Serbian")
, (SS, "Swati")
, (ST, "Southern Sotho")
, (SU, "Sundanese")
, (SV, "Swedish")
, (SW, "Swahili")
, (TA, "Tamil")
, (TE, "Telugu")
, (TG, "Tajik")
, (TH, "Thai")
, (TI, "Tigrinya")
, (TK, "Turkmen")
, (TL, "Tagalog")
, (TN, "Tswana")
, (TO, "Tonga")
, (TR, "Turkish")
, (TS, "Tsonga")
, (TT, "Tatar")
, (TW, "Twi")
, (TY, "Tahitian")
, (UG, "Uighur")
, (UK, "Ukrainian")
, (UR, "Urdu")
, (UZ, "Uzbek")
, (VE, "Venda")
, (VI, "Vietnamese")
, (VO, "Volapük")
, (WA, "Walloon")
, (WO, "Wolof")
, (XH, "Xhosa")
, (YI, "Yiddish")
, (YO, "Yoruba")
, (ZA, "Zhuang")
, (ZH, "Chinese")
, (ZU, "Zulu")
]
data ISO639'2 = AAR -- ^ Afar
| ABK -- ^ Abkhazian
| ACE -- ^ Acehnese, Achinese
| ACH -- ^ Acoli
| ADA -- ^ Adangme
| ADY -- ^ Adyghe, Adygei
| AFA -- ^ Afroasiatic languages
| AFH -- ^ Afrihili
| AFR -- ^ Afrikaans
| AIN -- ^ Ainu
| AKA -- ^ Akan
| AKK -- ^ Akkadian
| ALB -- ^ Albanian
| SQI -- ^ Albanian
| ALE -- ^ Aleut
| ALG -- ^ Algonquian languages
| ALT -- ^ Southern Altai
| AMH -- ^ Amharic
| ANG -- ^ Old English
| ANP -- ^ Angika
| APA -- ^ Apache languages
| ARA -- ^ Arabic
| ARC -- ^ Official Aramaic, Imperial Aramaic
| ARG -- ^ Aragonese
| ARM -- ^ Armenian
| HYE -- ^ Armenian
| ARN -- ^ Mapudungun, Mapuche
| ARP -- ^ Arapaho
| ART -- ^ Artificial languages
| ARW -- ^ Arawak
| ASM -- ^ Assamese
| AST -- ^ Asturian, Bable, Leonese, Asturleonese
| ATH -- ^ Athabaskan languages
| AUS -- ^ Australian languages
| AVA -- ^ Avaric
| AVE -- ^ Avestan
| AWA -- ^ Awadhi
| AYM -- ^ Aymara
| AZE -- ^ Azerbaijani
| BAD -- ^ Banda languages
| BAI -- ^ Bamileke languages
| BAK -- ^ Bashkir
| BAL -- ^ Baluchi
| BAM -- ^ Bambara
| BAN -- ^ Balinese
| BAQ -- ^ Basque
| EUS -- ^ Basque
| BAS -- ^ Basa
| BAT -- ^ Baltic languages
| BEJ -- ^ Beja, Bedawiyet
| BEL -- ^ Belarusian
| BEM -- ^ Bemba
| BEN -- ^ Bengali
| BER -- ^ Berber languages
| BHO -- ^ Bhojpuri
| BIH -- ^ Bihari languages
| BIK -- ^ Bikol
| BIN -- ^ Bini, Edo
| BIS -- ^ Bislama
| BLA -- ^ Siksika
| BNT -- ^ Bantu languages
| BOS -- ^ Bosnian
| BRA -- ^ Braj
| BRE -- ^ Breton
| BTK -- ^ Batak languages
| BUA -- ^ Buriat
| BUG -- ^ Buginese
| BUL -- ^ Bulgarian
| BUR -- ^ Burmese
| MYA -- ^ Burmese
| BYN -- ^ Blin, Bilin
| CAD -- ^ Caddo
| CAI -- ^ Central American Indian languages
| CAR -- ^ Galibi Carib
| CAT -- ^ Catalan, Valencian
| CAU -- ^ Caucasian languages
| CEB -- ^ Cebuano
| CEL -- ^ Celtic languages
| CHA -- ^ Chamorro
| CHB -- ^ Chibcha
| CHE -- ^ Chechen
| CHG -- ^ Chagatai
| CHI -- ^ Chinese
| ZHO -- ^ Chinese
| CHK -- ^ Chuukese
| CHM -- ^ Mari
| CHN -- ^ Chinook Jargon
| CHO -- ^ Choctaw
| CHP -- ^ Chipewyan, Dene Suline
| CHR -- ^ Cherokee
| CHU -- ^ Church Slavonic, Church Slavic, Old Church Slavonic, Old Slavonic, Old Bulgarian
| CHV -- ^ Chuvash
| CHY -- ^ Cheyenne
| CMC -- ^ Chamic languages
| COP -- ^ Coptic
| COR -- ^ Cornish
| COS -- ^ Corsican
| CPE -- ^ creoles and pidgins, English-based
| CPF -- ^ creoles and pidgins, French-based
| CPP -- ^ creoles and pidgins, Portuguese-based
| CRE -- ^ Cree
| CRH -- ^ Crimean Tatar, Crimean Turkish
| CRP -- ^ creoles and pidgins
| CSB -- ^ Kashubian
| CUS -- ^ Cushitic languages
| CZE -- ^ Czech
| CES -- ^ Czech
| DAK -- ^ Dakota
| DAN -- ^ Danish
| DAR -- ^ Dargwa
| DAY -- ^ Land Dayak languages
| DEL -- ^ Delaware
| DEN -- ^ Slave
| DGR -- ^ Dogrib
| DIN -- ^ Dinka
| DIV -- ^ Divehi, Dhivehi, Maldivian
| DOI -- ^ Dogri
| DRA -- ^ Dravidian languages
| DSB -- ^ Lower Sorbian
| DUA -- ^ Duala
| DUM -- ^ Middle Dutch
| DUT -- ^ Dutch, Flemish
| NLD -- ^ Dutch, Flemish
| DYU -- ^ Dyula
| DZO -- ^ Dzongkha
| EFI -- ^ Efik
| EGY -- ^ Ancient Egyptian
| EKA -- ^ Ekajuk
| ELX -- ^ Elamite
| ENG -- ^ English
| ENM -- ^ Middle English
| EPO -- ^ Esperanto
| EST -- ^ Estonian
| EWE -- ^ Ewe
| EWO -- ^ Ewondo
| FAN -- ^ Fang
| FAO -- ^ Faroese
| FAT -- ^ Fanti
| FIJ -- ^ Fijian
| FIL -- ^ Filipino, Pilipino
| FIN -- ^ Finnish
| FIU -- ^ Finno-Ugric languages
| FON -- ^ Fon
| FRE -- ^ French
| FRA -- ^ French
| FRM -- ^ Middle French
| FRO -- ^ Old French
| FRR -- ^ Northern Frisian
| FRS -- ^ Eastern Frisian
| FRY -- ^ Western Frisian
| FUL -- ^ Fulah
| FUR -- ^ Friulian
| GAA -- ^ Ga
| GAY -- ^ Gayo
| GBA -- ^ Gbaya
| GEM -- ^ Germanic languages
| GEO -- ^ Georgian
| KAT -- ^ Georgian
| GER -- ^ German
| DEU -- ^ German
| GEZ -- ^ Ge'ez
| GIL -- ^ Gilbertese, Kiribati
| GLA -- ^ Scottish Gaelic, Gaelic
| GLE -- ^ Irish
| GLG -- ^ Galician
| GLV -- ^ Manx
| GMH -- ^ Middle High German
| GOH -- ^ Old High German
| GON -- ^ Gondi
| GOR -- ^ Gorontalo
| GOT -- ^ Gothic
| GRB -- ^ Grebo
| GRC -- ^ Ancient Greek
| GRE -- ^ Modern Greek
| ELL -- ^ Modern Greek
| GRN -- ^ Guarani
| GSW -- ^ Swiss German, Alemannic, Alsatian
| GUJ -- ^ Gujarati
| GWI -- ^ Gwichʼin
| HAI -- ^ Haida
| HAT -- ^ Haitian Creole, Haitian
| HAU -- ^ Hausa
| HAW -- ^ Hawaiian
| HEB -- ^ Hebrew
| HER -- ^ Herero
| HIL -- ^ Hiligaynon
| HIM -- ^ Himachali languages
| HIN -- ^ Hindi
| HIT -- ^ Hittite
| HMN -- ^ Hmong
| HMO -- ^ Hiri Motu
| HRV -- ^ Croatian
| HSB -- ^ Upper Sorbian
| HUN -- ^ Hungarian
| HUP -- ^ Hupa
| IBA -- ^ Iban
| IBO -- ^ Igbo
| ICE -- ^ Icelandic
| ISL -- ^ Icelandic
| IDO -- ^ Ido
| III -- ^ Sichuan Yi, Nuosu
| IJO -- ^ Ijo languages
| IKU -- ^ Inuktitut
| ILE -- ^ Interlingue, Occidental
| ILO -- ^ Iloko
| INA -- ^ Interlingua
| INC -- ^ Indic languages