This module will transliterate text in the Tirhuta 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:Tirh-Deva-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 twoChars = {
= "क़", = "ख़", = "ग़", = "ज़", = "ड़", = "ढ़", = "फ़", = "य़", = "ळ",
= "ऎ", = "ऒ"
}
local oneChar = {
= "क", = "ख", = "ग", = "घ", = "ङ", = "च", = "छ", = "ज", = "झ", = "ञ", = "ट", = "ठ", = "ड", = "ढ", = "ण", = "त", = "थ", = "द", = "ध", = "न", = "प", = "फ", = "ब", = "भ", = "म", = "य", = "र", = "ल", = "व", = "श", = "ष", = "स", = "ह",
= "अ", = "आ", = "इ", = "ई", = "उ", = "ऊ", = "ऋ", = "ॠ", = "ऌ", = "ॡ", = "ए", = "ऐ", = "ओ", = "औ",
= "ा", = "ि", = "ी", = "ु", = "ू", = "ृ", = "ॄ", = "ॢ", = "ॣ", = "ॆ", = "े", = "ै", = "ॊ", = "ो", = "ौ", = "्",
= "ं", = "ः", = "ँ", = "ऽ", = "ॐ", = "॰",
= "०", = "१", = "२", = "३", = "४", = "५", = "६", = "७", = "८", = "९"
}
-- Override returns text even if some characters cannot be transliterated.
function export.tr(text, lang, sc, override)
local UTF8_char = "*"
local Deva = require("Module:scripts").getByCode("Deva")
for digraph, replacement in pairs(twoChars) do
text = string.gsub(text, digraph, replacement)
end
text = string.gsub(text, UTF8_char, oneChar)
local reducedText = mw.ustring.gsub(mw.ustring.gsub(text, "<.->", ""), "+", "")
if mw.ustring.len(reducedText) == Deva:countCharacters(reducedText) or override then
return text
else
return nil
end
end
return export