This module will transliterate Malayalam language text. It is also used to transliterate Badaga, Bellari, Beary, Kodava, Kurichiya, Konkani, Malavedan, Mannan, Tulu, Muduga, 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:ml-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local consonants = {
='k', ='kh', ='g', ='gh', ='ṅ',
='c', ='ch', ='j', ='jh', ='ñ',
='ṭ', ='ṭh', ='ḍ', ='ḍh', ='ṇ',
='t', ='th', ='d', ='dh', ='n',
='p', ='ph', ='b', ='bh', ='m',
='y', ='r', ='l', ='v',
='ś', ='ṣ', ='s', ='h',
='ḷ', ='ḻ', ='ṟ', ='ṉ', ='ṯ',
}
local diacritics = {
= 'ŭ',
= 'ā' ,
= 'i' ,
= 'ī' ,
= 'u' ,
= 'ū' ,
= 'r̥' ,
= 'r̥̄' ,
= 'e' ,
= 'ē' ,
= 'ai',
= 'o' ,
= 'ō' ,
= 'au', --archaic au
= 'au',
= 'l̥',
= 'l̥̄' ,
--virama, supresses the inherent vowel "a"
= '',
-- no diacritic
= 'a'
}
local nonconsonants = {
-- vowels
='a' , ='ā' , ='i' , ='ī' , ='u' , ='ū' ,
='r̥' , ='r̥̄' , ='l̥' , ='l̥̄', ='e' , ='ē' ,
='ai' , ='o' , ='ō' , ='au' , ='ī' ,
-- other symbols
='ṁ', -- anusvara
='ḥ' , -- visarga
='’', -- praślēṣam
-- chillus, consonants that never take vowels
='ṇ' , ='ṉ' , ='ṟ' , ='l' , ='ḷ' , ='k' , ='m', ='y', ='ḻ',
='ṟ',
-- digits
= '0', = '1', = '2', = '3', = '4',
= '5', = '6', = '7', = '8', = '9',
='10', ='100', ='1000',
='¼', ='½', ='¾', ='⅕', ='⅛',
='⅒', ='¹⁄₁₆', ='3⁄16', ='1⁄20',
='3⁄20', ='1⁄40', ='3⁄80', ='1⁄160',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local VIRAMA = '്'
-- final virama rules
if lang == "ml" or "tcy" then
text = mw.ustring.gsub(text, VIRAMA .. "(?)$", VIRAMA .. "ŭ%1")
text = mw.ustring.gsub(text, VIRAMA .. "(?) ", VIRAMA .. "ŭ%1 ")
end
text = mw.ustring.gsub(
text,
'()'..
'(\224\181\129??)',
function(c, d)
return consonants .. (diacritics or d)
end)
text = mw.ustring.gsub(text, '.', nonconsonants)
-- anusvara
text = mw.ustring.gsub(text, 'ṁ()', 'ṅ%1')
text = mw.ustring.gsub(text, 'ṁ()', 'ñ%1')
text = mw.ustring.gsub(text, 'ṁ()', 'ṇ%1')
text = mw.ustring.gsub(text, 'ṁ()', 'n%1')
text = mw.ustring.gsub(text, 'ṁ()', 'm%1')
text = mw.ustring.gsub(text, "ŭ (?)()", " %1%2") -- ŭ is elided before vowels
return text
end
return export