มอดูล:Mtei-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:Mtei-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 tt = {
-- consonants
['ꯀ'] = 'ก', ['ꯈ'] = 'ข', ['ꯒ'] = 'ค', ['ꯘ'] = 'ฆ', ['ꯉ'] = 'ง',
['ꯆ'] = 'จ', ['ꫢ'] = 'ฉ', ['ꯖ'] = 'ช', ['ꯓ'] = 'ฌ', ['ꫣ'] = 'ญ',
['ꫤ'] = 'ฏ', ['ꫥ'] = 'ฐ', ['ꫦ'] = 'ฑ', ['ꫧ'] = 'ฒ', ['ꫨ'] = 'ณ',
['ꯇ'] = 'ต', ['ꯊ'] = 'ถ', ['ꯗ'] = 'ท', ['ꯙ'] = 'ธ', ['ꯅ'] = 'น',
['ꯄ'] = 'ป', ['ꯐ'] = 'ผ', ['ꯕ'] = 'พ', ['ꯚ'] = 'ภ', ['ꯃ'] = 'ม',
['ꯌ'] = 'ย', ['ꯔ'] = 'ร', ['ꯂ'] = 'ล', ['ꯋ'] = 'ว',
['ꫩ'] = 'ศ', ['ꫪ'] = 'ษ', ['ꯁ'] = 'ส', ['ꯍ'] = 'ห',
-- finals
['ꯛ'] = 'กฺ', ['ꯜ'] = 'ลฺ', ['ꯝ'] = 'มฺ', ['ꯞ'] = 'ปฺ',
['ꯟ'] = 'นฺ', ['ꯠ'] = 'ตฺ', ['ꯡ'] = 'งฺ', ['ꯢ'] = 'ยฺ',
-- independent vowels
['ꯑ'] = 'อ', ['ꯏ'] = 'อิ', ['ꯎ'] = 'อุ', ['ꫠ'] = 'เอ', ['ꫡ'] = 'โอ',
-- dependent vowels and diacritics (excluding front type)
['ꯥ'] = 'า', ['ꯤ'] = 'ิ', ['ꫫ'] = 'ี', ['ꯨ'] = 'ุ', ['ꫬ'] = 'ู',
['ꯪ'] = 'ํ', ['ꫵ'] = 'ะ', ['꫶'] = 'ฺ',
-- 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)] = "‼",
-- zero-width non-joiner and joiner (display it if it hides in a word)
[u(0x200C)] = "₋",
[u(0x200D)] = "₊",
}
local adjust1 = {
-- dependent vowels (front type)
['ꯦ'] = 'เ%1', ['ꯩ'] = 'ไ%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
text = gsub(text, '.', tt)
for k, v in pairs(adjust1) do
text = gsub(text, '(.)'..k, v)
end
return text
end
return export