มอดูล:Brah-translit
หน้าตา
- The following documentation is located at มอดูล:Brah-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 อักษรพราหมี. It is used to transliterate ปรากฤตแบบอโศก, Kamarupi Prakrit, โคตาน, ทมิฬเก่า, บาลี, ปรากฤต, สันสกฤต, และตุมซุก.
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:Brah-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 letter_with_mark = "(.["..u(0x0300).."-"..u(0x036F).."]?)"
local tt = {
-- consonants
["𑀓"] = "ก", ["𑀔"] = "ข", ["𑀕"] = "ค", ["𑀖"] = "ฆ", ["𑀗"] = "ง",
["𑀘"] = "จ", ["𑀙"] = "ฉ", ["𑀚"] = "ช", ["𑀛"] = "ฌ", ["𑀜"] = "ญ",
["𑀝"] = "ฏ", ["𑀞"] = "ฐ", ["𑀟"] = "ฑ", ["𑀠"] = "ฒ", ["𑀡"] = "ณ",
["𑀢"] = "ต", ["𑀣"] = "ถ", ["𑀤"] = "ท", ["𑀥"] = "ธ", ["𑀦"] = "น",
["𑀧"] = "ป", ["𑀨"] = "ผ", ["𑀩"] = "พ", ["𑀪"] = "ภ", ["𑀫"] = "ม",
["𑀬"] = "ย", ["𑀭"] = "ร", ["𑀮"] = "ล", ["𑀯"] = "ว",
["𑀰"] = "ศ", ["𑀱"] = "ษ", ["𑀲"] = "ส", ["𑀳"] = "ห", ["𑀴"] = "ฬ",
["𑀵"] = "ฬ̱", ["𑀶"] = "ร̱", ["𑀷"] = "น̱",
-- independent vowels
["𑀅"] = "อ", ["𑀆"] = "อา", ["𑀇"] = "อิ", ["𑀈"] = "อี", ["𑀉"] = "อุ", ["𑀊"] = "อู",
["𑀋"] = "ฤ", ["𑀌"] = "ฤๅ", ["𑀍"] = "ฦ", ["𑀎"] = "ฦๅ",
["𑀏"] = "เอ", ["𑀐"] = "ไอ", ["𑀑"] = "โอ", ["𑀒"] = "เอา",
-- dependent vowels and diacritics (excluding front type)
["𑀸"] = "า", ["𑀹"] = "า", ["𑀺"] = "ิ", ["𑀻"] = "ี", ["𑀼"] = "ุ", ["𑀽"] = "ู",
["𑀾"] = "ฺฤ", ["𑀿"] = "ฺฤๅ", ["𑁀"] = "ฺฦ", ["𑁁"] = "ฺฦๅ",
["𑀁"] = "ํ", ["𑀂"] = "ห์", ["𑁆"] = "ฺ",
["𑀀"] = "ม̐", -- candrabindu
-- marks
["𑀃"] = "⧖", ["𑀄"] = "⨂",
["𑁇"] = "ฯ", ["𑁈"] = "๚", ["𑁉"] = "‧", ["𑁊"] = "⁚",
["𑁋"] = "—", ["𑁌"] = "๛", ["𑁍"] = "๏",
-- zero-width space (display it if it hides in a word)
[u(0x200B)] = "‼",
}
local adjust1 = {
-- dependent vowels (front type)
["𑁂"] = "เ%1", ["𑁃"] = "ไ%1", ["𑁄"] = "โ%1", ["𑁅"] = "เ%1า",
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
text = gsub(text, ".", tt)
for k, v in pairs(adjust1) do
text = gsub(text, letter_with_mark..k, v)
end
text = gsub(text, "([เแไโ])อฺ", "อฺ%1")
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331).."([ุ-ฺ])", u(0x0304).."%1") -- macron below > macron above
return text
end
return export