Jump to content

Module:kpy-translit

From Wiktionary, the free dictionary

This module will transliterate Koryak language text. The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:kpy-translit/testcases.

Functions

[edit]
tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

local export = {}

local tab = {
	["А"]="A", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="Je", ["Ё"]="Jo", ["Ж"]="Ž", ["З"]="Z", ["И"]="I", ["Й"]="J",
	["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["О"]="O", ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T", ["У"]="U", ["Ф"]="F",
	["Х"]="X", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", ["Щ"]="Ś", ["Ъ"]="ʺ", ["Ы"]="Ə", ["Ь"]="ʹ", ["Э"]="E", ["Ю"]="Ju", ["Я"]="Ja",
	["Ӈ"]="Ŋ", ["Ӄ"]="Q",
	['а']='a', ['б']='b', ['в']='v', ['г']='g', ['д']='d', ['е']='je', ['ё']='jo', ['ж']='ž', ['з']='z', ['и']='i', ['й']='y',
	['к']='k', ['л']='l', ['м']='m', ['н']='n', ['о']='o', ['п']='p', ['р']='r', ['с']='s', ['т']='t', ['у']='u', ['ф']='f',
	['х']='x', ['ц']='c', ['ч']='č', ['ш']='š', ['щ']='ś', ['ъ']='ʺ', ['ы']='ə', ['ь']='ʹ', ['э']='e', ['ю']='ju', ['я']='ya',
	["ӈ"]="ŋ", ['ӄ']='q',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, "Вʼ", "W")
	text = mw.ustring.gsub(text, "вʼ", "w")
	text = mw.ustring.gsub(text, "Гʼ", "H")
	text = mw.ustring.gsub(text, "гʼ", "h")
	
    return (mw.ustring.gsub(text, '.' ,tab))
end

return export