Modul:Sandkasse/Dipsacus fullonum/Modul:Sandkasse
Moduldokumentation[opret]
Hvis du ønsker en dokumentationsside for dette Scribuntomodul, så opret den her. Brugere kan eksperimentere i dette moduls undersider sandkasse (opret | kopiér) og testcases (opret). Tilføj venligst kategorier til /dok-undersiden. Undersider til dette modul. |
require('Modul:No globals')
local p = {}
function p.entry(frame)
local module = mw.title.new('Cycling race', 'Module')
local source = module:getContent()
local startpos, endpos = 1
repeat
startpos, endpos = string.find(source, '\n%s*local%s+l10nDef%s*=%s*{', startpos)
if startpos then
local defs = {}
local p1, p2, key, value = endpos + 1
local last = endpos + 1
local count = 0
repeat
p1, p2, key, value = string.find(source, '^%s*(%b[])%s*=%s*(%b{}%s*,?)', p1)
mw.logObject(p1)
mw.logObject(p2)
mw.logObject(key)
mw.logObject(value)
if p1 then
defs[key] = value
p1 = p2 + 1
last = p1
end
count = count + 1
until p1 == nil
local wanted = defs['["da"]'] or defs['["en"]']
mw.logObject(count)
mw.logObject(wanted)
if wanted then
source = string.sub(source, 1, endpos) .. ' ["da"] = ' .. wanted .. string.sub(source, last)
else
source = string.sub(source, 1, endpos) .. string.sub(source, last)
end
startpos = endpos + 1
end
until startpos == nil
local output = frame:extensionTag{ name = 'pre', content = source, args = {} }
return output
end
return p