# -*- coding: iso-8859-2 -*-
LanguageCodes = { }

LanguageCodes["aar"] = LanguageCodes["aa"] = ("Afar", "Hamitic")
LanguageCodes["abk"] = LanguageCodes["ab"] = ("Abkhazian", "Ibero-caucasian")
LanguageCodes["ace"] = ("Achinese", "")
LanguageCodes["ach"] = ("Acoli", "")
LanguageCodes["ada"] = ("Adangme", "")
LanguageCodes["afa"] = ("Afro-Asiatic (Other)", "")
LanguageCodes["afh"] = ("Afrihili", "")
LanguageCodes["afr"] = LanguageCodes["af"] = ("Afrikaans", "Germanic")
LanguageCodes["aka"] = ("Akan", "")
LanguageCodes["akk"] = ("Akkadian", "")
LanguageCodes["ale"] = ("Aleut", "")
LanguageCodes["alg"] = ("Algonquian languages", "")
LanguageCodes["amh"] = LanguageCodes["am"] = ("Amharic", "Semitic")
LanguageCodes["ang"] = ("English, Old (ca. 450-1100)", "")
LanguageCodes["apa"] = ("Apache languages", "")
LanguageCodes["ara"] = LanguageCodes["ar"] = ("Arabic", "Semitic")
LanguageCodes["arc"] = ("Aramaic", "")
LanguageCodes["arn"] = ("Araucanian", "")
LanguageCodes["arp"] = ("Arapaho", "")
LanguageCodes["art"] = ("Artificial (Other)", "")
LanguageCodes["arw"] = ("Arawak", "")
LanguageCodes["asm"] = LanguageCodes["as"] = ("Assamese", "Indian")
LanguageCodes["ath"] = ("Athapascan languages", "")
LanguageCodes["aus"] = ("Australian languages", "")
LanguageCodes["ava"] = ("Avaric", "")
LanguageCodes["ave"] = LanguageCodes["ae"] = ("Avestan", "")
LanguageCodes["awa"] = ("Awadhi", "")
LanguageCodes["aym"] = LanguageCodes["ay"] = ("Aymara", "Amerindian")
LanguageCodes["aze"] = LanguageCodes["az"] = ("Azerbaijani", "Turkic/altaic")
LanguageCodes["bad"] = ("Banda", "")
LanguageCodes["bai"] = ("Bamileke languages", "")
LanguageCodes["bak"] = LanguageCodes["ba"] = ("Bashkir", "Turkic/altaic")
LanguageCodes["bal"] = ("Baluchi", "")
LanguageCodes["bam"] = ("Bambara", "")
LanguageCodes["ban"] = ("Balinese", "")
LanguageCodes["bas"] = ("Basa", "")
LanguageCodes["bat"] = ("Baltic (Other)", "")
LanguageCodes["bej"] = ("Beja", "")
LanguageCodes["bel"] = LanguageCodes["be"] = ("Belarusian", "Slavic")
LanguageCodes["bem"] = ("Bemba", "")
LanguageCodes["ben"] = LanguageCodes["bn"] = ("Bengali", "Indian")
LanguageCodes["ber"] = ("Berber (Other)", "")
LanguageCodes["bho"] = ("Bhojpuri", "")
LanguageCodes["bih"] = LanguageCodes["bh"] = ("Bihari", "Indian")
LanguageCodes["bik"] = ("Bikol", "")
LanguageCodes["bin"] = ("Bini", "")
LanguageCodes["bis"] = LanguageCodes["bi"] = ("Bislama", "")
LanguageCodes["bla"] = ("Siksika", "")
LanguageCodes["bnt"] = ("Bantu (Other)", "")
LanguageCodes["bod"] = LanguageCodes["tib"] = LanguageCodes["bo"] = ("Tibetan", "Asian")
LanguageCodes["bos"] = LanguageCodes["bs"] = ("Bosnian", "")
LanguageCodes["bra"] = ("Braj", "")
LanguageCodes["bre"] = LanguageCodes["br"] = ("Breton", "Celtic")
LanguageCodes["btk"] = ("Batak (Indonesia)", "")
LanguageCodes["bua"] = ("Buriat", "")
LanguageCodes["bug"] = ("Buginese", "")
LanguageCodes["bul"] = LanguageCodes["bg"] = ("Bulgarian", "Slavic")
LanguageCodes["cad"] = ("Caddo", "")
LanguageCodes["cai"] = ("Central American Indian (Other)", "")
LanguageCodes["car"] = ("Carib", "")
LanguageCodes["cat"] = LanguageCodes["ca"] = ("Catalan", "Romance")
LanguageCodes["cau"] = ("Caucasian (Other)", "")
LanguageCodes["ceb"] = ("Cebuano", "")
LanguageCodes["cel"] = ("Celtic (Other)", "")
LanguageCodes["ces"] = LanguageCodes["cze"] = LanguageCodes["cs"] = ("Czech", "Slavic")
LanguageCodes["cha"] = LanguageCodes["ch"] = ("Chamorro", "")
LanguageCodes["chb"] = ("Chibcha", "")
LanguageCodes["che"] = LanguageCodes["ce"] = ("Chechen", "")
LanguageCodes["chg"] = ("Chagatai", "")
LanguageCodes["chk"] = ("Chuukese", "")
LanguageCodes["chm"] = ("Mari", "")
LanguageCodes["chn"] = ("Chinook jargon", "")
LanguageCodes["cho"] = ("Choctaw", "")
LanguageCodes["chp"] = ("Chipewyan", "")
LanguageCodes["chr"] = ("Cherokee", "")
LanguageCodes["chu"] = LanguageCodes["cu"] = ("Church Slavic", "")
LanguageCodes["chv"] = LanguageCodes["cv"] = ("Chuvash", "")
LanguageCodes["chy"] = ("Cheyenne", "")
LanguageCodes["cmc"] = ("Chamic languages", "")
LanguageCodes["cop"] = ("Coptic", "")
LanguageCodes["cor"] = LanguageCodes["kw"] = ("Cornish", "")
LanguageCodes["cos"] = LanguageCodes["co"] = ("Corsican", "Romance")
LanguageCodes["cpe"] = ("Creoles and pidgins, English based (Other)", "")
LanguageCodes["cpf"] = ("Creoles and pidgins, French-based (Other)", "")
LanguageCodes["cpp"] = ("Creoles and pidgins, Portuguese-based (Other)", "")
LanguageCodes["cre"] = ("Cree", "")
LanguageCodes["crp"] = ("Creoles and pidgins (Other)", "")
LanguageCodes["cus"] = ("Cushitic (Other)", "")
LanguageCodes["cym"] = LanguageCodes["wel"] = LanguageCodes["cy"] = ("Welsh", "Celtic")
LanguageCodes["dak"] = ("Dakota", "")
LanguageCodes["dan"] = LanguageCodes["da"] = ("Danish", "Germanic")
LanguageCodes["day"] = ("Dayak", "")
LanguageCodes["del"] = ("Delaware", "")
LanguageCodes["den"] = ("Slave (Athapascan)", "")
LanguageCodes["deu"] = LanguageCodes["ger"] = LanguageCodes["de"] = ("German", "Germanic")
LanguageCodes["dgr"] = ("Dogrib", "")
LanguageCodes["din"] = ("Dinka", "")
LanguageCodes["div"] = ("Divehi", "")
LanguageCodes["doi"] = ("Dogri", "")
LanguageCodes["dra"] = ("Dravidian (Other)", "")
LanguageCodes["dua"] = ("Duala", "")
LanguageCodes["dum"] = ("Dutch, Middle (ca. 1050-1350)", "")
LanguageCodes["dyu"] = ("Dyula", "")
LanguageCodes["dzo"] = LanguageCodes["dz"] = ("Dzongkha", "Asian")
LanguageCodes["efi"] = ("Efik", "")
LanguageCodes["egy"] = ("Egyptian (Ancient)", "")
LanguageCodes["eka"] = ("Ekajuk", "")
LanguageCodes["ell"] = LanguageCodes["gre"] = LanguageCodes["el"] = ("Greek, Modern (1453-)", "Latin/greek")
LanguageCodes["elx"] = ("Elamite", "")
LanguageCodes["eng"] = LanguageCodes["en"] = ("English", "Germanic")
LanguageCodes["enm"] = ("English, Middle (1100-1500)", "")
LanguageCodes["epo"] = LanguageCodes["eo"] = ("Esperanto", "International aux.")
LanguageCodes["est"] = LanguageCodes["et"] = ("Estonian", "Finno-ugric")
LanguageCodes["eus"] = LanguageCodes["baq"] = LanguageCodes["eu"] = ("Basque", "Basque")
LanguageCodes["ewe"] = ("Ewe", "")
LanguageCodes["ewo"] = ("Ewondo", "")
LanguageCodes["fan"] = ("Fang", "")
LanguageCodes["fao"] = LanguageCodes["fo"] = ("Faroese", "Germanic")
LanguageCodes["fas"] = LanguageCodes["per"] = LanguageCodes["fa"] = ("Persian", "")
LanguageCodes["fat"] = ("Fanti", "")
LanguageCodes["fij"] = LanguageCodes["fj"] = ("Fijian", "Oceanic/indonesian")
LanguageCodes["fin"] = LanguageCodes["fi"] = ("Finnish", "Finno-ugric")
LanguageCodes["fiu"] = ("Finno-Ugrian (Other)", "")
LanguageCodes["fon"] = ("Fon", "")
LanguageCodes["fra"] = LanguageCodes["fre"] = LanguageCodes["fr"] = ("French", "Romance")
LanguageCodes["frm"] = ("French, Middle (ca. 1400-1600)", "")
LanguageCodes["fro"] = ("French, Old (842-ca. 1400)", "")
LanguageCodes["fry"] = LanguageCodes["fy"] = ("Frisian", "Germanic")
LanguageCodes["ful"] = ("Fulah", "")
LanguageCodes["fur"] = ("Friulian", "")
LanguageCodes["gaa"] = ("Ga", "")
LanguageCodes["gay"] = ("Gayo", "")
LanguageCodes["gba"] = ("Gbaya", "")
LanguageCodes["gem"] = ("Germanic (Other)", "")
LanguageCodes["gez"] = ("Geez", "")
LanguageCodes["gil"] = ("Gilbertese", "")
LanguageCodes["gla"] = LanguageCodes["gd"] = ("Gaelic (Scots)", "Celtic")
LanguageCodes["gle"] = LanguageCodes["ga"] = ("Irish", "Celtic")
LanguageCodes["glg"] = LanguageCodes["gl"] = ("Gallegan", "Romance")
LanguageCodes["glv"] = LanguageCodes["gv"] = ("Manx", "")
LanguageCodes["gmh"] = ("German, Middle High (ca. 1050-1500)", "")
LanguageCodes["goh"] = ("German, Old High (ca. 750-1050)", "")
LanguageCodes["gon"] = ("Gondi", "")
LanguageCodes["gor"] = ("Gorontalo", "")
LanguageCodes["got"] = ("Gothic", "")
LanguageCodes["grb"] = ("Grebo", "")
LanguageCodes["grc"] = ("Greek, Ancient (to 1453)", "")
LanguageCodes["grn"] = LanguageCodes["gn"] = ("Guarani", "Amerindian")
LanguageCodes["guj"] = LanguageCodes["gu"] = ("Gujarati", "Indian")
LanguageCodes["gwi"] = ("Gwich´in", "")
LanguageCodes["hai"] = ("Haida", "")
LanguageCodes["hau"] = LanguageCodes["ha"] = ("Hausa", "Negro-african")
LanguageCodes["haw"] = ("Hawaiian", "")
LanguageCodes["heb"] = LanguageCodes["he"] = ("Hebrew", "")
LanguageCodes["her"] = LanguageCodes["hz"] = ("Herero", "")
LanguageCodes["hil"] = ("Hiligaynon", "")
LanguageCodes["him"] = ("Himachali", "")
LanguageCodes["hin"] = LanguageCodes["hi"] = ("Hindi", "Indian")
LanguageCodes["hit"] = ("Hittite", "")
LanguageCodes["hmn"] = ("Hmong", "")
LanguageCodes["hmo"] = LanguageCodes["ho"] = ("Hiri Motu", "")
LanguageCodes["hrv"] = LanguageCodes["scr"] = LanguageCodes["hr"] = ("Croatian", "Slavic")
LanguageCodes["hun"] = LanguageCodes["hu"] = ("Hungarian", "Finno-ugric")
LanguageCodes["hup"] = ("Hupa", "")
LanguageCodes["hye"] = LanguageCodes["arm"] = LanguageCodes["hy"] = ("Armenian", "Indo-european (other)")
LanguageCodes["iba"] = ("Iban", "")
LanguageCodes["ibo"] = ("Igbo", "")
LanguageCodes["ijo"] = ("Ijo", "")
LanguageCodes["iku"] = LanguageCodes["iu"] = ("Inuktitut", "")
LanguageCodes["ile"] = LanguageCodes["ie"] = ("Interlingue", "International aux.")
LanguageCodes["ilo"] = ("Iloko", "")
LanguageCodes["ina"] = LanguageCodes["ia"] = ("Interlingua (International Auxiliary Language Association)", "International aux.")
LanguageCodes["inc"] = ("Indic (Other)", "")
LanguageCodes["ind"] = LanguageCodes["id"] = ("Indonesian", "")
LanguageCodes["ine"] = ("Indo-European (Other)", "")
LanguageCodes["ipk"] = LanguageCodes["ik"] = ("Inupiaq", "Eskimo")
LanguageCodes["ira"] = ("Iranian (Other)", "")
LanguageCodes["iro"] = ("Iroquoian languages", "")
LanguageCodes["isl"] = LanguageCodes["ice"] = LanguageCodes["is"] = ("Icelandic", "Germanic")
LanguageCodes["ita"] = LanguageCodes["it"] = ("Italian", "Romance")
LanguageCodes["jaw"] = LanguageCodes["jav"] = LanguageCodes["jw"] = ("Javanese", "")
LanguageCodes["jpn"] = LanguageCodes["ja"] = ("Japanese", "Asian")
LanguageCodes["jpr"] = ("Judeo-Persian", "")
LanguageCodes["kaa"] = ("Kara-Kalpak", "")
LanguageCodes["kab"] = ("Kabyle", "")
LanguageCodes["kac"] = ("Kachin", "")
LanguageCodes["kal"] = LanguageCodes["kl"] = ("Kalaallisut", "Eskimo")
LanguageCodes["kam"] = ("Kamba", "")
LanguageCodes["kan"] = LanguageCodes["kn"] = ("Kannada", "Dravidian")
LanguageCodes["kar"] = ("Karen", "")
LanguageCodes["kas"] = LanguageCodes["ks"] = ("Kashmiri", "Indian")
LanguageCodes["kat"] = LanguageCodes["geo"] = LanguageCodes["ka"] = ("Georgian", "Ibero-caucasian")
LanguageCodes["kau"] = ("Kanuri", "")
LanguageCodes["kaw"] = ("Kawi", "")
LanguageCodes["kaz"] = LanguageCodes["kk"] = ("Kazakh", "Turkic/altaic")
LanguageCodes["kha"] = ("Khasi", "")
LanguageCodes["khi"] = ("Khoisan (Other)", "")
LanguageCodes["khm"] = LanguageCodes["km"] = ("Khmer", "Asian")
LanguageCodes["kho"] = ("Khotanese", "")
LanguageCodes["kik"] = LanguageCodes["ki"] = ("Kikuyu", "")
LanguageCodes["kin"] = LanguageCodes["rw"] = ("Kinyarwanda", "Negro-african")
LanguageCodes["kir"] = LanguageCodes["ky"] = ("Kirghiz", "Turkic/altaic")
LanguageCodes["kmb"] = ("Kimbundu", "")
LanguageCodes["kok"] = ("Konkani", "")
LanguageCodes["kom"] = LanguageCodes["kv"] = ("Komi", "")
LanguageCodes["kon"] = ("Kongo", "")
LanguageCodes["kor"] = LanguageCodes["ko"] = ("Korean", "Asian")
LanguageCodes["kos"] = ("Kosraean", "")
LanguageCodes["kpe"] = ("Kpelle", "")
LanguageCodes["kro"] = ("Kru", "")
LanguageCodes["kru"] = ("Kurukh", "")
LanguageCodes["kum"] = ("Kumyk", "")
LanguageCodes["kur"] = LanguageCodes["ku"] = ("Kurdish", "Iranian")
LanguageCodes["kut"] = ("Kutenai", "")
LanguageCodes["lad"] = ("Ladino", "")
LanguageCodes["lah"] = ("Lahnda", "")
LanguageCodes["lam"] = ("Lamba", "")
LanguageCodes["lao"] = LanguageCodes["lo"] = ("Lao", "Asian")
LanguageCodes["lat"] = LanguageCodes["la"] = ("Latin", "Latin/greek")
LanguageCodes["lav"] = LanguageCodes["lv"] = ("Latvian", "Baltic")
LanguageCodes["lez"] = ("Lezghian", "")
LanguageCodes["lin"] = LanguageCodes["ln"] = ("Lingala", "Negro-african")
LanguageCodes["lit"] = LanguageCodes["lt"] = ("Lithuanian", "Baltic")
LanguageCodes["lol"] = ("Mongo", "")
LanguageCodes["loz"] = ("Lozi", "")
LanguageCodes["ltz"] = LanguageCodes["lb"] = ("Letzeburgesch", "")
LanguageCodes["lua"] = ("Luba-Lulua", "")
LanguageCodes["lub"] = ("Luba-Katanga", "")
LanguageCodes["lug"] = ("Ganda", "")
LanguageCodes["lui"] = ("Luiseno", "")
LanguageCodes["lun"] = ("Lunda", "")
LanguageCodes["luo"] = ("Luo (Kenya and Tanzania)", "")
LanguageCodes["lus"] = ("lushai", "")
LanguageCodes["mad"] = ("Madurese", "")
LanguageCodes["mag"] = ("Magahi", "")
LanguageCodes["mah"] = LanguageCodes["mh"] = ("Marshall", "")
LanguageCodes["mai"] = ("Maithili", "")
LanguageCodes["mak"] = ("Makasar", "")
LanguageCodes["mal"] = LanguageCodes["ml"] = ("Malayalam", "Dravidian")
LanguageCodes["man"] = ("Mandingo", "")
LanguageCodes["map"] = ("Austronesian (Other)", "")
LanguageCodes["mar"] = LanguageCodes["mr"] = ("Marathi", "Indian")
LanguageCodes["mas"] = ("Masai", "")
LanguageCodes["mdr"] = ("Mandar", "")
LanguageCodes["men"] = ("Mende", "")
LanguageCodes["mga"] = ("Irish, Middle (900-1200)", "")
LanguageCodes["mic"] = ("Micmac", "")
LanguageCodes["min"] = ("Minangkabau", "")
LanguageCodes["mis"] = ("Miscellaneous languages", "")
LanguageCodes["mkd"] = LanguageCodes["mac"] = LanguageCodes["mk"] = ("Macedonian", "Slavic")
LanguageCodes["mkh"] = ("Mon-Khmer (Other)", "")
LanguageCodes["mlg"] = LanguageCodes["mg"] = ("Malagasy", "Oceanic/indonesian")
LanguageCodes["mlt"] = LanguageCodes["mt"] = ("Maltese", "Semitic")
LanguageCodes["mnc"] = ("Manchu", "")
LanguageCodes["mni"] = ("Manipuri", "")
LanguageCodes["mno"] = ("Manobo languages", "")
LanguageCodes["moh"] = ("Mohawk", "")
LanguageCodes["mol"] = LanguageCodes["mo"] = ("Moldavian", "Romance")
LanguageCodes["mon"] = LanguageCodes["mn"] = ("Mongolian", "")
LanguageCodes["mos"] = ("Mossi", "")
LanguageCodes["mri"] = LanguageCodes["mao"] = LanguageCodes["mi"] = ("Maori", "Oceanic/indonesian")
LanguageCodes["msa"] = LanguageCodes["may"] = LanguageCodes["ms"] = ("Malay", "Oceanic/indonesian")
LanguageCodes["mul"] = ("Multiple languages", "")
LanguageCodes["mun"] = ("Munda languages", "")
LanguageCodes["mus"] = ("Creek", "")
LanguageCodes["mwr"] = ("Marwari", "")
LanguageCodes["mya"] = LanguageCodes["bur"] = LanguageCodes["my"] = ("Burmese", "Asian")
LanguageCodes["myn"] = ("Mayan languages", "")
LanguageCodes["nah"] = ("Nahuatl", "")
LanguageCodes["nai"] = ("North American Indian", "")
LanguageCodes["nau"] = LanguageCodes["na"] = ("Nauru", "")
LanguageCodes["nav"] = LanguageCodes["nv"] = ("Navajo", "")
LanguageCodes["nbl"] = LanguageCodes["nr"] = ("Ndebele, South", "")
LanguageCodes["nde"] = LanguageCodes["nd"] = ("Ndebele, North", "")
LanguageCodes["ndo"] = LanguageCodes["ng"] = ("Ndonga", "")
LanguageCodes["nds"] = ("Low German; Low Saxon; German, Low; Saxon, Low", "")
LanguageCodes["nep"] = LanguageCodes["ne"] = ("Nepali", "Indian")
LanguageCodes["new"] = ("Newari", "")
LanguageCodes["nia"] = ("Nias", "")
LanguageCodes["nic"] = ("Niger-Kordofanian (Other)", "")
LanguageCodes["niu"] = ("Niuean", "")
LanguageCodes["nld"] = LanguageCodes["dut"] = LanguageCodes["nl"] = ("Dutch", "Germanic")
LanguageCodes["nno"] = LanguageCodes["nn"] = ("Norwegian Nynorsk", "")
LanguageCodes["nob"] = LanguageCodes["nb"] = ("Norwegian Bokmċl", "")
LanguageCodes["non"] = ("Norse, Old", "")
LanguageCodes["nor"] = LanguageCodes["no"] = ("Norwegian", "Germanic")
LanguageCodes["nso"] = ("Sotho, Northern", "")
LanguageCodes["nub"] = ("Nubian languages", "")
LanguageCodes["nya"] = LanguageCodes["ny"] = ("Chichewa; Nyanja", "")
LanguageCodes["nym"] = ("Nyamwezi", "")
LanguageCodes["nyn"] = ("Nyankole", "")
LanguageCodes["nyo"] = ("Nyoro", "")
LanguageCodes["nzi"] = ("Nzima", "")
LanguageCodes["oci"] = LanguageCodes["oc"] = ("Occitan (post 1500); Provençal", "Romance")
LanguageCodes["oji"] = ("Ojibwa", "")
LanguageCodes["ori"] = LanguageCodes["or"] = ("Oriya", "Indian")
LanguageCodes["orm"] = LanguageCodes["om"] = ("Oromo", "Hamitic")
LanguageCodes["osa"] = ("Osage", "")
LanguageCodes["oss"] = LanguageCodes["os"] = ("Ossetian; Ossetic", "")
LanguageCodes["ota"] = ("Turkish, Ottoman (1500-1928)", "")
LanguageCodes["oto"] = ("Otomian languages", "")
LanguageCodes["paa"] = ("Papuan (Other)", "")
LanguageCodes["pag"] = ("Pangasinan", "")
LanguageCodes["pal"] = ("Pahlavi", "")
LanguageCodes["pam"] = ("Pampanga", "")
LanguageCodes["pan"] = LanguageCodes["pa"] = ("Panjabi", "Indian")
LanguageCodes["pap"] = ("Papiamento", "")
LanguageCodes["pau"] = ("Palauan", "")
LanguageCodes["peo"] = ("Persian, Old (ca. 600-400 b.c.)", "")
LanguageCodes["phi"] = ("Philippine (Other)", "")
LanguageCodes["pli"] = LanguageCodes["pi"] = ("Pali", "")
LanguageCodes["pol"] = LanguageCodes["pl"] = ("Polish", "Slavic")
LanguageCodes["pon"] = ("Pohnpeian", "")
LanguageCodes["por"] = LanguageCodes["pt"] = ("Portuguese", "Romance")
LanguageCodes["pra"] = ("Prakrit languages", "")
LanguageCodes["pro"] = ("Provençal, Old (to 1500)", "")
LanguageCodes["pus"] = LanguageCodes["ps"] = ("Pushto", "Iranian")
LanguageCodes["que"] = LanguageCodes["qu"] = ("Quechua", "Amerindian")
LanguageCodes["raj"] = ("Rajasthani", "")
LanguageCodes["rap"] = ("Rapanui", "")
LanguageCodes["rar"] = ("Rarotongan", "")
LanguageCodes["roa"] = ("Romance (Other)", "")
LanguageCodes["rom"] = ("Romany", "")
LanguageCodes["ron"] = LanguageCodes["rum"] = LanguageCodes["ro"] = ("Romanian", "Romance")
LanguageCodes["run"] = LanguageCodes["rn"] = ("Rundi", "Negro-african")
LanguageCodes["rus"] = LanguageCodes["ru"] = ("Russian", "Slavic")
LanguageCodes["sad"] = ("Sandawe", "")
LanguageCodes["sag"] = LanguageCodes["sg"] = ("Sango", "Negro-african")
LanguageCodes["sah"] = ("Yakut", "")
LanguageCodes["sai"] = ("South American Indian (Other)", "")
LanguageCodes["sal"] = ("Salishan languages", "")
LanguageCodes["sam"] = ("Samaritan Aramaic", "")
LanguageCodes["san"] = LanguageCodes["sa"] = ("Sanskrit", "Indian")
LanguageCodes["sas"] = ("Sasak", "")
LanguageCodes["sat"] = ("Santali", "")
LanguageCodes["sco"] = ("Scots", "")
LanguageCodes["sel"] = ("Selkup", "")
LanguageCodes["sem"] = ("Semitic (Other)", "")
LanguageCodes["sga"] = ("Irish, Old (to 900)", "")
LanguageCodes["sgn"] = ("Sign Languages", "")
LanguageCodes["shn"] = ("Shan", "")
LanguageCodes["sid"] = ("Sidamo", "")
LanguageCodes["sin"] = LanguageCodes["si"] = ("Sinhalese", "Indian")
LanguageCodes["sio"] = ("Siouan languages", "")
LanguageCodes["sit"] = ("Sino-Tibetan (Other)", "")
LanguageCodes["sla"] = ("Slavic (Other)", "")
LanguageCodes["slk"] = LanguageCodes["slo"] = LanguageCodes["sk"] = ("Slovak", "Slavic")
LanguageCodes["slv"] = LanguageCodes["sl"] = ("Slovenian", "Slavic")
LanguageCodes["sme"] = LanguageCodes["se"] = ("Northern Sami", "")
LanguageCodes["smi"] = ("Sami languages (Other)", "")
LanguageCodes["smo"] = LanguageCodes["sm"] = ("Samoan", "Oceanic/indonesian")
LanguageCodes["sna"] = LanguageCodes["sn"] = ("Shona", "Negro-african")
LanguageCodes["snd"] = LanguageCodes["sd"] = ("Sindhi", "Indian")
LanguageCodes["snk"] = ("Soninke", "")
LanguageCodes["sog"] = ("Sogdian", "")
LanguageCodes["som"] = LanguageCodes["so"] = ("Somali", "Hamitic")
LanguageCodes["son"] = ("Songhai", "")
LanguageCodes["sot"] = LanguageCodes["st"] = ("Sotho, Southern", "Negro-african")
LanguageCodes["esl"] = LanguageCodes["spa"] = LanguageCodes["es"] = ("Spanish", "Romance")
LanguageCodes["sqi"] = LanguageCodes["alb"] = LanguageCodes["sq"] = ("Albanian", "Indo-european (other)")
LanguageCodes["srd"] = LanguageCodes["sc"] = ("Sardinian", "")
LanguageCodes["srp"] = LanguageCodes["scc"] = LanguageCodes["sr"] = ("Serbian", "Slavic")
LanguageCodes["srr"] = ("Serer", "")
LanguageCodes["ssa"] = ("Nilo-Saharan (Other)", "")
LanguageCodes["ssw"] = LanguageCodes["ss"] = ("Swati", "Negro-african")
LanguageCodes["suk"] = ("Sukuma", "")
LanguageCodes["sun"] = LanguageCodes["su"] = ("Sundanese", "Oceanic/indonesian")
LanguageCodes["sus"] = ("Susu", "")
LanguageCodes["sux"] = ("Sumerian", "")
LanguageCodes["swa"] = LanguageCodes["sw"] = ("Swahili", "Negro-african")
LanguageCodes["swe"] = LanguageCodes["sv"] = ("Swedish", "Germanic")
LanguageCodes["syr"] = ("Syriac", "")
LanguageCodes["tah"] = LanguageCodes["ty"] = ("Tahitian", "")
LanguageCodes["tai"] = ("Tai (Other)", "")
LanguageCodes["tam"] = LanguageCodes["ta"] = ("Tamil", "Dravidian")
LanguageCodes["tat"] = LanguageCodes["tt"] = ("Tatar", "Turkic/altaic")
LanguageCodes["tel"] = LanguageCodes["te"] = ("Telugu", "Dravidian")
LanguageCodes["tem"] = ("Timne", "")
LanguageCodes["ter"] = ("Tereno", "")
LanguageCodes["tet"] = ("Tetum", "")
LanguageCodes["tgk"] = LanguageCodes["tg"] = ("Tajik", "Iranian")
LanguageCodes["tgl"] = LanguageCodes["tl"] = ("Tagalog", "Oceanic/indonesian")
LanguageCodes["tha"] = LanguageCodes["th"] = ("Thai", "Asian")
LanguageCodes["tig"] = ("Tigre", "")
LanguageCodes["tir"] = LanguageCodes["ti"] = ("Tigrinya", "Semitic")
LanguageCodes["tiv"] = ("Tiv", "")
LanguageCodes["tkl"] = ("Tokelau", "")
LanguageCodes["tli"] = ("Tlingit", "")
LanguageCodes["tmh"] = ("Tamashek", "")
LanguageCodes["tog"] = ("Tonga (Nyasa)", "")
LanguageCodes["ton"] = LanguageCodes["to"] = ("Tonga (Tonga Islands)", "Oceanic/indonesian")
LanguageCodes["tpi"] = ("Tok Pisin", "")
LanguageCodes["tsi"] = ("Tsimshian", "")
LanguageCodes["tsn"] = LanguageCodes["tn"] = ("Tswana", "Negro-african")
LanguageCodes["tso"] = LanguageCodes["ts"] = ("Tsonga", "Negro-african")
LanguageCodes["tuk"] = LanguageCodes["tk"] = ("Turkmen", "Turkic/altaic")
LanguageCodes["tum"] = ("Tumbuka", "")
LanguageCodes["tur"] = LanguageCodes["tr"] = ("Turkish", "Turkic/altaic")
LanguageCodes["tut"] = ("Altaic (Other)", "")
LanguageCodes["tvl"] = ("Tuvalu", "")
LanguageCodes["twi"] = LanguageCodes["tw"] = ("Twi", "Negro-african")
LanguageCodes["tyv"] = ("Tuvinian", "")
LanguageCodes["uga"] = ("Ugaritic", "")
LanguageCodes["uig"] = LanguageCodes["ug"] = ("Uighur", "")
LanguageCodes["ukr"] = LanguageCodes["uk"] = ("Ukrainian", "Slavic")
LanguageCodes["umb"] = ("Umbundu", "")
LanguageCodes["und"] = ("Undetermined", "")
LanguageCodes["urd"] = LanguageCodes["ur"] = ("Urdu", "Indian")
LanguageCodes["uzb"] = LanguageCodes["uz"] = ("Uzbek", "Turkic/altaic")
LanguageCodes["vai"] = ("Vai", "")
LanguageCodes["ven"] = ("Venda", "")
LanguageCodes["vie"] = LanguageCodes["vi"] = ("Vietnamese", "Asian")
LanguageCodes["vol"] = LanguageCodes["vo"] = ("Volapük", "International aux.")
LanguageCodes["vot"] = ("Votic", "")
LanguageCodes["wak"] = ("Wakashan languages", "")
LanguageCodes["wal"] = ("Walamo", "")
LanguageCodes["war"] = ("Waray", "")
LanguageCodes["was"] = ("Washo", "")
LanguageCodes["wen"] = ("Sorbian languages", "")
LanguageCodes["wol"] = LanguageCodes["wo"] = ("Wolof", "Negro-african")
LanguageCodes["xho"] = LanguageCodes["xh"] = ("Xhosa", "Negro-african")
LanguageCodes["yao"] = ("Yao", "")
LanguageCodes["yap"] = ("Yapese", "")
LanguageCodes["yid"] = LanguageCodes["yi"] = ("Yiddish", "")
LanguageCodes["yor"] = LanguageCodes["yo"] = ("Yoruba", "Negro-african")
LanguageCodes["ypk"] = ("Yupik languages", "")
LanguageCodes["zap"] = ("Zapotec", "")
LanguageCodes["zen"] = ("Zenaga", "")
LanguageCodes["zha"] = LanguageCodes["za"] = ("Zhuang", "")
LanguageCodes["zho"] = LanguageCodes["chi"] = LanguageCodes["zh"] = ("Chinese", "Asian")
LanguageCodes["znd"] = ("Zande", "")
LanguageCodes["zul"] = LanguageCodes["zu"] = ("Zulu", "Negro-african")
LanguageCodes["zun"] = ("Zuni", "")

