Modul:Wikidata utilities: Unterschied zwischen den Versionen
Modul:Wikidata utilities (Quelltext anzeigen)
Version vom 25. Oktober 2019, 15:44 Uhr
, vor 4 Jahren+fw.getLabel
K (entityExists not necessary, takes computing time) |
(+fw.getLabel) |
||
Zeile 19: | Zeile 19: | ||
return id, entity, wrongQualifier | return id, entity, wrongQualifier | ||
end | |||
function fw.getLabel( entity, lang ) | |||
local isString = type( entity ) == 'string' | |||
if not entity or ( isString and entity == '' ) then | |||
return nil | |||
end | |||
if isString then -- entity is id | |||
if lang and lang ~= '' then | |||
return mw.wikibase.getLabelByLang( entity, lang ) | |||
else | |||
return mw.wikibase.getLabel( entity ) | |||
end | |||
else -- entity is table | |||
if lang and lang ~= '' then | |||
return entity:getLabel( lang ) | |||
else | |||
return entity:getLabel() | |||
end | |||
end | |||
end | end | ||