Modulo:Wikidata/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m spazio
aggiornato alla versione corrente
Riga 100:
 
local function formatMonolingualtext(value, args)
local ret = value.text''
if not args.includelang or args.includelang:match('%f[a-z]' .. value.language .. '%f[^a-z]') then
if args.showlang then
retif =not mLanguagesargs.lingueexcludelang or not args.excludelang:match({'%f[a-z]' .. value.language }) .. ' %f[^a-z]') .. retthen
ret = value.text
if args.showlang then
ret = mLanguages.lingue({ value.language }) .. ' ' .. ret
end
end
end
return ret
Line 408 ⟶ 413:
if claim.rank == rank then
table.insert(ret, claim)
end
end
return ret
end
 
-- Restituisce i claim con la lingua richiesta
local function filterByLanguage(claims, args)
local ret = {}
for _, claim in ipairs(claims) do
if claim.mainsnak.snaktype == 'value' and claim.mainsnak.datavalue.type == 'monolingualtext' then
local value = claim.mainsnak.datavalue.value
if not args.includelang or args.includelang:match('%f[a-z]' .. value.language .. '%f[^a-z]') then
if not args.excludelang or not args.excludelang:match('%f[a-z]' .. value.language .. '%f[^a-z]') then
table.insert(ret, claim)
end
end
end
end
Line 449 ⟶ 438:
claims = mw.wikibase.getAllStatements(entityId, propertyId)
claims = filterRankValue(claims, args.rank)
end
-- statements filtrati per lingua con args.includelang/excludelang
if args.includelang or args.excludelang then
claims = filterByLanguage(claims, args)
end