This module will transliterate Kannada language text per WT:KN TR. It is also used to transliterate Badaga, Bellari, Beary, Middle Kannada, Old Kannada, Kodava, Korra Koraga, Konkani, Sholaga, Tulu, 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:kn-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', ='ḷ', ='ḻ',
='f', ='z', ='ḻ',
}
local diacritics = {
= 'ā' , ='i' , ='ī' , ='u' , ='ū' , ='ṛ' , ='r̥̄' ,
='e' , ='ē' , ='ai' , ='o' , ='ō' , ='au', = 'è',
= 'l̥', ='l̥̄'
}
local nonconsonants = {
-- vowels
='a' , ='ā' , ='i' , ='ī' , ='u' , ='ū' ,
='ṛ' , ='r̥̄' , ='l̥' , ='l̥̄', ='e' , ='ē' ,
='ai' , ='o' , ='ō' , ='au' , ='aṃ' , ='ah' ,
-- other symbols
='ṃ', -- anusvara
='ḥ', -- visarga
--halant, supresses the inherent vowel "a"
='',
-- digits
= '0', = '1', = '2', = '3', = '4',
= '5', = '6', = '7', = '8', = '9',
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local VIRAMA = '್'
-- final virama rules
if lang == "tcy" or lang == "kfa" or lang == "kfd" or lang == "dra-bry" then
text = mw.ustring.gsub(text, VIRAMA .. "(?)$", VIRAMA .. "ŭ%1")
text = mw.ustring.gsub(text, VIRAMA .. "(?) ", VIRAMA .. "ŭ%1 ")
end
text = mw.ustring.gsub(
text,
'(?)'..
'(?)',
function(c, d)
-- mw.log('match', c, d)
c = consonants or c
if d == "" then
return c .. 'a'
else
return c .. (diacritics or d)
end
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')
return text
end
return export