Modulo:Babel: Malsamoj inter versioj

[kontrolita revizio][kontrolita revizio]
Enhavo forigita Enhavo aldonita
aldono el la modula provejo
aldono, korekto laŭ la modula provejo
Linio 1:
-- Babel -- 2015060220150603
 
function subtitle(text)
Linio 31:
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
Linio 47 ⟶ 45:
end
if args['common box'] == "yes" or args['komuna kesto'] =="jes" then
args.header = args.header or "[[Vikipedio:Babel]]"
args.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
args['extra-css'] = 'background-color:#FFFFFF;'
--shows it like the {{Babel}} template
Linio 53:
-- shows it like the old {{BabelLandoj}} and {{BabelDevenLoĝLoko}}
local empty = {}
empty.header = args.header or "[[Vikipedio:Babel]]"
empty.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
empty['extra-css'] = 'background-color:#FFFFFF;'
-- creates the external table
Linio 71 ⟶ 73:
-- code for the template {{DevenLoĝLoko}}
if args.devenlando ~= nil and args.devenlando ~= "" then
-- creates the secandsecond table cell
local row2 = ret:tag('tr')
local der = row2:tag('td')
Linio 81 ⟶ 83:
local ll3 = args['loĝlokspeco'] or ""
local n = args.nomo or ""
local derivation =der:wikitext( frame:preprocess('{{DevenLoĝLoko|devenlando='
.. dl1 .. '|devenloko=' .. dl2 .. '|devenlokspeco=' .. dl3 .. '|loĝlando='
.. ll1 .. '|loĝloko=' .. ll2 .. '|loĝlokspeco=' .. ll3
.. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
der:wikitext(derivation)
:done()
end
Linio 92 ⟶ 93:
end
 
end -- babel_l
 
function p._babel_l2(b,args)
-- this function builds the box used by the {{BabelLoko}} template
local babels = {}
-- copies some named parameters from {{BabelLoko}} 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.header = args.header or "[[Vikipedio:Babel]]"
args.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
args['extra-css'] = 'background-color:#FFFFFF;'
args['flag'] = 'no'
--shows it like the {{Babel}} template
return p._babel(babels,args)
else
-- shows it like the old {{BabelLoko}}
local empty = {}
empty.header = args.header or "[[Vikipedio:Babel]]"
empty.footer = args.footer or "'''[[:Kategorio:Vikipediistoj laŭ lingvo]]'''"
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)
derbab:wikitext(derivationbab_cell)
:done()
local k = args.kat or 'jes'
local frame = mw.getCurrentFrame()
-- code for the template {{UzantoLandoLoko}}
if args.lando ~= nil and args.lando ~= "" then
-- creates the second table cell
local row2 = ret:tag('tr')
local der = row2:tag('td')
local l1 = args.lando
local l2 = args.loko or ""
local n = args.Nomo or ""
der:wikitext(frame:preprocess('{{Loko|1='
.. l1 .. '|2=' .. l2 .. '|3=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes}}') )
:done()
end
return tostring(ret)
end
 
end -- babel_l2
 
function p._babel(babels, args)
Linio 141 ⟶ 203:
body_cells.wikitext(babels[1])
else
userboxes = frame:preprocess('{{Uzulo|'..babels[1]..'|kat=' .. k .. '|babel-larĝo=jes|floso=left}}')
end
else
Linio 169 ⟶ 231:
body_cells:wikitext(subtitle(v))
else
body_cells:wikitext( frame:preprocess('{{Uzulo|'..v..'|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
end
-- Recycling body_cells for <td>
Linio 197 ⟶ 259:
end
if args.flag == "yes" or args.flago == "jes" or args.flag == nil or args.flag == "" then
-- code for the template {{UzantoLando}}
-- little box with flag
if args.lando ~= nil and args.lando ~= "" then
-- code for the template {{UzantoLando}}
if args.lando ~= nil and args.lando ~= "" then
local l1 = args.lando
local l2 = args.loko or ""
local l3 = args.lokospeco or ""
local n = args.nomo or ""
body_cells:wikitext( frame:preprocess('{{UzantoLando|lando=' .. l1 .. '|loko=' .. l2
.. '|lokospeco=' .. l3 .. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
end
elseif args.flag == "no" or args.flago == "ne" then
-- little box without flag
-- code for the template {{Lando}}
if args.lando ~= nil and args.lando ~= "" then
local l1 = args.lando
local l2 = args.loko or ""
local n = args.Nomo or ""
body_cells:wikitext( frame:preprocess('{{Loko|1='
.. l1 .. '|2=' .. l2 .. '|3=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes}}') )
end
else
-- if the value of args.flag or args.flago hasn't a sense
-- little box with flag
-- code for the template {{UzantoLando}}
if args.lando ~= nil and args.lando ~= "" then
local l1 = args.lando
local l2 = args.loko or ""
local l3 = args.lokospeco or ""
local n = args.nomo or ""
body_cells:wikitext( frame:preprocess('{{UzantoLando|lando=' .. l1 .. '|loko=' .. l2
.. '|lokospeco=' .. l3 .. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
end
end
-- code for the template {{DevenLoĝLoko}}
Linio 218 ⟶ 306:
.. dl1 .. '|devenloko=' .. dl2 .. '|devenlokspeco=' .. dl3 .. '|loĝlando='
.. ll1 .. '|loĝloko=' .. ll2 .. '|loĝlokspeco=' .. ll3
.. '|nomo=' .. n .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
end
Linio 224 ⟶ 312:
if args.UTC ~= nil and args.UTC ~= "" then
local u = args.UTC
body_cells:wikitext( frame:preprocess('{{UTC|' ..u .. '|kat=' .. k .. '|babel-larĝo=jes|floso=left}}') )
end
Linio 292 ⟶ 380:
end
local funcNames = {'babel', 'babel_x', 'babel_l', 'babel_l2'}
for _, funcName in ipairs(funcNames) do