Module:Ratournaedjes
Apparence
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}
local languages = require("Module:Lingaedje")
local builder = require("Module:Builder");
function p.init(frame)
builder.init(frame, "Årtikes avou ene flotche dins l' modele Ratournaedjes")
local box = mw.html.create( 'div' ):attr("class", "TBox")
local listc = mw.html.create( 'div' ):attr("class", "TBox-content")
local list = mw.html.create( 'ul' )
-- for each argument of the parent modele
local modele = mw.getCurrentFrame():getParent()
if frame.args.tite == nil or frame.args.tite ~= "neni" then
local title = mw.html.create( 'div' ):attr("class", "TBox-title")
if modele.args[1] ~= nil and mw.text.trim(modele.args[1]) ~= "" then
title:wikitext(modele.args[1])
else
title:wikitext(mw.title.getCurrentTitle().text)
end
box:node(title)
end
if frame.args.class ~= nil and frame.args.class ~= "neni" then
box:addClass("TBox-"..frame.args.class);
else
box:addClass("TBox-ratour");
end
-- sort by keys (ling. code)
local sortc = {}
local i = 1
for key,val in pairs(modele.args) do
if tonumber(key) == nil then
sortc[i] = key
i = i+1
end
end
table.sort(sortc)
for key,code in ipairs(sortc) do
local lname = languages.get_name(code)
if not lname then
builder.error("Li côde do lingaedje « "..code.." » n’ est nén rkinoxhou.")
elseif lname == "" then
builder.error("Li côde do lingaedje « "..code.." » n’ a pont d’ no.")
else
local li = mw.html.create( 'li' )
local flag = languages.get_flag(code, true)
if flag ~= nil then
li:wikitext(flag .. " ")
end
li:wikitext(mw.language.getContentLanguage():ucfirst(lname) .. " : " .. modele.args[code])
list:node(li)
end
end
if #sortc >=9 then
listc:addClass('c-3')
elseif #sortc >=4 then
listc:addClass('c-2')
end
listc:node(list)
box:node(listc)
builder.add_content(box)
return builder.get_content()
end
return p