Module:Deva-Mong-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
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.
Functions
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
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[1], replacement[2])
end
return text
end
return export