มอดูล:Telu-translit
หน้าตา
- The following documentation is located at มอดูล:Telu-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 Old Telugu, Ollari, โคณฑี, Kolami, Konda-Dora, Southeastern Kolami, สันสกฤต, 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: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, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above
return text
end
return export