Mòdul:Infotable images

De Viquipèdia
Salta a la navegació Salta a la cerca
--[[
For translation of this module, you must customize:
Module:Infotable images/i18n
--]]
local p = {}
local SA = require "Module:SimpleArgs"
local SD = require "Module:SimpleDebug"
local WD = require 'Module:Wikidata'
local II = require 'Module:InfoboxImage'

p.i18n = {
	["image"]	= {"image","Image"},
	["alt"]		= "alt",
	["caption"]	= {"caption","Caption"},
}
p.i18n = SA.loadI18n ('Infotable images', p.i18n)

local function I18nArg (S)
	return p.i18n[S]
end

function p.main (frame, args, tab, hide)
	local img = SA.Str_Par (args, I18nArg('image'))
	if img ~= nil then
		local altfnd = SA.Str_Par (args, I18nArg('alt'), '')
		local caption = SA.Str_Par (args, I18nArg('caption'))
		img = II.InfoboxImage ({args={["image"]=img, ["size"]='300x300px', ["alt"]=altfnd}})
		if caption ~= nil then
			img = img..'<br />'..caption
		end	
	elseif hide == nil then
		img = WD.claim ({property='P18', qualifier='P2096', formatting='table', list='false', rowformat='[[File:$0|300x300px]]<br/>$1'})	
	end	
	if img ~= nil then
		tab["image"] = img
	end	
	return tab
end --main

return p