Modul:Cycling race/data exporter
Utseende
Moduldokumentasjon
[opprett]
--export Cycling race/data to a given wiki
--filter all information which are not related to the given wiki
--[[
Example:
{{#invoke:Cycling race/data_exporter|entry|wiki=ar}}
]]
local p = {}
local wiki = "en"
local modul_to_export='Cycling race/l10n all'
function p.entry(frame)
local module = mw.title.new( modul_to_export, 'Module')
local source = module:getContent()
--local wiki = frame.args.wiki or "pl"
--Deleted unnecessary languages
local startpos, endpos = 1
repeat
startpos, endpos = string.find(source, '%p*translate%p*{', 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['["'..wiki..'"]'] or defs['["en"]'] or defs['["fr"]']
mw.logObject(count)
mw.logObject(wanted)
if wanted then
wanted =string.gsub(wanted,"},","")
source = string.sub(source, 1, endpos-1) .. wanted .. string.sub(source, last)
else
source = string.sub(source, 1, endpos-1) .. string.sub(source, last)
end
startpos = endpos + 1
end
until startpos == nil
-- default
source =string.gsub(source,"black_list_translate","black_list")
local output = frame:extensionTag{ name = 'pre', content = source, args = {} }
return output
end
return p