Module:Translitteratio
Appearance
la:Modulus:Translitteratio
This page is a soft redirect.
The source code of this script comes from upstream, in this case la.wikipedia.
require[[strict]]
local ifacies = {}
ifacies.abecedaria = function(frame)
local argg = frame.args
if argg[1] == nil or argg[1] == '' then return '' end
if argg[2] == nil or argg[2] == '' then return argg[1] end
local reddenda = {}
local nparia
local textus = mw.text.split(argg[1], '', true)
local delenda = mw.text.split(argg[2], '', true)
local substituenda
if argg[3] ~= nil then
substituenda = mw.text.split(argg[3], '', 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
ifacies.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 - 2] = val
end
end
nparia = nparia - 2
if substituenda[-1] == nil or substituenda[-1] == '' then return '' end
if nparia < 1 or substituenda[0] == nil
or substituenda[0] == '' then return substituenda[-1] end
local reddenda = {}
local textus = mw.text.split(substituenda[-1], '', true)
local delenda = mw.text.split(substituenda[0], '', true)
local ndeletiones = #delenda
local nlitterae = #textus
substituenda[-1] = nil
substituenda[0] = nil
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 ifacies