Module:Country data : Différence entre versions

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
(+ Japon)
Ligne 1 : Ligne 1 :
-- version Lua de [[Modèle:COuntry data]]
+
local p = {}
 +
local modulelist = mw.loadData('Module:Country data/liste')
  
return {
+
local function getval(info, param, data)
['arménie'] = {
+
-- info== name, flag, etc.
['alias'] = 'Arménie',
+
-- param = ancient, default, etc.
['sortkey'] = 'Armenie',
+
-- data = table module with the data
['flag alias'] = 'Flag of Armenia.svg',
+
if type(data[info]) == 'string' then
['alt attribute'] = 'Drapeau de l\'Arménie',
+
return data[info]
['flag alias-1918'] = 'Flag of the Democratic Republic of Armenia.svg',
+
end
},
+
return data[info][param]
['japon'] = {
+
end
['alias'] = 'Japon',
+
 
['alt attribute'] = 'Drapeau du Japon',
+
function p.standarddisplay(country, typeval)
['flag alias'] = 'Flag of Japan.svg',
+
 
['flag alias-alt'] = 'Merchant flag of Japan (1870).svg',
+
country = string.lower(country.args[1])
['flag alias-1945'] = 'Flag of Allied Occupied Japan.svg',
+
local modul = modulelist[country]
['flag alias-ryukyu'] = 'Flag of US Occupied Ryukyu Islands.svg',
+
if not modul then return
['flag alias-naval'] = 'Naval Ensign of Japan.svg',
+
country
['link alias-naval'] = 'Japan Maritime Self-Defense Force',
+
end
--| var1 = alt
+
if not typeval then
--| var2 = 1945
+
typeval = "default"
--| var3 = ryukyu
+
end
},
+
local data = require('Module:Country data/' .. modul)
}
+
local function get(what) return getval(what, typeval, data) end
 +
local name = get('name')
 +
local link = get('link')
 +
local flag = get('flag')
 +
 +
if flag then
 +
flag = '<span class="flagicon">[[File:' .. flag .. '|' .. '22x20px]]</span>'
 +
else
 +
flag = ''
 +
end
 +
return flag .. ' [[' .. link.. '|' .. name .. ']]'
 +
end
 +
return p

Version du 15 janvier 2015 à 10:39

La documentation pour ce module peut être créée à Module:Country data/doc

local p = {}
local modulelist = mw.loadData('Module:Country data/liste')

local function getval(info, param, data)
	-- info== name, flag, etc.
	-- param = ancient, default, etc.
	-- data = table module with the data
	if type(data[info]) == 'string' then
		return data[info]
	end
	return data[info][param]
end

function p.standarddisplay(country, typeval)

	country = string.lower(country.args[1])
	local modul = modulelist[country]
	if not modul then return
		country
	end
	if not typeval then
		typeval = "default"
	end
	local data = require('Module:Country data/' .. modul)
	local function get(what) return getval(what, typeval, data) end
	local name = get('name')
	local link = get('link')
	local flag = get('flag')
	
	if flag then
		flag = '<span class="flagicon">[[File:' .. flag .. '|' .. '22x20px]]</span>'
	else
		flag = ''
	end
	return flag .. ' [[' .. link.. '|' .. name .. ']]'
end
return p