Bước tới nội dung

Mô đun:dlg-translit

Từ điển mở Wiktionary
local export = {}

local tab = {
	["А"]='A', ["а"]='a', ["Б"]='B', ["б"]='b', ["Г"]='G', ["г"]='g', ["Ҕ"]='Ǧ', ["ҕ"]='ǧ',
	["Д"]='D', ["д"]='d', ["И"]='I', ["и"]='i', ["Й"]='Y', ["й"]='y', ["К"]='K', ["к"]='k',
	["Л"]='L', ["л"]='l', ["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["Ӈ"]='Ñ', ["ӈ"]='ñ',
	["О"]='O', ["о"]='o', ["Ө"]='Ö', ["ө"]='ö', ["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r',
	["С"]='S', ["с"]='s', ["Һ"]='H', ["һ"]='h', ["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u',
	["Ү"]='Ü', ["ү"]='ü', ["Х"]='X', ["х"]='x', ["Ч"]='Ç', ["ч"]='ç', ["Ш"]='Ş', ["ш"]='ş',
	["Ы"]='I', ["ы"]='ı', ["Э"]='E', ["э"]='e',
	-- non-native letters
	["В"]='V', ["в"]='v', ["Е"]='Ye', ["е"]='ye', ["Ё"]='Jo', ["ё"]='jo', ["Ж"]='Ž', ["ж"]='ž',
	["З"]='Z', ["з"]='z', ["Ф"]='F', ["ф"]='f', ["Ц"]='Ts', ["ц"]='ts', ["Щ"]='Tsh', ["щ"]='tsh',
	['Ъ']='ʺ', ['ъ']='ʺ', ["Ь"]="’", ["ь"]="’", ["Ю"]='Yu', ["ю"]='yu', ["Я"]='Ya', ["я"]='ya',
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(text, 'Дь', 'Ď')
    text = mw.ustring.gsub(text, 'дь', 'ď')
    text = mw.ustring.gsub(text, 'Нь', 'Ń')
    text = mw.ustring.gsub(text, 'нь', 'ń')
	
    return (mw.ustring.gsub(text,'.',tab))
end

return export