Module:bug-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 Buginese language text per WT:BUG TR.
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:bug-translit/testcases.
Functions
[edit]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"] = {
["ka"]="ᨀ", ["ki"]="ᨀᨗ", ["ku"]="ᨀᨘ", ["ké"]="ᨀᨙ", ["ko"]="ᨀᨚ", ["ke"]="ᨀᨛ",
["ga"]="ᨁ", ["gi"]="ᨁᨗ", ["gu"]="ᨁᨘ", ["gé"]="ᨁᨙ", ["go"]="ᨁᨚ", ["ge"]="ᨁᨛ",
["pa"]="ᨄ", ["pi"]="ᨄᨗ", ["pu"]="ᨄᨘ", ["pé"]="ᨄᨙ", ["po"]="ᨄᨚ", ["pe"]="ᨄᨛ",
["ba"]="ᨅ", ["bi"]="ᨅᨗ", ["bu"]="ᨅᨘ", ["bé"]="ᨅᨙ", ["bo"]="ᨅᨚ", ["be"]="ᨅᨛ",
["ma"]="ᨆ", ["mi"]="ᨆᨗ", ["mu"]="ᨆᨘ", ["mé"]="ᨆᨙ", ["mo"]="ᨆᨚ", ["me"]="ᨆᨛ",
["ta"]="ᨈ", ["ti"]="ᨈᨗ", ["tu"]="ᨈᨘ", ["té"]="ᨈᨙ", ["to"]="ᨈᨚ", ["te"]="ᨈᨛ",
["da"]="ᨉ", ["di"]="ᨉᨗ", ["du"]="ᨉᨘ", ["dé"]="ᨉᨙ", ["do"]="ᨉᨚ", ["de"]="ᨉᨛ",
["na"]="ᨊ", ["ni"]="ᨊᨗ", ["nu"]="ᨊᨘ", ["né"]="ᨊᨙ", ["no"]="ᨊᨚ", ["ne"]="ᨊᨛ",
["ca"]="ᨌ", ["ci"]="ᨌᨗ", ["cu"]="ᨌᨘ", ["cé"]="ᨌᨙ", ["co"]="ᨌᨚ", ["ce"]="ᨌᨛ",
["ja"]="ᨍ", ["ji"]="ᨍᨗ", ["ju"]="ᨍᨘ", ["jé"]="ᨍᨙ", ["jo"]="ᨍᨚ", ["je"]="ᨍᨛ",
["ya"]="ᨐ", ["yi"]="ᨐᨗ", ["yu"]="ᨐᨘ", ["yé"]="ᨐᨙ", ["yo"]="ᨐᨚ", ["ye"]="ᨐᨛ",
["ra"]="ᨑ", ["ri"]="ᨑᨗ", ["ru"]="ᨑᨘ", ["ré"]="ᨑᨙ", ["ro"]="ᨑᨚ", ["re"]="ᨑᨛ",
["la"]="ᨒ", ["li"]="ᨒᨗ", ["lu"]="ᨒᨘ", ["lé"]="ᨒᨙ", ["lo"]="ᨒᨚ", ["le"]="ᨒᨛ",
["wa"]="ᨓ", ["wi"]="ᨓᨗ", ["wu"]="ᨓᨘ", ["wé"]="ᨓᨙ", ["wo"]="ᨓᨚ", ["we"]="ᨓᨛ",
["sa"]="ᨔ", ["si"]="ᨔᨗ", ["su"]="ᨔᨘ", ["sé"]="ᨔᨙ", ["so"]="ᨔᨚ", ["se"]="ᨔᨛ",
["ha"]="ᨖ", ["hi"]="ᨖᨗ", ["hu"]="ᨖᨘ", ["hé"]="ᨖᨙ", ["ho"]="ᨖᨚ", ["he"]="ᨖᨛ",
["a"]="ᨕ", ["i"]="ᨕᨗ", ["u"]="ᨕᨘ", ["é"]="ᨕᨙ", ["o"]="ᨕᨚ", ["e"]="ᨕᨛ",
["nga"]="ᨂ", ["ngi"]="ᨂᨗ", ["ngu"]="ᨂᨘ", ["ngé"]="ᨂᨙ", ["ngo"]="ᨂᨚ", ["nge"]="ᨂᨛ",
["nya"]="ᨎ", ["nyi"]="ᨎᨗ", ["nyu"]="ᨎᨘ", ["nyé"]="ᨎᨙ", ["nyo"]="ᨎᨚ", ["nye"]="ᨎᨛ",
["ngka"]="ᨃ", ["ngki"]="ᨃᨗ", ["ngku"]="ᨃᨘ", ["ngké"]="ᨃᨙ", ["ngko"]="ᨃᨚ", ["ngke"]="ᨃᨛ",
["mpa"]="ᨇ", ["mpi"]="ᨇᨗ", ["mpu"]="ᨇᨘ", ["mpé"]="ᨇᨙ", ["mpo"]="ᨇᨚ", ["mpe"]="ᨇᨛ",
["nra"]="ᨋ", ["nri"]="ᨋᨗ", ["nru"]="ᨋᨘ", ["nré"]="ᨋᨙ", ["nro"]="ᨋᨚ", ["nre"]="ᨋᨛ",
["nca"]="ᨏ", ["nci"]="ᨏᨗ", ["ncu"]="ᨏᨘ", ["ncé"]="ᨏᨙ", ["nco"]="ᨏᨚ", ["nce"]="ᨏᨛ",
};
function export.tr(text, lang, sc)
if (sc == "Latn") then
-- Lowercase
text = mw.ustring.lower(text)
-- Remove glottal stop
text = mw.ustring.gsub(text, "\'", "")
-- Replace character clusters
text = mw.ustring.gsub(text, "ngk[aeioué]", tt[sc])
text = mw.ustring.gsub(text, "mp[aeioué]", tt[sc])
text = mw.ustring.gsub(text, "nr[aeioué]", tt[sc])
text = mw.ustring.gsub(text, "nc[aeioué]", tt[sc])
text = mw.ustring.gsub(text, "ng[aeioué]", tt[sc])
text = mw.ustring.gsub(text, "ny[aeioué]", tt[sc])
-- Replace the rest of the characters
text = mw.ustring.gsub(text, "[kgnpbmtdnrcjyclwsh][aeioéu]", tt[sc])
-- Replace one-vowel syllables
text = mw.ustring.gsub(text, "[aeioué]", tt[sc])
-- Remove left-overs
text = mw.ustring.gsub(text, "[kgnpbmtdnrcjyclwsh-]", "")
end
return mw.ustring.toNFC(text)
end
return export