בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, צוות טכני, מעדכנים, מייבא
263
רעדאגירונגען
ק (rv) צייכן: צוריקגעשטעלט |
(ייבוא מוויקיפדיה העברית, ראה רשימת התורמים) צייכן: צוריקגעשטעלט |
||
| שורה 12: | שורה 12: | ||
value, error = wikidataModule.getValueOfClaim(claim, AS_OF_PROPERTY, nil) | value, error = wikidataModule.getValueOfClaim(claim, AS_OF_PROPERTY, nil) | ||
if value then | if value then | ||
return ' ( | return ' (נכון ל־'..value ..')' | ||
end | end | ||
return '' | return '' | ||
| שורה 33: | שורה 33: | ||
if unitSymbol then | if unitSymbol then | ||
local writingSystemElementId = 'Q33513' -- hebrew writing system | local writingSystemElementId = 'Q33513' -- hebrew writing system | ||
local langElementId = ' | local langElementId = 'Q9288' -- hebrew | ||
local labelFilter = 'P5061[language:'..langCode..'], P5061[P282:' .. writingSystemElementId .. ', P407:' .. langElementId .. ']' | local labelFilter = 'P5061[language:'..langCode..'], P5061[P282:' .. writingSystemElementId .. ', P407:' .. langElementId .. ']' | ||
local WDS = require( 'Module:WikidataSelectors' ) | local WDS = require( 'Module:WikidataSelectors' ) | ||
| שורה 66: | שורה 66: | ||
local function missingLabelCategory(propertyName) | local function missingLabelCategory(propertyName) | ||
return '[[ | return '[[קטגוריה:ויקינתונים:ערכים_חסרי_תווית_בעברית: ' .. (mw.wikibase.label( propertyName) or propertyName) .. ']][[קטגוריה:ויקינתונים:ערכים_חסרי_תווית_בעברית]]' | ||
end | end | ||
| שורה 104: | שורה 104: | ||
local formattedValue | local formattedValue | ||
local missingTranslation = false | local missingTranslation = false | ||
local fallbackLanguage = false | |||
if genderAwareEntity then | if genderAwareEntity then | ||
local gender = mw.wikibase.getBestStatements(genderAwareEntity, 'P21') -- P21 - gender | local gender = mw.wikibase.getBestStatements(genderAwareEntity, 'P21') -- P21 - gender | ||
| שורה 126: | שורה 127: | ||
end | end | ||
local isLocalLabel = langLabel==' | local isLocalLabel = langLabel=='he' | ||
-- fallback if there is target but no label, use target as label | -- fallback if there is target but no label, use target as label | ||
if linkTarget and not isLocalLabel then | if linkTarget and not isLocalLabel then | ||
| שורה 132: | שורה 133: | ||
isLocalLabel = true | isLocalLabel = true | ||
end | end | ||
if localLabel and isLocalLabel then | if localLabel and isLocalLabel then | ||
if linkTarget and localLabel and linkTarget == localLabel then | if linkTarget and localLabel and linkTarget == localLabel then | ||
| שורה 146: | שורה 146: | ||
missingTranslation = true | missingTranslation = true | ||
-- in that case we would unfourtanly can show only the entity id which is meaningless for users | -- in that case we would unfourtanly can show only the entity id which is meaningless for users | ||
if langLabel=='en' then | |||
fallbackLanguage = true | |||
formattedValue = mw.ustring.format('<span lang="en" dir="ltr">%s</span>', localLabel) | |||
else | |||
formattedValue = mw.ustring.format( "[[:d:%s|%s]]", entityId, entityId ) | |||
end | |||
end | end | ||
return formattedValue, missingTranslation | return formattedValue, missingTranslation, fallbackLanguage | ||
end | end | ||
| שורה 158: | שורה 163: | ||
local warnings = '' | local warnings = '' | ||
for _, optionalQualifier in pairs( qualifiers ) do | for _, optionalQualifier in pairs( qualifiers ) do | ||
if optionalQualifier and property.qualifiers[ | -- handling case of "first or default" qualifier (e.g.: for 'P1/P2' take P1 if exists, otherwise - P2) | ||
for selectableQualifier in string.gmatch(optionalQualifier, '[^/]+') do | |||
if selectableQualifier and property.qualifiers[selectableQualifier] then | |||
local optionalQualifierVal = mw.wikibase.formatValues(property.qualifiers[selectableQualifier]) | |||
local isQualLocalLabel = true | |||
if optionalQualifierVal and property.qualifiers[selectableQualifier][1] and property.qualifiers[selectableQualifier][1]['datatype']=='wikibase-item' then | |||
for i, optionalQValues in ipairs(property.qualifiers[selectableQualifier]) do | |||
local qualLabel, qualLang = mw.wikibase.getLabelWithLang( optionalQValues['datavalue']['value']['id'] ) | |||
isQualLocalLabel = isQualLocalLabel and (qualLang=='he') | |||
end | |||
end | end | ||
if optionalQualifierVal then | |||
local formattedValue = '<span title="'.. mw.wikibase.label(selectableQualifier)..'" class="propertylink-wikidata-qualifier">'..mw.wikibase.formatValues(property.qualifiers[selectableQualifier]) ..'</span>' | |||
local formattedValue = '<span title="'.. mw.wikibase.label( | |||
table.insert(formmatedQualifiers, formattedValue) | table.insert(formmatedQualifiers, formattedValue) | ||
break -- found first available value | |||
end | end | ||
elseif string.sub(selectableQualifier, 1, 1) ~= 'P' then | |||
table.insert(formmatedQualifiers, selectableQualifier) | |||
break -- found first available value | |||
end | end | ||
end | end | ||
| שורה 206: | שורה 214: | ||
function getProperty( propertyName, allowMulti, allowNA, entityId, multiSeperator, optionalQualifier, genderAware ) | function getProperty( propertyName, allowMulti, allowNA, entityId, multiSeperator, optionalQualifier, genderAware ) | ||
if propertyName==nil or #propertyName==0 then return end -- no property specified | if propertyName==nil or #propertyName==0 then return end -- no property specified | ||
entityId = entityId | entityId = entityId | ||
if entityId == nil then return end -- entity doesnt exist | if entityId == nil then return end -- entity doesnt exist | ||
options = { | options = { | ||
| שורה 223: | שורה 231: | ||
function property( frame ) | function property( frame ) | ||
return getProperty(string.upper(frame.args[1]), (frame.args[2] and string.len(frame.args[2])>0) or false, true, frame.args['entity']) | if frame.args['entity']==nil and frame.args['title'] and #frame.args['title']>0 then | ||
frame.args['entity'] = mw.wikibase.getEntityIdForTitle( frame.args['title'] ) | |||
if frame.args['entity']==nil then return end | |||
end | |||
return getProperty(string.upper(frame.args[1]), (frame.args[2] and string.len(frame.args[2])>0) or false, true, frame.args['entity'], frame.args['sep'], frame.args['q']) | |||
end | end | ||
| שורה 266: | שורה 278: | ||
function getPropertyByOptions( propertyName, entityId, options ) | function getPropertyByOptions( propertyName, entityId, options ) | ||
-- verify entity exists | -- verify entity exists | ||
if entityId==nil then return end | if entityId==nil then return end | ||
| שורה 279: | שורה 290: | ||
options['img-width'] = options['img-width'] or '250px' | options['img-width'] = options['img-width'] or '250px' | ||
options['source'] = options['source'] or false | options['source'] = options['source'] or false | ||
options['filter'] = options['filter'] or nil | |||
return --no such property for this item | |||
end | end | ||
function getLabel( propertyName, entityId ) | function getLabel( propertyName, entityId ) | ||
local entity = entityId | local entity = entityId | ||
if not entity then return end--the entity doesnt exist or have no claims | if not entity then return end--the entity doesnt exist or have no claims | ||
local property = mw.wikibase.getBestStatements(entity, propertyName) | local property = mw.wikibase.getBestStatements(entity, propertyName) | ||
| שורה 394: | שורה 306: | ||
if propValue['type'] == 'wikibase-entityid' then | if propValue['type'] == 'wikibase-entityid' then | ||
local label, lang = mw.wikibase.label( | local label, lang = mw.wikibase.label( propValue.value['id'] ) | ||
return label | return label | ||
elseif propValue['type'] == 'string' then | elseif propValue['type'] == 'string' then | ||
| שורה 406: | שורה 318: | ||
end | end | ||
function | function getItem( propertyName, entityId ) | ||
local entityId | local entity = entityId | ||
if not | if not entity then return end--the entity doesnt exist or have no claims | ||
local property = mw.wikibase.getBestStatements( | local property = mw.wikibase.getBestStatements(entity, propertyName) | ||
if property | if not property or not property[1] then return end --no such property for this item | ||
property = property[1] | |||
local propValue = property.mainsnak.datavalue | |||
if not propValue then return '' end --property doesnt exist | |||
return propValue.value['id'] | |||
end | |||
-- Return the Item for property, or the item of the linked entiy of that property | |||
function item( frame ) | |||
return getItem( string.upper(frame.args[1] )) | |||
end | |||
function getImageLink( propName, width, align, description, border, entityId) | |||
return --the entity doesnt exist or have no claims | |||
end | end | ||
| שורה 436: | שורה 353: | ||
end | end | ||
-- returns the wikidata Qid, if exists, "" otherwise | |||
function getPageEntry(frame) | |||
return mw.wikibase.getEntityIdForTitle(string.upper(frame.args[1] )) | |||
end | |||
function getSitelinksFromQid(frame) | |||
resTable =mw.wikibase.getEntity(string.upper(frame.args[1] )) | |||
resTable = resTable["sitelinks"] | |||
s= "<table>\n" | |||
for k,v in pairs(resTable) do | |||
if v.title then | |||
s=s.."<tr>".. "<td>" .. k.."</td>".. "<td>" .. v.title.."</td>".."</tr>" .. "\n" | |||
end | |||
end | |||
return s .. "</table>" | |||
end | |||
return { | return { | ||
imageLink = imageLink, | imageLink = imageLink, | ||
| שורה 441: | שורה 376: | ||
label = label, | label = label, | ||
['תווית'] = label, | ['תווית'] = label, | ||
item = item, | |||
['פריט'] = item, | |||
formatEntity = formatEntity, | formatEntity = formatEntity, | ||
property = property, | property = property, | ||
propertyWithGender = propertyWithGender, | propertyWithGender = propertyWithGender, | ||
['מאפיין'] = property, | ['מאפיין'] = property, | ||
getProperty = getProperty, | getProperty = getProperty, | ||
getPropertyByOptions = getPropertyByOptions, | getPropertyByOptions = getPropertyByOptions, | ||
| שורה 452: | שורה 388: | ||
getLabel = getLabel, | getLabel = getLabel, | ||
hasEntry = hasEntry, | hasEntry = hasEntry, | ||
getPageEntry = getPageEntry, | |||
getSitelinksFromQid=getSitelinksFromQid, | |||
['יש פריט'] = hasEntry | ['יש פריט'] = hasEntry | ||
} | } | ||
רעדאגירונגען