模組:Aio-phk-translit

這個模組會將緬甸文文字轉寫為拉丁字母。

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

關於測試用例,請參閱Module:Aio-phk-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.

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local con_cls = "([ကၵငꩡꩬၺတထꩫဒပၸမဗယꩺလဝꩭဢ])"
local med_cls = "([ျြၞ]?)"

local tt1 = {
	-- consonants
	["က"] = "k", ["ၵ"] = "kh", ["င"] = "ṅ",
	["ꩡ"] = "c", ["ꩬ"] = "s", ["ၺ"] = "ñ",
	["တ"] = "t", ["ထ"] = "th", ["ꩫ"] = "n", ["ဒ"] = "d",
	["ပ"] = "p", ["ၸ"] = "ph", ["မ"] = "m", ["ဗ"] = "b",
	["ယ"] = "y", ["ꩺ"] = "r", ["လ"] = "l", ["ဝ"] = "w",
	["ꩭ"] = "h", ["ဢ"] = "ʼ",
	-- medials
	["ျ"] = "y", ["ြ"] = "r", ["ၞ"] = "w",
	-- dependent vowels and diacritics (excluding front type)
	["္"] = "", ["ႜ"] = "a", ["ႃ"] = "ā", ["ိ"] = "i", ["ီ"] = "ī",
	["ု"] = "u", ["ူ"] = "ū", ["ွ"] = "o", ["်"] = "", ["ႝ"] = "y",
	["ေ"] = "e", ["ံ"] = "ṃ",
	-- punctuation marks
	["၊"] = ",", ["။"] = ".", ["꩷"] = "!",
	-- numerals
	["꩸"] = "1", ["꩹"] = "2",
	["၀"] = "0", ["၁"] = "1", ["၂"] = "2", ["၃"] = "3", ["၄"] = "4",
	["၅"] = "5", ["၆"] = "6", ["၇"] = "7", ["၈"] = "8", ["၉"] = "9",
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = "‼",
}

function export.tr(text, lang, sc)

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

	text = gsub(text, u(0xFE00), "") -- remove VS01

	text = gsub(text, "ေ".."ႃ", "ō")
	text = gsub(text, "ိ".."ု", "ü")
	text = gsub(text, "ွ".."်", "aw")
	text = gsub(text, "ၞ".."်", "aü")

	text = gsub(text, con_cls .. med_cls .. con_cls .. "်", "%1%2a%3")
	text = gsub(text, con_cls .. med_cls .. "([ႝံ])", "%1%2a%3")

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

	return text
 
end
 
return export