Jump to content

Module:mns-translit

From Wiktionary, the free dictionary

This module will transliterate text in one of the Mansi languages per WT:MNS TR. It is also used to transliterate Central Mansi, Northern Mansi, and Southern Mansi. 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:mns-translit/testcases.

Functions

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 tt = {
	["а"]="a", ["а̄"]="ā", ["ӓ"]="ä", ["б"]="b", ["в"]="v", ["г"]="g", ["д"]="d", ["е"]="e",
	["е̄"]="ē", ["ё"]="ë", ["ё̄"]="ë̄", ["ж"]="ž", ["з"]="z", ["и"]="i", ["ӣ"]="ī",
	["й"]="j", ["к"]="k", ["л"]="l", ["м"]="m", ["н"]="n", ["ӈ"]="ň", ["о"]="o",
	["о̄"]="ō", ["ӧ"]="ö", ["п"]="p", ["р"]="r", ["с"]="s", ["т"]="t", ["у"]="u", ["ӯ"]="ū",
	["ӱ"]="ü", ["ф"]="f", ["х"]="h", ["ц"]="c", ["ч"]="č", ["ш"]="š", ["щ"]="ŝ", ["ъ"]="ʺ",
	["ы"]="y", ["ы̄"]="ȳ", ["ь"]="ʹ", ["э"]="è", ["э̄"]="è̄", ["ю"]="û", ["ю̄"]="û̄",
	["я"]="â", ["я̄"]="â̄",
	["А"]="A", ["А̄"]="Ā", ["Ӓ"]="Ä", ["Б"]="B", ["В"]="V", ["Г"]="G", ["Д"]="D", ["Е"]="E",
	["Е̄"]="Ē", ["Ё"]="Ë", ["Ё̄"]="Ë̄", ["Ж"]="Ž", ["З"]="Z", ["И"]="I", ["Ӣ"]="Ī",
	["Й"]="J", ["К"]="K", ["Л"]="L", ["М"]="M", ["Н"]="N", ["Ӈ"]="Ň", ["О"]="O",
	["О̄"]="Ō", ["Ӧ"]="Ö",  ["П"]="P", ["Р"]="R", ["С"]="S", ["Т"]="T", ["У"]="U", ["Ӯ"]="Ū",
	["Ӱ"]="Ü", ["Ф"]="F", ["Х"]="H", ["Ц"]="C", ["Ч"]="Č", ["Ш"]="Š", ["Щ"]="Ŝ", ["Ъ"]="ʺ",
	["Ы"]="Y", ["Ы̄"]="Ȳ", ["Ь"]="ʹ", ["Э"]="È", ["Э̄"]="È̄", ["Ю"]="Û", ["Ю̄"]="Û̄",
	["Я"]="Â", ["Я̄"]="Â̄",
};
 
function export.tr(text, lang, sc)
	return (mw.ustring.gsub(text, '.', tt))
end
 
return export