Pergi ke kandungan

Modul:Armn-translit

Daripada Wikikamus

Modul ini akan mentransliterasi teks dalam Tulisan Armenian. Ia digunakan untuk mentransliterasi Armenia Pertengahan, Armenia, Northern Kurdish, Kipchak, Lomavren, Udi, and Armenia Kuno. 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:Armn-translit/testcases.

Functions

[sunting]
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 gsub = mw.ustring.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",
	 -- punctuation
	["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>", 
	["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʿ'
}

function export.tr(text, lang, sc)
	text = gsub(text, 'յ̵', 'ɦ')
	text = gsub(text, 'Ո[ւՒ]', 'U')
	text = gsub(text, 'ու', 'u')
	text = gsub(text, 'Ո՛[ւՒ]', 'Ú')
	text = gsub(text, 'ո՛ւ', 'ú')
	text = gsub(text, 'Ո՜[ւՒ]', 'U<sup>!</sup>')
	text = gsub(text, 'ո՜ւ', 'u<sup>!</sup>')
	text = gsub(text, 'Ո՞[ւՒ]', 'U<sup>?</sup>')
	text = gsub(text, 'ո՞ւ', 'u<sup>?</sup>')
	text = gsub(text, 'ո̈ւ', 'ü')
	text = gsub(text, 'Ո̈[ւՒ]', 'Ü')
	text = gsub(text, '.', mapping)
	return text
end

return export