Module:My-translit是什么意思_Module:My-translit读音|解释_Module:My-translit同义词|反义词

Module:My-translit

这个模组会将缅甸语未确定的文字拉丁化。

最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。

关于测试用例,请参阅Module:My-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 Burmese 缅甸語轉譯

local export = {}
local gsub = mw.ustring.gsub

local symbols = {
	["၀"] = "0", ["၁"] = "1", ["၂"] = "2", ["၃"] = "3", ["၄"] = "4", 
	["၅"] = "5", ["၆"] = "6", ["၇"] = "7", ["၈"] = "8", ["၉"] = "9", 
	["၊"] = "|", ["။"] = "||"
}

function export.tr(text, lang, sc, debug_mode)
	local m_pron = require("Module:my-pron").get_romanisation
	text = gsub(text, ".", symbols)
	for word in mw.ustring.gmatch(text, "[က-႟ꩠ-ꩻ]+") do
		success, translit = pcall(m_pron, word, nil, { 2, ["type"] = "orthographic", ["name"] = "MLCTS" }, 2, "translit_module")
		if success then
			text = gsub(text, word, translit, 1)
		else
			return nil
		end
	end
	if mw.ustring.match(text, "[က-႟ꩠ-ꩻ]") and not debug_mode then
		return nil
	end
	return text
end

return export