Module:ISO 639

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module contains functions for working with ISO 639 language codes. Currently the only exported function is one to convert from two-letter ISO 639-1 codes (as used in Wiktionary) to three-letter ISO 639-2 codes (as used on some sites, such as MediaWiki Lingua Libre audio files).


local export = {}

-- Auto-generated based on https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes then hand-modified.
export.iso_639_1_to_iso_639_2 = {
	aa = "aar", -- Afar
	ab = "abk", -- Abkhazian
	ae = "ave", -- Avestan
	af = "afr", -- Afrikaans
	ak = "aka", -- Akan
	am = "amh", -- Amharic
	an = "arg", -- Aragonese
	ar = "ara", -- Arabic
	as = "asm", -- Assamese
	av = "ava", -- Avaric
	ay = "aym", -- Aymara
	az = "aze", -- Azerbaijani
	ba = "bak", -- Bashkir
	be = "bel", -- Belarusian
	bg = "bul", -- Bulgarian
	bi = "bis", -- Bislama
	bm = "bam", -- Bambara
	bn = "ben", -- Bengali
	bo = "bod", -- Tibetan
	br = "bre", -- Breton
	-- bs = "bos", -- Bosnian
	ca = "cat", -- Catalan
	ce = "che", -- Chechen
	ch = "cha", -- Chamorro
	co = "cos", -- Corsican
	cr = "cre", -- Cree
	cs = "ces", -- Czech
	cu = "chu", -- Old Church Slavonic
	cv = "chv", -- Chuvash
	cy = "cym", -- Welsh
	da = "dan", -- Danish
	de = "deu", -- German
	dv = "div", -- Divehi
	dz = "dzo", -- Dzongkha
	ee = "ewe", -- Ewe
	el = "ell", -- Greek
	en = "eng", -- English
	eo = "epo", -- Esperanto
	es = "spa", -- Spanish
	et = "est", -- Estonian
	eu = "eus", -- Basque
	fa = "fas", -- Persian
	ff = "ful", -- Fulah
	fi = "fin", -- Finnish
	fj = "fij", -- Fijian
	fo = "fao", -- Faroese
	fr = "fra", -- French
	fy = "fry", -- Western Frisian
	ga = "gle", -- Irish
	gd = "gla", -- Gaelic
	gl = "glg", -- Galician
	gn = "grn", -- Guarani
	gu = "guj", -- Gujarati
	gv = "glv", -- Manx
	ha = "hau", -- Hausa
	he = "heb", -- Hebrew
	hi = "hin", -- Hindi
	ho = "hmo", -- Hiri Motu
	-- hr = "hrv", -- Croatian
	ht = "hat", -- Haitian
	hu = "hun", -- Hungarian
	hy = "hye", -- Armenian
	hz = "her", -- Herero
	ia = "ina", -- Interlingua
	id = "ind", -- Indonesian
	ie = "ile", -- Interlingue
	ig = "ibo", -- Igbo
	ii = "iii", -- Nuosu
	ik = "ipk", -- Inupiaq
	io = "ido", -- Ido
	is = "isl", -- Icelandic
	it = "ita", -- Italian
	iu = "iku", -- Inuktitut
	ja = "jpn", -- Japanese
	jv = "jav", -- Javanese
	ka = "kat", -- Georgian
	kg = "kon", -- Kongo
	ki = "kik", -- Kikuyu
	kj = "kua", -- Kuanyama
	kk = "kaz", -- Kazakh
	kl = "kal", -- Kalaallisut
	km = "khm", -- Central Khmer
	kn = "kan", -- Kannada
	ko = "kor", -- Korean
	kr = "kau", -- Kanuri
	ks = "kas", -- Kashmiri
	ku = "kur", -- Kurdish
	kv = "kom", -- Komi
	kw = "cor", -- Cornish
	ky = "kir", -- Kirghiz
	la = "lat", -- Latin
	lb = "ltz", -- Luxembourgish
	lg = "lug", -- Ganda
	li = "lim", -- Limburgan
	ln = "lin", -- Lingala
	lo = "lao", -- Lao
	lt = "lit", -- Lithuanian
	lu = "lub", -- Luba-Katanga
	lv = "lav", -- Latvian
	mg = "mlg", -- Malagasy
	mh = "mah", -- Marshallese
	mi = "mri", -- Maori
	mk = "mkd", -- Macedonian
	ml = "mal", -- Malayalam
	mn = "mon", -- Mongolian
	mr = "mar", -- Marathi
	ms = "msa", -- Malay
	mt = "mlt", -- Maltese
	my = "mya", -- Burmese
	na = "nau", -- Nauru
	nb = "nob", -- Norwegian Bokmål
	nd = "nde", -- North Ndebele
	ne = "nep", -- Nepali
	ng = "ndo", -- Ndonga
	nl = "nld", -- Dutch
	nn = "nno", -- Norwegian Nynorsk
	no = "nor", -- Norwegian
	nr = "nbl", -- South Ndebele
	nv = "nav", -- Navajo
	ny = "nya", -- Chichewa
	oc = "oci", -- Occitan
	oj = "oji", -- Ojibwa
	om = "orm", -- Oromo
	["or"] = "ori", -- Oriya
	os = "oss", -- Ossetian
	pa = "pan", -- Punjabi
	pi = "pli", -- Pali
	pl = "pol", -- Polish
	ps = "pus", -- Pashto
	pt = "por", -- Portuguese
	qu = "que", -- Quechua
	rm = "roh", -- Romansh
	rn = "run", -- Rundi
	ro = "ron", -- Romanian
	ru = "rus", -- Russian
	rw = "kin", -- Kinyarwanda
	sa = "san", -- Sanskrit
	sc = "srd", -- Sardinian
	sd = "snd", -- Sindhi
	se = "sme", -- Northern Sami
	sg = "sag", -- Sango
	si = "sin", -- Sinhala
	sk = "slk", -- Slovak
	sl = "slv", -- Slovenian
	sm = "smo", -- Samoan
	sn = "sna", -- Shona
	so = "som", -- Somali
	sq = "sqi", -- Albanian
	-- sr = "srp", -- Serbian
	ss = "ssw", -- Swati
	st = "sot", -- Southern Sotho
	su = "sun", -- Sundanese
	sv = "swe", -- Swedish
	sw = "swa", -- Swahili
	ta = "tam", -- Tamil
	te = "tel", -- Telugu
	tg = "tgk", -- Tajik
	th = "tha", -- Thai
	ti = "tir", -- Tigrinya
	tk = "tuk", -- Turkmen
	tl = "tgl", -- Tagalog
	tn = "tsn", -- Tswana
	to = "ton", -- Tonga
	tr = "tur", -- Turkish
	ts = "tso", -- Tsonga
	tt = "tat", -- Tatar
	tw = "twi", -- Twi
	ty = "tah", -- Tahitian
	ug = "uig", -- Uighur
	uk = "ukr", -- Ukrainian
	ur = "urd", -- Urdu
	uz = "uzb", -- Uzbek
	ve = "ven", -- Venda
	vi = "vie", -- Vietnamese
	vo = "vol", -- Volapük
	wa = "wln", -- Walloon
	wo = "wol", -- Wolof
	xh = "xho", -- Xhosa
	yi = "yid", -- Yiddish
	yo = "yor", -- Yoruba
	za = "zha", -- Zhuang
	zh = "zho", -- Chinese
	zu = "zul", -- Zulu
}

function export.convert_iso_639_1_to_iso_639_2(frame)
	local langcode = frame.args[1]
	return export.iso_639_1_to_iso_639_2[langcode] or langcode
end
	

return export