模組:Ota-Armn-translit


Language code in page name (Ota) not recognized.


local export = {}
	-- Used to transliterate the [[w:Armeno-Turkish alphabet]]
local gsub = require("Module:string utilities").gsub

local mapping = {
	["ա"]="a",  ["գ"]="k", ["ե"]="y", ["զ"]="z",["է"]="e", ["ը"]="ı",
	["թ"]="t", ["ժ"]="j", ["ի"]="i", ["լ"]="l", ["խ"]="h", ["կ"]="g", ["հ"]="h",
	["ղ"]="ğ", ["ճ"]="c", ["մ"]="m", ["յ"]="y", ["ն"]="n", ["շ"]="ş",
	["չ"]="ç", ["պ"]="b", ["ս"]="s", ["վ"]="v", ["տ"]="d", ["ր"]="r",
	["փ"]="p", ["ք"]="k", ["և"]="ew", ["օ"]="o", ["ֆ"]="f",
	["Ա"]="A",  ["Գ"]="K", ["Ե"]="Y", ["Զ"]="Z", ["Է"]="E", ["Ը"]="I",
	["Թ"]="T", ["Ժ"]="J", ["Ի"]="İ", ["Լ"]="L", ["Խ"]="H", ["Կ"]="G", ["Հ"]="H",
	["Ղ"]="Ğ", ["Ճ"]="C", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Ş",
	["Չ"]="Ç", ["Պ"]="B", ["Ս"]="S", ["Վ"]="V", ["Տ"]="D", ["Ր"]="R",
	["Փ"]="P", ["Ք"]="K", ["Օ"]="O", ["Ֆ"]="F", ["՚"]="ʼ",
	 -- not used in Turkish words
	["բ"]="p", ["դ"]="t", ["ծ"]="dz", ["ձ"]="ts", ["ջ"]="ç", ["ռ"]="r", ["ց"]="ts", 
	["Բ"]="P", ["Դ"]="T", ["Ծ"]="Dz", ["Ձ"]="Ts", ["Ջ"]="Ç", ["Ռ"]="R", ["Ց"]="Ts", 
	 -- punctuation
	["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>",
	["՟"]=".", ["֊"]="-", ['«']='“', ['»']='”',
}

local replacements = {
	['([ՔԿ])ԵԱ'] = '%1Â',
	['([ՔքԿկ])եա'] = '%1â', -- լեա is lya
	['Ո[ւՒ]'] = 'U',
	['ու'] = 'u',
	['Ի[ւՒ]'] = 'Ü',
	['իւ'] = 'ü',
	['Է[օՕ]'] = 'Ö',
	['էօ'] = 'ö',
	['Ո՛[ւՒ]'] = 'Ú',
	['ո՛ւ'] = 'ú',
	['Ո՜[ւՒ]'] = 'U<sup>!</sup>',
	['ո՜ւ'] = 'u<sup>!</sup>',
	['Ո՞[ւՒ]'] = 'U<sup>?</sup>',
	['ո՞ւ'] = 'u<sup>?</sup>',
	 -- ['Ն[ԿՂ]'] = 'Ñ', these cannot be handled automatically
	 -- ['ն[կղ]'] = 'ñ', these cannot be handled automatically
}

function export.tr(text, lang, sc)
	if sc and sc ~= "Armn" then
		return nil
	end

	for regex, replacement in pairs(replacements) do
		text = gsub(text, regex, replacement)
	end

	text = gsub(text, '.', mapping)
	return text
end

return export