This module will transliterate Old Persian language text.
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:peo-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 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
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 then
if need_hyphen then
t = "-"
end
t = alphabetic_tt
need_hyphen = true
else
need_hyphen = false
if numbers then
if preceding_num then
t = t + numbers
else
t = numbers
end
preceding_num = true
else
preceding_num = false
t = nonalphabetic_tt or c
end
end
end)
return table.concat(t)
end
return export