Module:Tirh-Deva-translit
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Tirh-Deva-translit/doc
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 = "[%z\1-\127\194-\244][\128-\191]*"
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, "<.->", ""), "[%s%p\n]+", "")
if mw.ustring.len(reducedText) == Deva:countCharacters(reducedText) or override then
return text
else
return nil
end
end
return export