יחידה:PropertyLink: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מ תמיכה בquantity + החלפה לgetEntityObject
שורה 1: שורה 1:
   
   
function getProperty( propertyName )
function getProperty( propertyName )
     local entity = mw.wikibase.getEntity()
     local entity = mw.wikibase.getEntityObject()
     if not entity or not entity.claims then return end --the entity doesnt exist or have no claims
     if not entity or not entity.claims then return end --the entity doesnt exist or have no claims


שורה 18: שורה 15:
         return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle )
         return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle )
             or linkTitle
             or linkTitle
     elseif propValue and propValue['type'] == 'string' then return propValue.value end
     elseif propValue['type'] == 'string' then
    return propValue.value
    elseif propValue['type'] == 'quantity' then
    local lang = mw.getContentLanguage()
    return lang:formatNum( propValue.value.amount )
    end
end
end