Module:aio-phk-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:aio-phk-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the Burmese script. It is also used to transliterate Aiton and Phake.
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:aio-phk-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 gsub = mw.ustring.gsub
local u = require("Module:string/char")
local con_cls = "([ကၵငꩡꩬၺတထꩫဒပၸမဗယꩺလဝꩭဢ])"
local med_cls = "([ျြၞ]?)"
local tt1 = {
-- consonants
["က"] = "k", ["ၵ"] = "kh", ["င"] = "ṅ",
["ꩡ"] = "c", ["ꩬ"] = "s", ["ၺ"] = "ñ",
["တ"] = "t", ["ထ"] = "th", ["ꩫ"] = "n", ["ဒ"] = "d",
["ပ"] = "p", ["ၸ"] = "ph", ["မ"] = "m", ["ဗ"] = "b",
["ယ"] = "y", ["ꩺ"] = "r", ["လ"] = "l", ["ဝ"] = "w",
["ꩭ"] = "h", ["ဢ"] = "ʼ",
-- medials
["ျ"] = "y", ["ြ"] = "r", ["ၞ"] = "w",
-- dependent vowels and diacritics (excluding front type)
["္"] = "", ["ႜ"] = "a", ["ႃ"] = "ā", ["ိ"] = "i", ["ီ"] = "ī",
["ု"] = "u", ["ူ"] = "ū", ["ွ"] = "o", ["်"] = "", ["ႝ"] = "y",
["ေ"] = "e", ["ံ"] = "ṃ",
-- punctuation marks
["၊"] = ",", ["။"] = ".", ["꩷"] = "!",
-- numerals
["꩸"] = "1", ["꩹"] = "2",
["၀"] = "0", ["၁"] = "1", ["၂"] = "2", ["၃"] = "3", ["၄"] = "4",
["၅"] = "5", ["၆"] = "6", ["၇"] = "7", ["၈"] = "8", ["၉"] = "9",
-- zero-width space (display it if it hides in a word)
[u(0x200B)] = "‼",
}
function export.tr(text, lang, sc)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
text = gsub(text, u(0xFE00), "") -- remove VS01
text = gsub(text, "ေ".."ႃ", "ō")
text = gsub(text, "ိ".."ု", "ü")
text = gsub(text, "ွ".."်", "aw")
text = gsub(text, "ၞ".."်", "aü")
text = gsub(text, con_cls .. med_cls .. con_cls .. "်", "%1%2a%3")
text = gsub(text, con_cls .. med_cls .. "([ႝံ])", "%1%2a%3")
text = gsub(text, ".", tt1)
return text
end
return export