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

מאין תקציר עריכה
מאין תקציר עריכה
שורה 18: שורה 18:
local function formatQuantity(property)  
local function formatQuantity(property)  
local propValue = property.mainsnak and property.mainsnak.datavalue
local propValue = property.mainsnak and property.mainsnak.datavalue
    local lang = mw.getContentLanguage()
local lang = mw.getContentLanguage()
local asOfDate = asOfDateQualifier(property)
local asOfDate = asOfDateQualifier(property)
local localAmount = lang:formatNum( tonumber(propValue.value.amount) )
local localAmount = lang:formatNum( tonumber(propValue.value.amount) )
שורה 24: שורה 24:
if propValue.value.unit and string.match( propValue.value.unit, 'http://www.wikidata.org/entity/' ) then
if propValue.value.unit and string.match( propValue.value.unit, 'http://www.wikidata.org/entity/' ) then
local unitEntityId = string.gsub( propValue.value.unit, 'http://www.wikidata.org/entity/', '' );
local unitEntityId = string.gsub( propValue.value.unit, 'http://www.wikidata.org/entity/', '' );
local unitEntity = mw.wikibase.getEntity( unitEntityId );
if unitEntityId and #unitEntityId>0 then
if unitEntity then
-- name from label
-- name from label
unit =  unitEntity:getLabel();
unit =  mw.wikibase.label( unitEntityId );
local unitSymbol = mw.wikibase.getBestStatements(unitEntityId, 'P558')
--  name from properties
--  name from properties
if unitEntity.claims and unitEntity.claims.P558 then
if unitSymbol then
local writingSystemElementId = 'Q33513'; -- hebrew writing system
local writingSystemElementId = 'Q33513'; -- hebrew writing system
local langElementId = 'Q9288'; -- hebrew
local langElementId = 'Q9288'; -- hebrew
local labelFilter = 'P558[P282:' .. writingSystemElementId .. ', P407:' .. langElementId .. ']';
local labelFilter = 'P558[P282:' .. writingSystemElementId .. ', P407:' .. langElementId .. ']';
local WDS = require( 'Module:WikidataSelectors' );
local WDS = require( 'Module:WikidataSelectors' );
local labelClaims = WDS.filter( unitEntity.claims, labelFilter );
local labelClaims = WDS.filter( {['P558']=unitSymbol }, labelFilter );
for r, claim in pairs( labelClaims ) do
for r, claim in pairs( labelClaims ) do
if claim.mainsnak
if claim.mainsnak