มอดูล:Armn-translit

จาก วิกิพจนานุกรม พจนานุกรมเสรี
ไปยังการนำทาง ไปยังการค้นหา

มอดูลนี้ใช้ถอดอักษรข้อความในอักษรอาร์มีเนีย.

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 มอดูล:Armn-translit/testcases.

ฟังก์ชัน[แก้ไข]

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by sc, and language specified by lang. When the transliteration fails, returns nil.

local export = {}

local gsub = mw.ustring.gsub
local mapping = {
	["ա"]="า", ["բ"]="บ", ["գ"]="ก̱", ["դ"]="ด", ["ե"]="↶เʲ", ["զ"]="ซ̱",["է"]="↶เ", ["ը"]="↶เอ̂",
	["թ"]="ท", ["ժ"]="ฌ̱", ["ի"]="ี", ["լ"]="ล", ["խ"]="ฅ", ["ծ"]="ต͡ซ", ["կ"]="ก", ["հ"]="ฮ",
	["ձ"]="ด͡ซ", ["ղ"]="ฆ", ["ճ"]="จ", ["մ"]="ม", ["յ"]="ย", ["ն"]="น", ["շ"]="ฌ", ["ո"]="อ̂",
	["չ"]="ช", ["պ"]="ป", ["ջ"]="จ̱", ["ռ"]="ร̱", ["ս"]="ซ", ["վ"]="ฝ", ["տ"]="ต", ["ր"]="ร",
	["ց"]="ท͡ซ", ["ւ"]="ว", ["փ"]="พ", ["ք"]="ค", ["և"]="↶เʲฝ", ["օ"]="↶โ", ["ֆ"]="ฟ",

	["Ա"]="า", ["Բ"]="บ", ["Գ"]="ก̱", ["Դ"]="ด", ["Ե"]="↶เʲ", ["Զ"]="ซ̱", ["Է"]="↶เ", ["Ը"]="↶เอ̂",
	["Թ"]="ท", ["Ժ"]="ฌ̱", ["Ի"]="ี", ["Լ"]="ล", ["Խ"]="ฅ", ["Ծ"]="ต͡ซ", ["Կ"]="ก", ["Հ"]="ฮ",
	["Ձ"]="ด͡ซ", ["Ղ"]="ฆ", ["Ճ"]="จ", ["Մ"]="ม", ["Յ"]="ย", ["Ն"]="น", ["Շ"]="ฌ", ["Ո"]="อ̂",
	["Չ"]="ช", ["Պ"]="ป", ["Ջ"]="จ̱", ["Ռ"]="ร̱", ["Ս"]="ซ", ["Վ"]="ฝ", ["Տ"]="ต", ["Ր"]="ร",
	["Ց"]="ท͡ซ", ["Ւ"]="ว", ["Փ"]="พ", ["Ք"]="ค", ["Օ"]="↶โ", ["Ֆ"]="ฟ",

	["ﬓ "]="มน", ["ﬔ"]="ม↶เะ", ["ﬕ"]="มี", ["ﬖ"]="ฝน", ["ﬗ"]="มฅ",
	 -- punctuation
	["՝"]=",", ["։"]=".", ["․"]=";", ["՛"]="́", ["՜"]="<sup>!</sup>", ["՞"]="<sup>?</sup>", 
	["՟"]=".", ["֊"]="-", ["՚"]="’", ['«']='“', ['»']='”', ['ՙ']='ʿ'
}

