มอดูล:Ahom-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 มอดูล:Ahom-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 u = mw.ustring.char
local con_cls = "([𑜀-𑜙][𑜝𑜞𑜟]?)"

local tt = {
	-- consonants
	["𑜀"] = "ก", ["𑜁"] = "ข", ["𑜂"] = "ง", ["𑜃"] = "น", ["𑜄"] = "ต", ["𑜅"] = "ต",
	["𑜆"] = "ป", ["𑜇"] = "ผ", ["𑜈"] = "บ", ["𑜉"] = "ม", ["𑜊"] = "ย", ["𑜋"] = "จ",
	["𑜌"] = "ถ", ["𑜍"] = "ร", ["𑜎"] = "ล", ["𑜏"] = "ส", ["𑜐"] = "ญ", ["𑜑"] = "ห",
	["𑜒"] = "อ", ["𑜓"] = "ด", ["𑜔"] = "ธ", ["𑜕"] = "ค", ["𑜖"] = "ค", ["𑜗"] = "ฆ",
	["𑜘"] = "ภ", ["𑜙"] = "ฌ",
	-- medials
	["𑜝"] = "ฺล", ["𑜞"] = "ฺร", ["𑜟"] = "ฺร",
	-- vowels (excluding front type)
	["𑜠"] = "ะ", ["𑜡"] = "า", ["𑜢"] = "ิ", ["𑜣"] = "ี",
	["𑜤"] = "ุ", ["𑜥"] = "ู", ["𑜧"] = "ว์", ["𑜩"] = "ย์",
	["𑜨"] = "อ̂",
	["𑜪"] = "ํ", ["𑜫"] = "์",
	-- numerals
	["𑜰"] = "0", ["𑜱"] = "1", ["𑜲"] = "2", ["𑜳"] = "3", ["𑜴"] = "4",
	["𑜵"] = "5", ["𑜶"] = "6", ["𑜷"] = "7", ["𑜸"] = "8", ["𑜹"] = "9",
	["𑜺"] = "[10]", ["𑜻"] = "[20]",
	-- punctuations and symbols
	["𑜼"] = "ฯ", ["𑜽"] = "๚", ["𑜾"] = "@", ["𑜿"] = "วิ",
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = "‼",
}

local adjust0 = {
	-- vowels (composition)
	["𑜢".."𑜤"] = "%1ึ",
	["𑜦".."𑜡"] = "%1อ̂",
	["𑜨".."𑜦".."𑜡"] = "%1ฺวอ̂",
	["𑜦".."𑜧"] = "เ%1",
	["𑜩".."𑜤"] = "%1าย์",
}

local adjust1 = {
	-- vowels (front type)
	["𑜦"] = "เ%1",
}

function export.tr(text, lang, sc, debug_mode)

	if type(text) == "table" then -- called directly from a template
		text = text.args[1]
	end

	for k, v in pairs(adjust0) do
		text = gsub(text, con_cls..k, v)
	end
	for k, v in pairs(adjust1) do
		text = gsub(text, con_cls..k, v)
	end

	text = gsub(text, ".", tt)

	text = gsub(text, "บ์", "ว์")

	return text

end

return export