Module:Translitteratio
Documentation for this module may be created at Module:Translitteratio/doc
local iface = {}
iface.abecedaria = function(frame)
local argg = frame.args
if argg[1] == nil or argg[1] == '' or argg[3] == nil
or argg[3] == '' then return '' end
local reddenda = {}
local nparia
local textus = mw.text.split(argg[3], '', true)
local delenda = mw.text.split(argg[1], '', true)
local substituenda
if argg[2] ~= nil then
substituenda = mw.text.split(argg[2], '', true)
else
substituenda = {}
end
local ndeletiones = #delenda
local nlitterae = #textus
local tmp = #substituenda
if ndeletiones > tmp then nparia = tmp else nparia = ndeletiones end
for idx1 = 1, nparia do
for idx2 = 1, nlitterae do
if textus[idx2] == delenda[idx1] then
textus[idx2] = substituenda[idx1]
end
end
end
for idx1 = nparia + 1, ndeletiones do
for idx2 = 1, nlitterae do
if textus[idx2] == delenda[idx1] then
textus[idx2] = nil
end
end
end
tmp = 0
for key, val in pairs(textus) do
if type(key) == 'number' then
tmp = tmp + 1
reddenda[tmp] = key
end
end
table.sort(reddenda)
for key, val in ipairs(reddenda) do reddenda[key] = textus[val] end
return table.concat(reddenda)
end
iface.aucta = function(frame)
local substituenda = {}
local nparia = 0
for key, val in pairs(frame.args) do
if type(key) == 'number' then
if nparia == nil or key > nparia then nparia = key end
substituenda[key - 1] = val
end
end
nparia = nparia - 1
if substituenda[0] == nil or substituenda[0] == '' or nparia < 2
or substituenda[nparia] == '' then return '' end
local reddenda = {}
local textus = mw.text.split(substituenda[nparia], '', true)
local delenda = mw.text.split(substituenda[0], '', true)
local ndeletiones = #delenda
local nlitterae = #textus
substituenda[0] = nil
substituenda[nparia] = nil
nparia = nparia - 1
if ndeletiones < nparia then nparia = ndeletiones end
for idx1 = 1, nparia do
for idx2 = 1, nlitterae do
if textus[idx2] == delenda[idx1] then
textus[idx2] = substituenda[idx1]
end
end
end
for idx1 = nparia + 1, ndeletiones do
for idx2 = 1, nlitterae do
if textus[idx2] == delenda[idx1] then
textus[idx2] = nil
end
end
end
local tmp = 0
for key, val in pairs(textus) do
if type(key) == 'number' then
tmp = tmp + 1
reddenda[tmp] = key
end
end
table.sort(reddenda)
for key, val in ipairs(reddenda) do reddenda[key] = textus[val] end
return table.concat(reddenda)
end
return iface