Module:xchc-translit: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:


local export = {}
local export = {}
local MorA = "[" .. M .. A .. "]"


local tt_lepik = {
local tt_lepik = {
[M] = A,
["Е" .. A .. D]='Yó', ["е" .. A .. D]='yó', ["Е" .. D]='Yo', ["е" .. D]='yo',
["О" .. B]='A' .. D, ["о" .. B]='a' .. D,
["О" .. M .. B]='A' .. DA, ["о" .. M .. B]='a' .. DA,
["Э" .. B]='E' .. D, ["э" .. B]='e' .. D,
["Э" .. M .. B]='E' .. DA, ["э" .. M .. B]='e' .. DA,
["Ү" .. M]='U' .. DA, ["ү" .. M]='u' .. DA,
["Ү"]='U' .. D, ["ү"]='u' .. D,
["Ө" .. A]='O' .. DA, ["ө" .. A]='o' .. DA,
["Ö" .. A]='O' .. DA, ["ö" .. A]='o' .. DA,
["Ө"]='O' .. D, ["ө"]='o' .. D,
["Дз"]='Dc', ["дз"]='dc', ["Дж"]='Dz', ["дж"]='dz',
["ХӀ"]='H', ["хӀ"]='h',
["[ЬІ]"]="Y", ["[ьі]"]="y",
["Э"]='E', ["э"]='e',
["О"]='O', ["о"]='o',
["А"]='A', ["а"]='a',
["А"]='A', ["а"]='a',
["Я"]='Ja', ["я"]='ja',
["Б"]='B', ["б"]='b',
["Б"]='B', ["б"]='b',
["В"]='V', ["в"]='v',
["В"]='V', ["в"]='v',
["Г"]='G', ["г"]='g',
["Г"]='G', ["г"]='g',
["Ғ"]='Gh', ["ғ"]='gh',
["Ғ"]='Gh', ["ғ"]='gh',
["Д"]='D', ["д"]='d',
["Е"]='Ye', ["е"]='ye',
["Д[zз]"]='Dc', ["д[zз]"]='dc', ["Д[жž]"]='Dz', ["д[жž]"]='dz',
["Ж"]='Ž', ["ж"]='ž',
["Д"]='D', ["д"]='d', ["З"]='Z', ["з"]='z', ["Ж"]='Ž', ["ж"]='ž',
["З"]='Z', ["з"]='z',  
["И" .. B]='J', ["и" .. B]='j', ["И"]='Yi', ["и"]='yi',
["Е(" .. M .. "?)" .. D]='Jo%1', ["е(" .. M .. "?)" .. D]='jo%1',
["Е"]='Je', ["е"]='je',
["Ы"]='I', ["ы"]='i',
["И"]='Ji', ["и"]='ji',
["К"]='K', ["к"]='k',
["К"]='K', ["к"]='k',
["Л"]='L', ["л"]='l',
["Л"]='L', ["л"]='l',
Line 40: Line 33:
["Н"]='N', ["н"]='n',
["Н"]='N', ["н"]='n',
["Ӈ"]='Ng', ["ӈ"]='ng',
["Ӈ"]='Ng', ["ӈ"]='ng',
["О" .. M .. B]='A' .. DA, ["о" .. M .. B]='a' .. DA,
["О" .. B]='A' .. D, ["о"]='a' .. D,
["Е(" .. M .. "?)" .. D]='Jo%1', ["е(" .. M .. "?)" .. D]='jo%1',
["О"]='O', ["о"]='o',
["О"]='O', ["о"]='o',
["Ө" .. M]='O' .. DA, ["ө" .. M]='o' .. DA,
["Ө"]='O' .. D, ["ө"]='o' .. D,
["П"]='P', ["п"]='p',
["П"]='P', ["п"]='p',
["Р"]='R', ["р"]='r',
["Р"]='R', ["р"]='r',
["С"]='S', ["с"]='s',
["С"]='S', ["с"]='s',
["Т"]='T', ["т"]='t',
["Т"]='T', ["т"]='t',
["У"]='U', ["у"]='u',
["У"]='U', ["у"]='u',
["Ю"]='Ju', ["ю"]='ju',
["Ү" .. M]='U' .. DA, ["ү" .. M]='u' .. DA,
["Ү"]='U' .. D, ["ү"]='u' .. D,
["Ф"]='F', ["ф"]='f',
["Ф"]='F', ["ф"]='f',
    ["Х"]='Ch', ["х"]='ch',
["ХӀ"]='H', ["хӀ"]='h',
["Х"]='Ch', ["х"]='ch',
["Ц"]='C', ["ц"]='c',
["Ц"]='C', ["ц"]='c',
["Ч"]='Cs', ["ч"]='cs',
["Ч"]='Cs', ["ч"]='cs',
["Ш"]='Š', ["ш"]='š',
["Ш"]='Š', ["ш"]='š',
["Ы"]='I', ["ы"]='i',
["Ю"]='Yu', ["ю"]='yu',
["Э" .. M .. B]='E' .. DA, ["э"]='e' .. DA,
["Я"]='Ya', ["я"]='ya',
["Э" .. B]='E' .. D, ["э"]='e' .. D,
["Э"]='E', ["э"]='e',
["[ЬІ]"]="J", ["[ьі]"]="j",
["[Ъъ]"]="'",
["[Ъъ]"]="'",
["yĭ"] = "j", ["Yĭ"] = "J",
["[" .. D .. A .. "]+"] = DA, [M .. B] = DA, [M] = A,
["[" .. D .. A .. "]+"] = DA, [M .. B] = DA, [M] = A,
["Ye" .. A .. DA] = "Yo" .. A, ["ye" .. A .. DA] = "yo" .. A
["Ye" .. A .. DA] = "Yo" .. A, ["ye" .. A .. DA] = "yo" .. A
Line 62: Line 74:


function export.tr(text, lang, sc)
function export.tr(text, lang, sc)
text = text:gsub("Й", "J"):gsub("й", "j")
text = mw.ustring.toNFD(text)
text = mw.ustring.toNFD(text)
Line 71: Line 85:
-- text = text:gsub("([Yy])e(" .. A .. ")" .. DA, "%1o%2")
-- text = text:gsub("([Yy])e(" .. A .. ")" .. DA, "%1o%2")
return mw.ustring.toNFC(text)
return text
end
end


return export
return export

Revision as of 14:06, 26 November 2023



local u = mw.ustring.char
local M = u(0x0304) -- COMBINING MACRON
local B = u(0x0306) -- COMBINING BREVE
local D = u(0x0308) -- COMBINING DIAERESIS
local A = u(0x0301) -- COMBINING ACUTE
local DA = u(0x030B) -- COMBINING DOUBLE ACUTE

local export = {}

local MorA = "[" .. M .. A .. "]" 

local tt_lepik = {
	["А"]='A', ["а"]='a',
	["Я"]='Ja', ["я"]='ja',
	
	["Б"]='B', ["б"]='b',
	["В"]='V', ["в"]='v',
	["Г"]='G', ["г"]='g',
	["Ғ"]='Gh', ["ғ"]='gh',
	
	["Д[zз]"]='Dc', ["д[zз]"]='dc',	["Д[жž]"]='Dz', ["д[жž]"]='dz',
	["Д"]='D', ["д"]='d', ["З"]='Z', ["з"]='z', ["Ж"]='Ž', ["ж"]='ž',
	
	["Е(" .. M .. "?)" .. D]='Jo%1', ["е(" .. M .. "?)" .. D]='jo%1',
	["Е"]='Je', ["е"]='je',
	
	["Ы"]='I', ["ы"]='i',
	["И"]='Ji', ["и"]='ji',
	
	["К"]='K', ["к"]='k',
	["Л"]='L', ["л"]='l',
	["М"]='M', ["м"]='m',
	["Н"]='N', ["н"]='n',
	["Ӈ"]='Ng', ["ӈ"]='ng',
	
	["О" .. M .. B]='A' .. DA, ["о" .. M .. B]='a' .. DA,
	["О" .. B]='A' .. D, ["о"]='a' .. D,
	["Е(" .. M .. "?)" .. D]='Jo%1', ["е(" .. M .. "?)" .. D]='jo%1',
	["О"]='O', ["о"]='o',
	
	["Ө" .. M]='O' .. DA, ["ө" .. M]='o' .. DA,
	["Ө"]='O' .. D, ["ө"]='o' .. D,
	
	["П"]='P', ["п"]='p',
	["Р"]='R', ["р"]='r',
	["С"]='S', ["с"]='s',
	["Т"]='T', ["т"]='t',
	
	["У"]='U', ["у"]='u',
	["Ю"]='Ju', ["ю"]='ju',
	
	["Ү" .. M]='U' .. DA, ["ү" .. M]='u' .. DA,
	["Ү"]='U' .. D, ["ү"]='u' .. D,
	
	["Ф"]='F', ["ф"]='f',
	
	["ХӀ"]='H', ["хӀ"]='h',
	["Х"]='Ch', ["х"]='ch',
	
	["Ц"]='C', ["ц"]='c',
	["Ч"]='Cs', ["ч"]='cs',
	["Ш"]='Š', ["ш"]='š',
	
	["Э" .. M .. B]='E' .. DA, ["э"]='e' .. DA,
	["Э" .. B]='E' .. D, ["э"]='e' .. D,
	["Э"]='E', ["э"]='e',
	
	["[ЬІ]"]="J", ["[ьі]"]="j",
	["[Ъъ]"]="'",
	
	["[" .. D .. A .. "]+"] = DA, [M .. B] = DA, [M] = A,
	["Ye" .. A .. DA] = "Yo" .. A, ["ye" .. A .. DA] = "yo" .. A
};

function export.tr(text, lang, sc)
	
	text = text:gsub("Й", "J"):gsub("й", "j")
	
	text = mw.ustring.toNFD(text)
	
	for pat, repl in pairs(tt_lepik) do
		text = mw.ustring.gsub(text, pat, repl)
	end
	
	-- text = text:gsub("([Yy])e(" .. A .. ")" .. DA, "%1o%2")
	
	return mw.ustring.toNFC(text)
end

return export