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-Limb-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, '()(?)(?)(़?)(?)(?)ᤁ्', '%1%2%3%4%5%6ᤰ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤅ्', '%1%2%3%4%5%6ᤱ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤋ्', '%1%2%3%4%5%6ᤳ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤏ्', '%1%2%3%4%5%6ᤴ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤐ्', '%1%2%3%4%5%6ᤵ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤔ्', '%1%2%3%4%5%6ᤶ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤖ्', '%1%2%3%4%5%6ᤷ')
text = gsub(text, '()(?)(?)(़?)(?)(?)ᤗ्', '%1%2%3%4%5%6ᤸ')
text = gsub(text, '्ᤖ', 'ᤪ')
text = gsub(text, '्ᤕ', 'ᤩ')
text = gsub(text, '्ᤘ', 'ᤫ')
text = gsub(text, 'ज्ञ', 'ᤝ')
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