Module:Prti-translit
- 下列说明文档位于Module:Prti-translit/doc。[编辑]
- 相关链接:子页面列表 • 链入 • 嵌入包含 • 测试用例 • 沙盒
这个模组会将碑刻帕提亚文文字转写为拉丁字母。
最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}
做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。
关于测试用例,请参阅Module:Prti-translit/testcases。
函数
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. When the transliteration fails, returnsnil
.
local export = {}
local tt = {
['𐭀'] = 'ʾ',
['𐭁'] = 'b',
['𐭂'] = 'g',
['𐭃'] = 'd',
['𐭄'] = 'h',
['𐭅'] = 'w',
['𐭆'] = 'z',
['𐭇'] = 'ḥ',
['𐭈'] = 'ṭ',
['𐭉'] = 'y',
['𐭊'] = 'k',
['𐭋'] = 'l',
['𐭌'] = 'm',
['𐭍'] = 'n',
['𐭎'] = 's',
['𐭏'] = 'ʿ',
['𐭐'] = 'p',
['𐭑'] = 'c',
['𐭒'] = 'q',
['𐭓'] = 'r',
['𐭔'] = 'š',
['𐭕'] = 't',
}
local numbers = {
['𐭘'] = 1,
['𐭙'] = 2,
['𐭚'] = 3,
['𐭛'] = 4,
['𐭜'] = 10,
['𐭝'] = 20,
['𐭞'] = 100,
['𐭟'] = 1000,
}
function export.convert_numbers(numeric_str)
local total = 0
for c in mw.ustring.gmatch(numeric_str, ".") do
total = total + numbers[c]
end
return total
end
function export.tr(text, lang, sc)
-- If the script is not Prti, do not transliterate
if sc ~= "Prti" then
return
end
if mw.ustring.match(text, '[𐭘-𐭟]') then
text = mw.ustring.gsub(text, '[𐭘-𐭟]+', export.convert_numbers)
end
-- Transliterate characters
text = mw.ustring.gsub(text, '.', tt)
return text
end
return export