Module:taln-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Talnanian language text.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}.
Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:taln-translit/testcases.
Functions
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, returns
nil.
local export = {}
local tt = {}
tt["Mong"] = {
{"ᠠ", "a"},
{"ᠪ", "b"},
{"ᠺ", "c"},
{"ᠴ", "č"},
{"ᠳ", "d"},
{"ᠡ", "e"},
{"ᠹ", "f"},
{"ᠭ", "g"},
{"ᠢ", "i"},
{"ᠯ", "l"},
{"ᠨ", "n"},
{"ᠣ", "o"}, {"ᠤ", "u"},
{"ᠫ", "p"},
{"ᠬ", "q"},
{"ᠷ", "r"},
{"ᠰ", "s"},
{"ᠲ", "t"},
{"ᠸ", "v"},
{"ᠶ", "y"},
{"ᠵ", "z"},
}
tt["Latn"] = require("Module:table").invert(tt["Mong"])
function export.tr(text, lang, sc)
text = mw.ustring.lower(text)
for _, rule in ipairs(tt[sc]) do
text = mw.ustring.gsub(text, rule[1], rule[2])
end
return text
end
function export.template_tr(frame)
local args = require("Module:parameters").process(frame.args, {
[1] = {required = true}, -- text
[2] = {required = true, default = "taln"},
["sc"] = {default = require("Module:scripts").findBestScriptWithoutLang(frame.args[1])}
})
local tr = export.tr(args[1], "taln", args.sc)
return tr or "-"
end
return export