มอดูล:Cakm-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 in the อักษรจักมา. It is used to transliterate จักมา and บาลี.
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:Cakm-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
['𑅀'] = '๏', ['𑅁'] = 'ฯ', ['𑅂'] = '๚', ['𑅃'] = '?',
-- 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 = {
-- for convenience
['𑄱'..'𑄧'] = '𑄮', ['𑄲'..'𑄧'] = '𑄯',
}
local adjust1 = {
-- dependent vowels (front type)
['𑄬'] = 'เ%1', ['𑄭'] = 'ไ%1', ['𑄮'] = 'โ%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
for k, v in pairs(adjust0) do
text = gsub(text, k, v)
end
text = gsub(text, '.', tt)
for k, v in pairs(adjust1) do
text = gsub(text, letter_with_mark..k, v)
end
if lang == "pi" then
text = gsub(text, "ะ", "า") -- visarga is used as aa
text = gsub(text, "ว̱", "ว")
end
text = gsub(text, '([เแไโ])อฺ', 'อฺ%1')
text = gsub(text, 'ฯฯ', '๚')
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above
return text
end
return export