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-Mong-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 tt = {
{"(.*)()", "%2%1"}, {"(.*)(ऽ+)", "%2%1"},
{"क", "ᢉᠠ"}, {"ख", "ᠻᠠ"}, {"ग", "ᠺᠠ"}, {"घ", "ᠺᠾᠠ"}, {"ङ", "ᢊᠠ"},
{"च", "ᢋᠠ"}, {"छ", "ᠼᠠ"}, {"ज", "ᠽᠠ"}, {"झ", "ᠽᠾᠠ"}, {"ञ", "ᡛᠠ"},
{"ट", "ᢌᠠ"}, {"ठ", "ᢍᠠ"}, {"ड", "ᢎᠠ"}, {"ढ", "ᢎᠾᠠ"}, {"ण", "ᢏᠠ"},
{"त", "ᢐᠠ"}, {"थ", "ᠲᠠ"}, {"द", "ᢑᠠ"}, {"ध", "ᢑᠾᠠ"}, {"न", "ᠨᠠ"},
{"प", "ᢒᠠ"}, {"फ", "ᠹᠠ"}, {"ब", "ᠪᠠ"}, {"भ", "ᠪᠾᠠ"}, {"म", "ᠮᠠ"},
{"य", "ᠶ᠋ᠠ"}, {"र", "ᠷᠠ"}, {"ल", "ᠯᠠ"}, {"व", "ᠸᠠ"},
{"श", "ᠱᠠ"}, {"ष", "ᢔᠠ"}, {"स", "ᠰᠠ"}, {"ह", "ᠾᠠ"},
{"अ", "ᠠ"}, {"आ", "ᠠᢗ"}, {"इ", "ᠢ"}, {"ई", "ᠢᠢ"}, {"उ", "ᠤ"}, {"ऊ", "ᠤᠤ"}, {"ऋ", "ᠷᠢ"}, {"ॠ", "ᠷᠢᠢ"},
{"ऌ", "ᠯᠢ"}, {"ॡ", "ᠯᠢᠢ"}, {"ए", "ᠧ"}, {"ऐ", "ᠧᠧ"}, {"ओ", "ᠣᠸᠠ"}, {"औ", "ᠣᠸᠸᠠ"},
{"ँ", "ᢀ"}, {"ं", "ᢀ᠋"}, {"ः", "ᢁ᠋"}, {"ऽऽऽ", "ᢆ"}, {"ऽ", "ᢅ"},
{"०", "᠐"}, {"१", "᠑"}, {"२", "᠒"}, {"३", "᠓"}, {"४", "᠔"}, {"५", "᠕"}, {"६", "᠖"}, {"७", "᠗"}, {"८", "᠘"}, {"९", "᠙"},
{"॥", "᠃ "}, {"।", "᠂ "},
{"ᳵ", "ᢂ"}, {"ᳶ", "ᢄ"},
{"ॐ", "ᢀᠣᠸᠠ"},
{"-", "᠊"},
{"(्)ᠸᠠ()", "%1ᢦ%2"}, {"(्)ᠸᠠ$", "%1ᢦ"}, {"(्)ᠶ᠋ᠠ(ा?%s)", "%1ᠶᠠ%2"}, {"(्)ᠶ᠋ᠠ(ा?)$", "%1ᠶᠠ%2"},
{"ᠠा", "ᠠᢗ"}, {"ᠠि", "ᠢ"}, {"ᠠी", "ᠢᠢ"}, {"ᠠु", "ᠤ"}, {"ᠠू", "ᠤᠤ"}, {"ᠠृ", "ᠷᠢ"}, {"ᠠॄ", "ᠷᠢᠢ"},
{"ᠠॢ", "ᠯᠢ"}, {"ᠠॣ", "ᠯᠢᠢ"}, {"ᠠे", "ᠧ"}, {"ᠠै", "ᠧᠧ"}, {"ᠠो", "ᠣᠸᠠ"}, {"ᠠौ", "ᠣᠸᠸᠠ"}, {"ᠠ्", ""}, {"ᢦा", "ᢦᠠ"},
{"ᠯᠾ", "ᡀ"},
{"ᠠᢗ()", "ᠠᠠ%1"}, {"ᠠᢗ$", "ᠠᠠ"}, {"^ᠠ()", "ᠠ᠋%1"}, {"()ᠠ()", "%1ᠠ᠋%2"}, {"^ᠠ$", "ᠠ᠋"}, {"()ᠠ$", "%1ᠠ᠋"}, {"(ᠣᠸᠸ?ᠠ)᠋", "%1"},
{"()(.᠋?)", "%2%1"},
{"\n", " "}, {"<br>", " "},
{" ()", "%1"},
{" +", " "}, {"^ +(.*)", "%1"}, {"(.*) +$", "%1"}
}
function export.tr(text)
text = mw.ustring.lower(text)
for _, replacement in ipairs(tt) do
text = mw.ustring.gsub(text, replacement, replacement)
end
return text
end
return export