Module:peo-translit
Jump to navigation
Jump to search
Documentation for this module may be created at Module:peo-translit/doc
local export = {}
local alphabetic_tt = {
-- this should only contain alphabetic characters
["๐ "] = "a",
["๐ก"] = "i",
["๐ข"] = "u",
["๐ฃ"] = "k",
["๐ค"] = "ku",
["๐ฅ"] = "g",
["๐ฆ"] = "gu",
["๐ง"] = "x",
["๐จ"] = "c",
["๐ฉ"] = "j",
["๐ช"] = "ji",
["๐ซ"] = "t",
["๐ฌ"] = "tu",
["๐ญ"] = "d",
["๐ฎ"] = "di",
["๐ฏ"] = "du",
["๐ฐ"] = "ฮธ",
["๐ฑ"] = "p",
["๐ฒ"] = "b",
["๐ณ"] = "f",
["๐ด"] = "n",
["๐ต"] = "nu",
["๐ถ"] = "m",
["๐ท"] = "mi",
["๐ธ"] = "mu",
["๐น"] = "y",
["๐บ"] = "v",
["๐ป"] = "vi",
["๐ผ"] = "r",
["๐ฝ"] = "ru",
["๐พ"] = "l",
["๐ฟ"] = "s",
["๐"] = "z",
["๐"] = "ลก",
["๐"] = "รง",
["๐"] = "h",
["๐"] = "AM", -- Auramazdฤ
["๐"] = "AM", -- Auramazdฤ
["๐"] = "AMha", -- Auramazdฤha
["๐"] = "Xล ", -- xลกฤyathiya
["๐"] = "DH", -- dahyฤuลก
["๐"] = "DH", -- dahyฤuลก
["๐"] = "BG", -- baga
["๐"] = "BU", -- bลซmiลก
}
local nonalphabetic_tt = {
["๐"] = " : ", --word divider
}
local numbers = {
["๐"] = 1,
["๐"] = 2,
["๐"] = 10,
["๐"] = 20,
["๐"] = 100,
}
function export.convert_numbers(numeric_str)
local total = 0
for c in mw.ustring.gmatch(numeric_str, ".") do
total = total + numbers[c]
end
return total
end
function export.tr(text, lang, sc)
-- If the script is not Xpeo, do not transliterate
if sc ~= "Xpeo" then
return
end
local t = {}
local preceding_num = false
local need_hyphen = false
-- Transliterate characters
text = mw.ustring.gsub(text,
".",
function(c)
if alphabetic_tt[c] then
if need_hyphen then
t[#t + 1] = "-"
end
t[#t + 1] = alphabetic_tt[c]
need_hyphen = true
else
need_hyphen = false
if numbers[c] then
if preceding_num then
t[#t] = t[#t] + numbers[c]
else
t[#t + 1] = numbers[c]
end
preceding_num = true
else
preceding_num = false
t[#t + 1] = nonalphabetic_tt[c] or c
end
end
end)
return table.concat(t)
end
return export