Module:Gin-translit
- 下列说明文档位于Module:Gin-translit/doc。[编辑]
- 相关链接:子页面列表 • 链入 • 嵌入包含 • 测试用例 • 沙盒
这个模组会将希努赫语未确定的文字拉丁化。
最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。
关于测试用例,请参阅Module:Gin-translit/testcases。
函数
tr(text, lang, sc)- Transliterates a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. When the transliteration fails, returnsnil.
local export = {}
local mapping1 = {
["п"] = "p", ["б"] = "b",
["т"] = "t", ["д"] = "d",
["к"] = "k", ["г"] = "g",
["ц"] = "c", ["ч"] = "č",
["с"] = "s", ["з"] = "z", ["ш"] = "š", ["ж"] = "ž", ["х"] = "x",
["м"] = "m", ["н"] = "n",
["р"] = "r", ["л"] = "l",
["в"] = "v", ["й"] = "y",
["и"] = "i", ["е"] = "e", ["э"] = "e", ["а"] = "a", ["о"] = "o", ["у"] = "u", ["ӥ"] = "ü",
["ъ"] = "ʾ",
}
local mapping2 = {
["пӏ"] = "p’", ["тӏ"] = "t’", ["кӏ"] = "k’", ["къ"] = "q’",
["цӏ"] = "c’", ["лӏ"] = "ƛ", ["кь"] = "ƛ’", ["чӏ"] = "c’", ["хъ"] = "q",
["лъ"] = "λ", ["гъ"] = "ġ", ["хӏ"] = "ḥ", ["гӏ"] = "a̯", ["гь"] = "h",
["кӏв"] = "k’ʷ", ["хъв"] = "qʷ", ["къв"] = "q’ʷ", ["гъв"] = "ġʷ", ["хв"] = "xʷ",
}
function export.tr(text, lang, sc)
local str_gsub = string.gsub
local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"
-- Convert capital to lowercase palochka.
text = str_gsub(text, mw.ustring.char(0x4C0), mw.ustring.char(0x4CF))
for pat, repl in pairs(mapping2) do
text = str_gsub(text, pat, repl)
end
text = str_gsub(text, UTF8_char, mapping1)
return text
end
return export
