มอดูล:kjp-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:kjp-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 diacritics = {
[mw.ustring.char(0x1039)] = "",
[mw.ustring.char(0x103D)] = "w",
[mw.ustring.char(0x1060)] = "l",
[mw.ustring.char(0x103C)] = "r",
[mw.ustring.char(0x103B)] = "j",
[mw.ustring.char(0x105E)] = "n",
[mw.ustring.char(0x102E)] = "I",
[mw.ustring.char(0x1031)] = "E",
[mw.ustring.char(0x1032)] = "Ä",
[mw.ustring.char(0x103A)] = "V",
[mw.ustring.char(0x103E)] = "H",
[mw.ustring.char(0x102B)] = "A",
[mw.ustring.char(0x102C)] = "A",
[mw.ustring.char(0x1038)] = "3",
[mw.ustring.char(0x1030)] = "Y",
[mw.ustring.char(0x102F)] = "U",
[mw.ustring.char(0x102D)] = "Ï",
[mw.ustring.char(0x108B)] = "2",
[mw.ustring.char(0x1036)] = "Q",
[mw.ustring.char(0x1037)] = "4",
}
local consonants = {
["က"]="k", ["ခ"]="kh", ["ဂ"]="K", ["ဃ"]="kh", ["င"]="ŋ",
["စ"]="c", ["ဆ"]="ch", ["ဇ"]="c", ["ဈ"]="ch", ["ည"]="ɲ",
["ဋ"]="t", ["ဌ"]="th", ["ဍ"]="d", ["ဎ"]="d", ["ဏ"]="n",
["တ"]="t", ["ထ"]="th", ["ဒ"]="T", ["ဓ"]="th", ["န"]="n",
["ပ"]="p", ["ဖ"]="ph", ["ဗ"]="p", ["ဘ"]="ph", ["မ"]="m",
["ယ"]="j", ["ရ"]="r", ["လ"]="l", ["ဝ"]="w", ["သ"]="θ",
["ဟ"]="h", ["ဠ"]="l", ["အ"]="ʔ", ["ၜ"]="b", ["ၯ"]="ɣ",
["ၰ"]="x",
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(text, ".", diacritics)
text = mw.ustring.gsub(text, ".", consonants)
-- making sure U and Ä is rendered correctly
text = mw.ustring.gsub(text, "([ÏIÄ])([UY])", "%2%1")
text = mw.ustring.gsub(text, "([ÏI])Ä", "Ä%1")
-- vowels
text = mw.ustring.gsub(text, "EAwV2", "ʊ̄")
text = mw.ustring.gsub(text, "EAw4V", "ʊ̂")
text = mw.ustring.gsub(text, "UÏŋV2", "ə̄ɴ")
text = mw.ustring.gsub(text, "UÏŋV3", "ə́ɴ")
text = mw.ustring.gsub(text, "UÏŋ4V", "ə̂ɴ")
text = mw.ustring.gsub(text, "UQwV3", "ó")
text = mw.ustring.gsub(text, "UÏwV2", "ō")
text = mw.ustring.gsub(text, "AnV2", "āɴ")
text = mw.ustring.gsub(text, "AnV3", "áɴ")
text = mw.ustring.gsub(text, "An4V", "âɴ")
text = mw.ustring.gsub(text, "AŋV2", "āiɴ")
text = mw.ustring.gsub(text, "AŋV3", "áiɴ")
text = mw.ustring.gsub(text, "Aŋ4V", "âiɴ")
text = mw.ustring.gsub(text, "EAhV", "ʊ́")
text = mw.ustring.gsub(text, "EAtV", "ó")
text = mw.ustring.gsub(text, "EAwV", "ʊ̀")
text = mw.ustring.gsub(text, "EnV2", "ī̱ɴ")
text = mw.ustring.gsub(text, "EnV3", "í̱ɴ")
text = mw.ustring.gsub(text, "En4V", "î̱ɴ")
text = mw.ustring.gsub(text, "EwV2", "ī̱")
text = mw.ustring.gsub(text, "Ew4V", "î̱")
text = mw.ustring.gsub(text, "ÏŋV2", "ēiɴ")
text = mw.ustring.gsub(text, "ÏŋV3", "éiɴ")
text = mw.ustring.gsub(text, "Ïŋ4V", "êiɴ")
text = mw.ustring.gsub(text, "QŋV2", "ōɴ")
text = mw.ustring.gsub(text, "QŋV3", "óɴ")
text = mw.ustring.gsub(text, "Qŋ4V", "ôɴ")
text = mw.ustring.gsub(text, "UÄÏ2", "wē")
text = mw.ustring.gsub(text, "UÄÏ3", "wé")
text = mw.ustring.gsub(text, "UÄÏ4", "wê")
text = mw.ustring.gsub(text, "UÏhV", "ɨ́")
text = mw.ustring.gsub(text, "UÏŋV", "ə̀ɴ")
text = mw.ustring.gsub(text, "UÏTV", "ɨ̀")
text = mw.ustring.gsub(text, "UŋV2", "ə̄ɯɴ")
text = mw.ustring.gsub(text, "UŋV3", "ə́ɯɴ")
text = mw.ustring.gsub(text, "Uŋ4V", "ə̂ɯɴ")
text = mw.ustring.gsub(text, "UÏtV", "ó")
text = mw.ustring.gsub(text, "UÏwV", "ò")
text = mw.ustring.gsub(text, "AnV", "àɴ")
text = mw.ustring.gsub(text, "AŋV", "àiɴ")
text = mw.ustring.gsub(text, "EhV", "í̱")
text = mw.ustring.gsub(text, "EnV", "ì̱ɴ")
text = mw.ustring.gsub(text, "EtV", "é")
text = mw.ustring.gsub(text, "EwV", "ì̱")
text = mw.ustring.gsub(text, "HVE", "í̱")
text = mw.ustring.gsub(text, "ÏkV", "ái")
text = mw.ustring.gsub(text, "ÏŋV", "èiɴ")
text = mw.ustring.gsub(text, "j4V", "ɛ̂")
text = mw.ustring.gsub(text, "([nŋ])V2", "āɴ")
text = mw.ustring.gsub(text, "([nŋ])V3", "áɴ")
text = mw.ustring.gsub(text, "([nŋ])4V", "âɴ")
text = mw.ustring.gsub(text, "QŋV", "òɴ")
text = mw.ustring.gsub(text, "UÄ2", "wī")
text = mw.ustring.gsub(text, "UÄ3", "wí")
text = mw.ustring.gsub(text, "UÄ4", "wî")
text = mw.ustring.gsub(text, "UÄÏ", "wè")
text = mw.ustring.gsub(text, "UÏ2", "ɨ̄")
text = mw.ustring.gsub(text, "UÏ3", "ɨ̂")
text = mw.ustring.gsub(text, "UŋV", "ə̀ɯɴ")
text = mw.ustring.gsub(text, "UkV", "áʊ")
text = mw.ustring.gsub(text, "UKV", "àʊ")
text = mw.ustring.gsub(text, "UQ2", "ōʊɴ")
text = mw.ustring.gsub(text, "UQ3", "óʊɴ")
text = mw.ustring.gsub(text, "UQ4", "ôʊɴ")
text = mw.ustring.gsub(text, "wV2", "ɔ̄")
text = mw.ustring.gsub(text, "w4V", "ɔ̂")
text = mw.ustring.gsub(text, "VU", "ə")
text = mw.ustring.gsub(text, "AÄ", "ɛ̄")
text = mw.ustring.gsub(text, "ÄA", "ɛ̄")
text = mw.ustring.gsub(text, "AV", "ài")
text = mw.ustring.gsub(text, "A2", "ā")
text = mw.ustring.gsub(text, "A4", "â")
text = mw.ustring.gsub(text, "E4", "ê")
text = mw.ustring.gsub(text, "I2", "ī")
text = mw.ustring.gsub(text, "I3", "í")
text = mw.ustring.gsub(text, "I4", "î")
text = mw.ustring.gsub(text, "jV", "ɛ̀")
text = mw.ustring.gsub(text, "QE", "é")
text = mw.ustring.gsub(text, "hV", "ɔ́")
text = mw.ustring.gsub(text, "HV", "ɔ́")
text = mw.ustring.gsub(text, "([nŋ])V", "àɴ")
text = mw.ustring.gsub(text, "UÄ", "wì")
text = mw.ustring.gsub(text, "wV", "ɔ̀")
text = mw.ustring.gsub(text, "UQ", "òʊɴ")
text = mw.ustring.gsub(text, "Y2", "ɯ̄")
text = mw.ustring.gsub(text, "Y3", "ɯ́")
text = mw.ustring.gsub(text, "Y4", "ɯ̂")
text = mw.ustring.gsub(text, "A", "à")
text = mw.ustring.gsub(text, "Ä", "ɛ́")
text = mw.ustring.gsub(text, "E", "è")
text = mw.ustring.gsub(text, "I", "ì")
text = mw.ustring.gsub(text, "K", "k")
text = mw.ustring.gsub(text, "T", "t")
text = mw.ustring.gsub(text, "Y", "ɯ̀")
text = mw.ustring.gsub(text, "([kgŋcɲtdnpbmjrlwθhʔɣx])3", "%1á")
-- interpunction
text = mw.ustring.gsub(text, "၊", ",")
text = mw.ustring.gsub(text, "။", ".")
-- spaces
text = mw.ustring.gsub(text, "([aeiouàèìòùáéíóúāēīōūâêîôûɨʊɯɛɔɴə" .. mw.ustring.char(0x0300) .. mw.ustring.char(0x0301) .. mw.ustring.char(0x0302) .. mw.ustring.char(0x0304) .. mw.ustring.char(0x0331) .. "])([kgŋcɲtdnpbmjrlwθhʔɣx])", "%1 %2")
return(text)
end
return export