class ISO639Language:
	[PRIMARY, SECONDARY, TERTIARY] = [1, 2, 3]
	def __init__(self, depth=PRIMARY):
		self.depth = depth

		wanted_languages = []
		if depth == self.PRIMARY:
			wanted_languages = [ "Undetermined", "English", "German", "Arabic", "Catalan", "Croatian", "Czech", "Danish", "Dutch", "Estonian", "Finnish", "French", "Greek", "Hungarian", "Lithuanian", "Latvian", "Icelandic", "Italian", "Norwegian", "Polish", "Portuguese", "Russian", "Serbian", "Slovakian", "Slovenian", "Spanish", "Swedish", "Turkish", "Ukrainian" ]
		elif depth == self.SECONDARY:
			for key, val in LanguageCodes.iteritems():
				if len(key) == 2:
					wanted_languages.append(val[0])
		else:
			for key, val in LanguageCodes.iteritems():
				if len(key) == 3:
					wanted_languages.append(val[0])

		self.idlist_by_name = {}
		for key, val in LanguageCodes.iteritems():
			val = val[0]
			if val not in wanted_languages:
				continue
			if val not in self.idlist_by_name:
				self.idlist_by_name[val] = [key]
			else:
				self.idlist_by_name[val].append(key)

		self.name_and_shortid_by_longid = {}
		self.name_by_shortid = {}
		for lang, id_list in self.idlist_by_name.iteritems():
			long_ids = []
			short_id = None
			for id in id_list:
				if len(id) == 3:
					long_ids.append(id)
				if len(id) == 2:
					self.name_by_shortid[id] = lang
					short_id = id
			for long_id in long_ids:
				self.name_and_shortid_by_longid[long_id] = (short_id, lang)

		translated_generic_languages = [_("Miscellaneous languages"), _("Multiple languages")]

	def getChoices(self):
		from Components.Language import language as syslanguage
		syslang = syslanguage.getLanguage()[:2]
		choices = []
		for lang, id_list in self.idlist_by_name.iteritems():
			if syslang not in id_list and 'en' not in id_list:
				choices.append((lang, lang))
		choices.sort()
		choices.insert(0,(self.name_by_shortid[syslang], self.name_by_shortid[syslang]))
		if syslang != "en":
			choices.insert(1,(self.name_by_shortid["en"], self.name_by_shortid["en"]))
		return choices

	def determineLanguage(self, string):
		string = string.lower()
		language = "Undetermined"
		for word in ("stereo", "audio", "description", "2ch", "dolby digital", "2.0"):
			string = string.replace(word,"").strip()
		if len(string) == 2 and string in self.name_by_shortid:
			language = self.name_by_shortid[string]
		elif len(string) == 3 and string in self.name_and_shortid_by_longid:
			language = self.name_and_shortid_by_longid[string][1]
		elif len(string) >= 3:
			string = string.capitalize()
			for key in self.idlist_by_name.keys():
				if key == string or _(key) == string:
					language = key
		return language
