This module will transliterate text in the Devanagari script.
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:Deva-Newa-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 gsub = mw.ustring.gsub
local export = {}
local conv = {
='๐', ='๐', ='๐', ='๐', ='๐',
='๐', ='๐', ='๐', ='๐', ='๐',
='๐', ='๐', ='๐', ='๐', ='๐',
='๐', ='๐ ', ='๐ก', ='๐ข', ='๐ฃ',
='๐ฅ', ='๐ฆ', ='๐ง', ='๐จ', ='๐ฉ',
='๐ซ', ='๐ฌ', ='๐ฎ', ='๐ฐ', ='๐ฎ',
='๐ฑ', ='๐ฒ', ='๐ณ', ='๐ด',
='๐ต', ='๐ถ', ='๐ท', ='๐ธ', ='๐น', ='๐บ', ='๐ป',
='๐ผ', ='๐ฝ', ='๐พ', ='๐ฟ', ='๐', ='๐', = '๐', ='๐',
-- vowels
='๐', ='๐', ='๐', ='๐', ='๐', ='๐
', ='๐', ='๐',
='๐', ='๐', ='๐', ='๐', ='๐', ='๐',
-- chandrabindu
='๐',
-- anusvara
='๐',
-- visarga
='๐
',
-- avagraha
='๐',
--punctuation
='๐' ,
='๐',
='๐',
='๐',
--Vedic extensions
='๐ ', ='๐ก',
='๐', ='๐', ='๐', ='๐', ='๐', ='๐', ='๐', ='๐', ='๐', ='๐'
}
function export.tr(text, lang, sc)
text = gsub(
text,
".",
function(c)
return conv
end)
text = gsub(text, '๐ฃ๐๐ด', "๐ค")
text = gsub(text, '๐๐๐ด', "๐")
text = gsub(text, '๐ฌ๐๐ด', "๐ญ")
text = gsub(text, '๐ฎ๐๐ด', "๐ฏ")
text = gsub(text, '๐ฉ๐๐ด', "๐ช")
text = gsub(text, '๐๐๐ด', "๐")
--text = gsub(text, '๐$', "๐")
return text
end
return export