This module will transliterate Sirenik 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:ysr-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 u = mw.ustring.char
local gsub = mw.ustring.gsub

local RING = u(0x030A)

local single_letter_replacements = {

	["А"]='A', ["а"]='a', ["В"]='V', ["в"]='v',
	["Е"]='E', ["е"]='e', ["Ё"]='Jo', ["ё"]='jo',
	["Г"]='G', ["г"]='g', ["Ў"]='W',["ў"]='w', ["Ԝ"]='W',["ԝ"]='w', ["Ӷ"]='Ǧ',["ӷ"]='ǧ',
	["И"]='I', ["и"]='i', ["Ӣ"]='Ī', ["ӣ"]='ī',
	["Й"]='J', ["й"]='j', ["К"]='K', ["к"]='k', ["Л"]='L', ["л"]='l', ["Ӄ"]='Q', ["ӄ"]='q',
	["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["Ӈ"]='Ŋ', ["ӈ"]='ŋ', ["О"]='O', ["о"]='o',
	["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r', ["С"]='S', ["с"]='s',
	["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u', ["Х"]='H', ["х"]='h', 
	["Ч"]='Č', ["ч"]='č', ["Ӽ"]='X̌', ["ӽ"]='x̌',["Ы"]='Y', ["ы"]='y',
	["Э"]='Ə', ["э"]='ə', ["Ю"]='Ju', ["ю"]='ju',["Я"]='Ja', ["я"]='ja', ['Ъ']='ʺ', ['ъ']='ʺ',

	-- NOT PRESENT IN THE ORIGINAL LATINISATION --

	-- non-native letters
	["Ж"]='Z', ["ж"]='z', ["З"]='Ž', ["з"]='ž',
	["Ц"]='C', ["ц"]='c', ["Ш"]='Š', ["ш"]='š', ["Щ"]='Šč', ["щ"]='šč',
	["Ь"]="’", ["ь"]="’",["Ф"]='F', ["ф"]='f',
	["Б"]='B', ["б"]='ʙ',["Д"]='D', ["д"]='d',

	-- non-standard letters
	["Ҕ"]='Γ', ["ҕ"]='γ', ["Ҥ"]='Ŋ', ["ҥ"]='ŋ',
	["Ӄ"]='Q', ["ӄ"]='q', ["Ҕ"]='Ǧ', ["ҕ"]='ǧ',

}

function export.tr(text, lang, sc)
	text = gsub(text, ".", single_letter_replacements)
	text = gsub(text, "([ЙйЛлНн])ъ", "%1" .. RING)
	return text
end

return export