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-Knda-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, nakaaraPollu, archaicLlla, archaicRra)
local UTF8_char = "*"
local Knda = require("Module:scripts").getByCode("Knda")
text = mw.ustring.toNFD(text)
text = string.gsub(text, UTF8_char, char)
-- Nakaara Pollu is used in Sanskrit.
if nakaaraPollu or lang == "sa" then
text = mw.ustring.gsub(text, "ನ್()", "ೝ%1")
text = mw.ustring.gsub(text, "ನ್$", "ೝ")
end
if archaicLlla then
text = mw.ustring.gsub(text, "ಳ಼", "ೞ")
end
if archaicRra then
text = mw.ustring.gsub(text, "ರ಼", "ಱ")
end
text = mw.ustring.toNFC(text)
local reducedText = mw.ustring.gsub(mw.ustring.gsub(text, "<.->", ""), "+", "")
if (mw.ustring.len(reducedText) == Knda:countCharacters(reducedText) and not mw.ustring.find(text, "಼಼")) or override then
return text
else
return nil
end
end
return export