Modulo:String/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
fix arraytostring |
test modifiche sostituzione funzione mw.message.newRawMessage |
||
Riga 471:
-- =================================================================
-- Classe per gestire i
-- =================================================================
local Message = {}
Riga 480:
msg = mw.ustring.gsub(msg, '\\{', '{')
msg = mw.ustring.gsub(msg, '\\}', '}')
-- break msg in msg_table, odd position are fixed string, even position are a parameter number to be substitued
local msg_table = {}
local last_position = 1
while true do
sep_start, sep_end, par_number = mw.ustring.find(msg, '$(\d+)', last_position) -- find the next '$n' in the string
if sep_start~=nil then -- separator found
if sep_start == 1 then
table.insert(msg_table, '') -- il $n è subito a inizio stringa, salvo la string vuota al primo posto
else
table.insert(msg_table, mw.ustring.sub(msg, last_position, sep_start-1))
end
table.insert(msg_table, tonumber(par_number))
last_position=sep_end + 1 -- save next position to start
else
table.insert(msg_table, mw.ustring.sub(msg, last_position) or '') -- Save what's left in msg_tabele
break
end
end
return setmetatable({
values = {},
}, Message)
Line 495 ⟶ 514:
function Message:text()
local
table.insert(t, self.msg_table[i])
table.insert(t, self.values[self.msg_table[i]] or '')
end
local msg = table.join(t)
return frame:preprocess(msg)
end
Line 519 ⟶ 543:
end
--carico il messaggio
local msg = base_args.msg or '$1'
local message = Message(msg)
elements = {}
|