Modulo:Babel: Malsamoj inter versioj

[kontrolita revizio][kontrolita revizio]
Enhavo forigita Enhavo aldonita
nova versio el la modula provejo
aldono el la modula provejo
Linio 1:
-- Babel -- 2015053120150602
 
function subtitle(text)
Linio 21:
local p = {}
 
function p._babel_x(babels,args)
-- this function builds the box used by the {{Babel-x}} template
args.header = args.header or "[[Vikipedio:Babel]]"
args.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
args['extra-css'] = 'background-color:#FFFFFF;'
return p._babel(babels,args)
end
 
function p._babel_l(b,args)
-- this function builds the box used by the {{BabelLandoj}} and {{BabelDevenLoĝLoko}} templates
args.header = args.header or "[[Vikipedio:Babel]]"
args.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
local babels = {}
-- copies some named parameters from {{BabelLandoj}} into unnamed for the modul
local i = 1
for k, v in pairs(args) do
local x = args['l' .. i]
if type(x) == "string" then
x = mw.text.trim(x)
end
if x ~= "" then
babels[i] = x
i = i + 1
end
end
if args['common box'] == "yes" or args['komuna kesto'] =="jes" then
args['extra-css'] = 'background-color:#FFFFFF;'
--shows it like the {{Babel}} template
return p._babel(babels,args)
else
-- shows it like the old {{BabelLandoj}} and {{BabelDevenLoĝLoko}}
local empty = {}
empty['extra-css'] = 'background-color:#FFFFFF;'
-- creates the external table
local ret = mw.html.create('table')
:css('border','none')
:css('width','100px')
:addClass('float-right')
local row1 = ret:tag('tr')
local bab = row1:tag('td')
-- puts the babel information into the first table cell
local bab_cell = p._babel(babels, empty)
bab:wikitext(bab_cell)
:done()
local k = args.kat or 'jes'
local frame = mw.getCurrentFrame()
-- code for the template {{DevenLoĝLoko}}
if args.devenlando ~= nil and args.devenlando ~= "" then
-- creates the secand table cell
local row2 = ret:tag('tr')
local der = row2:tag('td')
local dl1 = args.devenlando
local dl2 = args.devenloko or ""
local dl3 = args.devenlokspeco or ""
local ll1 = args['loĝlando'] or ""
local ll2 = args['loĝloko'] or ""
local ll3 = args['loĝlokspeco'] or ""
local n = args.nomo or ""
local derivation = frame:preprocess('{{DevenLoĝLoko|devenlando='
.. dl1 .. '|devenloko=' .. dl2 .. '|devenlokspeco=' .. dl3 .. '|loĝlando='
.. ll1 .. '|loĝloko=' .. ll2 .. '|loĝlokspeco=' .. ll3
.. '|nomo=' .. n .. '|kat=' .. k .. '}}')
der:wikitext(derivation)
:done()
end
return tostring(ret)
end
 
end
 
function p._babel(babels, args)
Linio 221 ⟶ 292:
end
local funcNames = {'babel', 'babel_x', 'babel_l'}
for _, funcName in ipairs(funcNames) do