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-Tirh-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.
function export.tr(text, lang, sc, override)
local UTF8_char = "*"
local Tirh = require("Module:scripts").getByCode("Tirh")
text = string.gsub(text, UTF8_char, char)
local reducedText = mw.ustring.gsub(mw.ustring.gsub(text, "<.->", ""), "+", "")
if (mw.ustring.len(reducedText) == Tirh:countCharacters(reducedText) and not mw.ustring.find(text, "๐๐")) or override then
return text
else
return nil
end
end
return export