This module will transliterate text in the Inscriptional Pahlavi script. It is used to transliterate Middle Persian.
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:Phli-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 tt = {
= "ʾ", -- aleph
= "b", -- beth
= "g", -- gimil
= "d", -- daleth
= "h", -- he
= "ʿ", -- waw-ayin-resh
= "z", -- zayin
= "ḥ", -- heth
= "ṭ", -- teth
= "y", -- yodh
= "k", -- kaph
= "l", -- lamedh
= "m", -- mem-qoph
= "n", -- nun
= "s", -- samekh
= "p", -- pe
= "c", -- sadhe
= "š", -- shin
= "t", -- taw
}
local numbers = {
= 1,
= 2,
= 3,
= 4,
= 10,
= 20,
= 100,
= 1000,
}
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 Phli, do not transliterate
if sc ~= "Phli" then
return
end
-- Category to catch automatic transcriptions of waw-ayin-resh and mem-qoph
-- ]
local categories
if mw.ustring.match(text, "") then
categories = {"Automatic Inscriptional Pahlavi transliterations containing ambiguous characters"}
end
if mw.ustring.match(text, "") then
text = mw.ustring.gsub(text, "+", export.convert_numbers)
end
-- Transliterate characters
text = mw.ustring.gsub(text, ".", tt)
return text, nil, categories
end
return export