Module:Latn-Tfng-translit
Appearance
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Latin script.
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:Latn-Tfng-translit/testcases.
Functions
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, returns
nil
.
local export = {}
local tt = {}
tt["Latn"] = {
["common"] = {
["a"] = "ⴰ",
["ā"] = "ⴰⴰ",
["b"] = "ⴱ",
["ḇ"] = "ⴲ",
["ǧ"] = "ⴵ",
["g"] = "ⴳ",
["d"] = "ⴷ",
["ḏ"] = "ⴸ",
["ḍ"] = "ⴹ",
["ḏ̣"] = "ⴺ",
["e"] = "ⴻ",
["f"] = "ⴼ",
["k"] = "ⴽ",
["h"] = "ⵀ",
["ḥ"] = "ⵃ",
["ɛ"] = "ⵄ",
["x"] = "ⵅ",
["q"] = "ⵇ",
["i"] = "ⵉ",
["j"] = "ⵊ",
["l"] = "ⵍ",
["m"] = "ⵎ",
["n"] = "ⵏ",
["p"] = "ⵒ",
["u"] = "ⵓ",
["r"] = "ⵔ",
["ř"] = "ⵔ",
["ṛ"] = "ⵕ",
["ɣ"] = "ⵖ",
["s"] = "ⵙ",
["ṣ"] = "ⵚ",
["t"] = "ⵜ",
["ṯ"] = "ⵝ",
["š"] = "ⵛ",
["c"] = "ⵛ",
["č"] = "ⵞ",
["ṭ"] = "ⵟ",
["v"] = "ⵠ",
["w"] = "ⵡ",
["y"] = "ⵢ",
["z"] = "ⵣ",
["ẓ"] = "ⵥ",
["o"] = "ⵧ",
["ʷ"] = "ⵯ",
["."] = "⵰",
},
["tmh"] = {["b"] = "ⵀ", ["w"] = "ⵓ"},
["thv"] = {["b"] = "ⵀ", ["w"] = "ⵓ"},
["taq"] = {["b"] = "ⵀ", ["w"] = "ⵓ"},
["ttq"] = {["b"] = "ⵀ", ["w"] = "ⵓ"},
["thz"] = {["b"] = "ⵀ", ["w"] = "wⵓ", ["ɣ"] = "ⵘ"}
}
function export.tr(text, lang, sc)
if not sc then
sc = require("Module:languages").getByCode(lang or "ber"):findBestScript(text):getCode()
end
if sc == "Latn" then
text = mw.ustring.lower(text)
if tt[sc][lang] then
text = mw.ustring.gsub(text, '.', tt[sc][lang])
end
text = mw.ustring.gsub(text, '.', tt[sc]["common"])
else
text = nil
end
return text
end
return export