這個模組會將亞美尼亞文文字轉寫為拉丁字母。

最好不要直接從模板或其他模組調用此模組。要從模板中使用它,請以{{xlit}}做為替代;若要在模組中使用,則以Module:languages#Language:transliterate替代。

關於測試用例,請參閱Module:Armn-translit/testcases

函數

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.

--[[
Transliteration for Armenian alphabet. 亞美尼亞字母轉寫
]]
local export = {}
	-- Keep synchronized with [[模組:Xcl-translit]] as much as possible
local gsub = require("Module:string utilities").gsub

local mapping = {
	["ա"]="a", ["բ"]="b", ["գ"]="g", ["դ"]="d", ["ե"]="e", ["զ"]="z",["է"]="ē", ["ը"]="ə",
	["թ"]="tʿ", ["ժ"]="ž", ["ի"]="i", ["լ"]="l", ["խ"]="x", ["ծ"]="c", ["կ"]="k", ["հ"]="h",
	["ձ"]="j", ["ղ"]="ğ", ["ճ"]="č", ["մ"]="m", ["յ"]="y", ["ն"]="n", ["շ"]="š", ["ո"]="o",
	["չ"]="čʿ", ["պ"]="p", ["ջ"]="ǰ", ["ռ"]="ṙ", ["ս"]="s", ["վ"]="v", ["տ"]="t", ["ր"]="r",
	["ց"]="cʿ", ["ւ"]="w", ["փ"]="pʿ", ["ք"]="kʿ", ["և"]="ew", ["օ"]="ō", ["ֆ"]="f",
	["Ա"]="A", ["Բ"]="B", ["Գ"]="G", ["Դ"]="D", ["Ե"]="E", ["Զ"]="Z", ["Է"]="Ē", ["Ը"]="Ə",
	["Թ"]="Tʿ", ["Ժ"]="Ž", ["Ի"]="I", ["Լ"]="L", ["Խ"]="X", ["Ծ"]="C", ["Կ"]="K", ["Հ"]="H",
	["Ձ"]="J", ["Ղ"]="Ğ", ["Ճ"]="Č", ["Մ"]="M", ["Յ"]="Y", ["Ն"]="N", ["Շ"]="Š", ["Ո"]="O",
	["Չ"]="Čʿ", ["Պ"]="P", ["Ջ"]="J̌", ["Ռ"]="Ṙ", ["Ս"]="S", ["Վ"]="V", ["Տ"]="T", ["Ր"]="R",
	["Ց"]="Cʿ", ["Ւ"]="W", ["Փ"]="Pʿ", ["Ք"]="Kʿ", ["Օ"]="Ō", ["Ֆ"]="F", ["ﬓ "]="mn", ["ﬔ"]="me",
	["ﬕ"]="mi", ["ﬖ"]="vn", ["ﬗ"]="mx", ["ՠ"]="ä", ["ֈ"]="hª",
	 -- punctuation
	["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>",
	["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʿ'
}

local replacements = {
	['<sup>յ</sup>'] = 'ʸ',
	['յ̵'] = 'ɦ',
	['ղՙ'] = 'q',
	['Ո[ւՒ]'] = 'U',
	['ու'] = 'u',
	['Ո՛[ւՒ]'] = 'Ú',
	['ո՛ւ'] = 'ú',
	['Ո՜[ւՒ]'] = 'U<sup>!</sup>',
	['ո՜ւ'] = 'u<sup>!</sup>',
	['Ո՞[ւՒ]'] = 'U<sup>?</sup>',
	['ո՞ւ'] = 'u<sup>?</sup>',
	['ո̈ւ'] = 'ü',
	['Ո̈[ւՒ]'] = 'Ü',
	['օ̈'] = 'ö',
	['Օ̈'] = 'Ö',
}

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