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-as-Beng-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 char = {
= "ৰ", = "ৱ"
}
-- Override returns text even if some characters cannot be transliterated.
-- If noKhandaTa is set, then "ৎ" will not be contextually substituted for "ত্", which is suitable (e.g.) for Sanskrit transliteration.
function export.tr(text, lang, sc, override, noKhandaTa)
local UTF8_char = "*"
local asBeng = require("Module:scripts").getByCode("as-Beng")
text = mw.ustring.toNFD(text)
text = string.gsub(text, UTF8_char, char)
text = require("Module:Deva-Beng-translit").tr(text, lang, sc, true, noKhandaTa)
-- Khanda Ta is not used in Sanskrit.
if not noKhandaTa and lang ~= "sa" then
text = mw.ustring.gsub(text, "ৎ(ৰ)", "ত্%1")
end
text = string.gsub(text, "্ৱ", "্ব")
local reducedText = mw.ustring.gsub(mw.ustring.gsub(text, "<.->", ""), "+", "")
if (mw.ustring.len(reducedText) == asBeng:countCharacters(reducedText) and not mw.ustring.find(text, "়়")) or override then
return text
else
return nil
end
end
return export