มอดูล:Knda-translit
- The following documentation is located at มอดูล:Knda-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 พทคะ, Bellari, Old Kannada, Kodava, Korra Koraga, กันนาดา, กงกัณ, ปรากฤต, สันสกฤต, Sholaga, ตูลู, Alu Kurumba, Betta Kurumba, Jennu Kurumba, and Ravula.
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:Knda-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)
['ಾ'] = 'า', ['ಿ'] = 'ิ', ['ೀ'] = 'ี', ['ು'] = 'ุ', ['ೂ'] = 'ู',
['ೃ'] = 'ฺฤ', ['ೄ'] = 'ฺฤๅ', ['ೢ'] = 'ฺฦ', ['ೣ'] = 'ฺฦๅ',
['ೕ'] = '~', ['ೖ'] = '~', ['ಂ'] = 'ํ', ['ಃ'] = 'ะ', ['್'] = 'ฺ',
['಼'] = u(0x0331), -- macron below
['ಁ'] = 'ํ์', -- 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
text = gsub(text, '([เแไโ])อฺ', 'อฺ%1')
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above
return text
end
return export