Module:Datastub
Apparence
La documentation pour ce module peut être créée à Module:Datastub/doc
local p = {}
local lualinq = require "Module:LuaLinq"
local wikidata = require "Module:Wikidata"
local declension = require "Module:Declension"
function p.city(frame)
local args = frame:getParent().args
local itemId = nil
if args.item then
itemId = args.item
end
local country = wikidata.claim({item=itemId, property="P17", case="annexed", list="false"})
local text = "<b>"..mw.title.getCurrentTitle().text.."</b>".." d tamdint deg tmurt n "..country
local item = mw.wikibase.getEntity(itemId)
local original_names = lualinq.main(item.claims["P1705"]):select(function(c) return 's '..declension.annexed(mw.language.fetchLanguageName(c.mainsnak.datavalue.value['language'], "kab"))..': '..c.mainsnak.datavalue.value['text'] ; end):toArray()
if #original_names > 0 then
text = text.." (Isem-is "..table.concat(original_names,", ")..")"
end
--if item.claims["P131"] then
-- text = text.." , tettiki deg "..wikidata.getParentValues({item=itemId, upto="2",rowformat="$1",separator=" ("})
--end
if item.claims["P1082"] then
text = text..". Zedɣen-tt "..wikidata.claim({item=itemId, property="P1082", list="false"}).." n yimezdaɣen"
local pop_year = wikidata.claim({item=itemId, property="P1082", qualifier="P585", list="false"})
if pop_year then
text = text.." (Aseggas n "..pop_year..")"
end
end
if item.claims["P2046"] then
text = text..", tajumma-ines "..wikidata.claim({item=itemId, property="P2046", list="false"}).." km²"
end
local lng = mw.language.new('kab')
if item.claims["P1082"] and item.claims["P2046"] then
local density = tonumber(item.claims["P1082"][1].mainsnak.datavalue.value['amount']) / tonumber(item.claims["P2046"][1].mainsnak.datavalue.value['amount']) * 1000000
text = text..", ihi llan "..lng:formatNum(math.ceil(density)).." n yimezdaɣen deg mkull km²"
end
text = text.."."
return text
end
return p