模組:My-translit
外观
- 下列說明文檔位於Module:My-translit/doc。[編輯] 分類由 Module:module categorization 自動生成。[編輯]
- 相關連結:子頁面列表 • 链入 • 嵌入包含 • 測試用例 • 沙盒
本模块會將緬甸語的文字轉寫為拉丁字母per the MLCTS scheme。
最好不要直接從模板或其他模块調用此模块。要從模板中使用它,請以 {{xlit}} 做為替代;若要在模块中使用,則以 Module:languages#Language:transliterate 替代。
關於測試用例,請參閱Module:My-translit/testcases。
函數
tr(text, lang, sc)- 對以代碼
sc指定的文字、代碼lang指定的語言所書寫的一段text進行轉寫。 - 當轉寫失敗時,回傳
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