มอดูล:Telu-translit
- เอกสารการใช้งานต่อไปนี้ตั้งอยู่ที่ มอดูล:Telu-translit/documentation [แก้ไข]
- ลิงก์ที่เป็นประโยชน์: รายชื่อหน้าย่อย • การรวมมา • มอดูลทดสอบ
This module will transliterate text in the อักษรเตลูกู. It is used to transliterate สันสกฤต (sa
), Ollari (gdb
), เตลูกู (te
), Southeastern Kolami (nit
), โคณฑี (gon
), Konda-Dora (kfc
), and Kolami (kfb
).
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:Telu-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 above
['ఁ'] = 'น̆', -- candrabindu rightside
-- 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า',
}
--[[
-- About fractions: http://www.unicode.org/L2/L2008/08199r-3471-oriyafractions.pdf
local numerator = { ['౸'] = 0, ['౹'] = 4, ['౺'] = 8, ['౻'] = 12, ['౦'] = 0, ['౼'] = 1, ['౽'] = 2, ['౾'] = 3, }
local fraction = {
{'1','16'}, {'1','8'}, {'3','16'}, {'1','4'}, {'5','16'}, {'3','8'}, {'7','16'}, {'1','2'},
{'9','16'}, {'5','8'}, {'11','16'}, {'3','4'}, {'13','16'}, {'7','8'}, {'15','16'},
}
function export.convertFraction(text)
local sum = 0
local c
for c in mw.ustring.gmatch(text, '[౦౸-౾]') do
sum = sum + numerator[c]
end
return mw.getCurrentFrame():expandTemplate{ title = 'เศษ', args = fraction[sum] }
end
--]]
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)
-- แปลงเศษส่วน
--text = gsub(text, '[౦౸-౾][౦౸-౾]?', export.convertFraction)
for k, v in pairs(adjust1) do
text = gsub(text, letter_with_mark..k, v)
end
text = gsub(text, '([เแไโ])อฺ', 'อฺ%1')
text = gsub(text, 'ะ'..letter_with_mark..'ฺ', '็%1ฺ') -- เปลี่ยน ะ ที่มีตัวสะกดตามเป็นไม้ไต่คู้
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above
return text
end
return export