function export.tr(text, lang, sc)
	text = gsub(text, 'յ̵', 'ɦ')
	text = gsub(text, 'Ո[ւՒ]', 'ู')
	text = gsub(text, 'ու', 'ู')
	text = gsub(text, 'Ո՛[ւՒ]', 'ู')
	text = gsub(text, 'ո՛ւ', 'ู')
	text = gsub(text, 'Ո՜[ւՒ]', 'ู<sup>!</sup>')
	text = gsub(text, 'ո՜ւ', 'ู<sup>!</sup>')
	text = gsub(text, 'Ո՞[ւՒ]', 'ู<sup>?</sup>')
	text = gsub(text, 'ո՞ւ', 'ู<sup>?</sup>')
	text = gsub(text, 'ո̈ւ', 'ื')
	text = gsub(text, 'Ո̈[ւՒ]', 'ื')
	text = gsub(text, '.', mapping)

	text = gsub(text, '^([าีืู])', 'อ%1')
	text = gsub(text, ' ([าีืู])', ' อ%1')
	text = gsub(text, 'าี', 'าอี')
	text = gsub(text, '^(อ̂)', 'ฝ%1')
	text = gsub(text, ' (อ̂)', ' ฝ%1')
	text = gsub(text, '^(↶เʲ)', 'ย%1')
	text = gsub(text, ' (↶เʲ)', ' ย%1')
	text = gsub(text, '^(↶เอ̂)', 'อ%1')
	text = gsub(text, ' (↶เอ̂)', ' อ%1')
	text = gsub(text, '^(↶[เโ])', 'อ%1')
	text = gsub(text, ' (↶[เโ])', ' อ%1')
	text = gsub(text, 'ʲ', '')
	text = gsub(text, '([ก-ฮ]̱?)↶([เโ])', '%2%1')

	text = gsub(text, '([ก-ฮ]̱?)า([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1ั%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)า([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1ั%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)า([ก-ฮ]̱?)([เแโ])', '%1ั%2%3')
	text = gsub(text, '([ก-ฮ]̱?)า([ก-ฮ]̱?)([%s%p])', '%1ั%2%3')
	text = gsub(text, '([ก-ฮ]̱?)า([ก-ฮ]̱?)$', '%1ั%2')

	text = gsub(text, '([ก-ฮ]̱?)ี([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1ิ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ี([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1ิ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ี([ก-ฮ]̱?)([เแโ])', '%1ิ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ี([ก-ฮ]̱?)([%s%p])', '%1ิ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ี([ก-ฮ]̱?)$', '%1ิ%2')

	text = gsub(text, '([ก-ฮ]̱?)ื([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1ึ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ื([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1ึ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ื([ก-ฮ]̱?)([เแโ])', '%1ึ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ื([ก-ฮ]̱?)([%s%p])', '%1ึ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ื([ก-ฮ]̱?)$', '%1ึ%2')

	text = gsub(text, '([ก-ฮ]̱?)ู([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1ุ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ู([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1ุ%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)ู([ก-ฮ]̱?)([เแโ])', '%1ุ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ู([ก-ฮ]̱?)([%s%p])', '%1ุ%2%3')
	text = gsub(text, '([ก-ฮ]̱?)ู([ก-ฮ]̱?)$', '%1ุ%2')

	text = gsub(text, '([ก-ฮ]̱?)อ̂([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1็อ̂%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)อ̂([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1็อ̂%2%3%4')
	text = gsub(text, '([ก-ฮ]̱?)อ̂([ก-ฮ]̱?)([เแโ])', '%1็อ̂%2%3')
	text = gsub(text, '([ก-ฮ]̱?)อ̂([ก-ฮ]̱?)([%s%p])', '%1็อ̂%2%3')
	text = gsub(text, '([ก-ฮ]̱?)อ̂([ก-ฮ]̱?)$', '%1็อ̂%2')

	text = gsub(text, '([เแโ])([ก-ฮ]̱?)([ก-ฮ]̱?)([ก-ฮ]̱?)(อ̂)', '%1%2็%3%4%5')
	text = gsub(text, '([เแโ])([ก-ฮ]̱?)([ก-ฮ]̱?)([ก-ฮ]̱?)([ัาิีึืฺุู็])', '%1%2็%3%4%5')
	text = gsub(text, '([เแโ])([ก-ฮ]̱?)([ก-ฮ]̱?)([เแโ])', '%1%2็%3%4')
	text = gsub(text, '([เแโ])([ก-ฮ]̱?)([ก-ฮ]̱?)([%s%p])', '%1%2็%3%4')
	text = gsub(text, '([เแโ])([ก-ฮ]̱?)([ก-ฮ]̱?)$', '%1%2็%3')

	return text
end

return export