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

מאין תקציר עריכה
הגנה מפני לייבל עם ערך ניל, אבל בעיקר, ניקוי סמיקולון שלא צריכים להיות שם.
שורה 24: שורה 24:
local unit = ''
local unit = ''
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/', '' )
if unitEntityId and #unitEntityId>0 then
if unitEntityId and #unitEntityId>0 then
-- name from label
-- name from label
unit =  mw.wikibase.label( unitEntityId );
unit =  mw.wikibase.label( unitEntityId ) or ''
local unitSymbol = mw.wikibase.getBestStatements(unitEntityId, 'P558')
local unitSymbol = mw.wikibase.getBestStatements(unitEntityId, 'P558')
--  name from properties
--  name from properties
if unitSymbol 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( {['P558']=unitSymbol }, labelFilter );
local labelClaims = WDS.filter( {['P558']=unitSymbol }, labelFilter )
for r, claim in pairs( labelClaims ) do
for r, claim in pairs( labelClaims ) do
שורה 42: שורה 42:
and claim.mainsnak.datavalue.type == 'string'
and claim.mainsnak.datavalue.type == 'string'
and claim.mainsnak.datavalue.value ~= '' then
and claim.mainsnak.datavalue.value ~= '' then
unit = claim.mainsnak.datavalue.value;
unit = claim.mainsnak.datavalue.value
break;
break
end
end
end
end
end
end
unit = ' ' .. unit;
unit = ' ' .. unit
end
end
     end
     end
שורה 75: שורה 75:
if not femaleForm then return nil, false end
if not femaleForm then return nil, false end
local femLabels = WDS.filterByLanguage( femaleForm, 'he' );
local femLabels = WDS.filterByLanguage( femaleForm, 'he' )
if femLabels ~= nil and
if femLabels ~= nil and
  femLabels[1] and
  femLabels[1] and
שורה 82: שורה 82:
  femLabels[1].mainsnak.datavalue.value and
  femLabels[1].mainsnak.datavalue.value and
  femLabels[1].mainsnak.datavalue.value.text then
  femLabels[1].mainsnak.datavalue.value.text then
return femLabels[1].mainsnak.datavalue.value.text;
return femLabels[1].mainsnak.datavalue.value.text
end
end


return nil, (#femaleForm)>0;
return nil, #femaleForm > 0
end
end