มอดูล:pwo-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate ภาษากะเหรี่ยงโปตะวันตก 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:pwo-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 = mw.ustring.char
local tt1 = {
-- consonants
["က"] = "kə", ["ခ"] = "khə", ["ဂ"] = "ghə", ["ဃ"] = "xə", ["င"] = "ngə",
["စ"] = "sə", ["ဆ"] = "sə", ["ဇ"] = "jə", ["ၡ"] = "shə", ["ည"] = "nyə",
["တ"] = "tə", ["ထ"] = "hṭə", ["ဒ"] = "də", ["န"] = "nə",
["ပ"] = "pə", ["ဖ"] = "phə", ["ဘ"] = "bə", ["မ"] = "mə",
["ယ"] = "yə", ["ရ"] = "rə", ["လ"] = "lə", ["ဝ"] = "wə", ["ဎ"] = "pə",
["ၥ"] = "thə", ["ဟ"] = "hə", ["အ"] = "ʼə", ["ဧ"] = "ahh ", ["ၦ"] = "plə",
-- medials
["ှ"] = "ˣhgə", ["ၠ"] = "ˣyə", ["ြ"] = "ˣrə", ["ျ"] = "ˣlə", ["ွ"] = "ˣwə",
-- dependent vowels
["ါ"] = "̄", ["ံ"] = "ey", ["ု"] = "ọ", ["ူ"] = "ū", ["ၧ"] = "ȳ",
["့"] = "n", ["ဲ"] = "ite", ["ိ"] = "ụ", ["ီ"] = "ō", ["ၭ"] = "̣",
["ၨ"] = "u", ["ၪ"] = "̄", ["ၫ"] = "̄", ["ၩ"] = "̣", ["ၬ"] = "̣",
-- numerals
["၀"] = "0", ["၁"] = "1", ["၂"] = "2", ["၃"] = "3", ["၄"] = "4",
["၅"] = "5", ["၆"] = "6", ["၇"] = "7", ["၈"] = "8", ["၉"] = "9",
-- zero-width space (display it if it hides in a word)
[u(0x200B)] = "‼",
}
local adjust0 = {
-- tones
["ၪံ"] = u(0x0331), ["ၬံ"] = u(0x0323), ["း"] = u(0x0308), ["ၧံ"] = u(0x0300),
["ၩံ"] = u(0x0304), --prolonged
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
for k, v in pairs(adjust0) do
text = gsub(text, k, v)
end
text = gsub(text, ".", tt1)
text = gsub(text, "əˣ", "")
text = gsub(text, "ə([aeiou])", "%1")
text = gsub(text, "ə", "a ")
text = gsub(text, "%s(["..u(0x0331)..u(0x0323)..u(0x0308)..u(0x0300)..u(0x0304).."])", "%1 ")
text = gsub(text, "(.-)%s*$", "%1") -- remove space at the end
return text
end
return export