יחידה:WikidataCrossValidation: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מ מקרה נפוץ של מטר |
||
| שורה 54: | שורה 54: | ||
if propValue['type'] == 'wikibase-entityid' then | if propValue['type'] == 'wikibase-entityid' then | ||
local localLabel, langLabel = mw.wikibase.getLabelWithLang( "Q" .. propValue.value['numeric-id'] ) | |||
local isLocalLabel = langLabel=='he' | local isLocalLabel = langLabel=='he' | ||
if not isLocalLabel then | if not isLocalLabel then | ||
| שורה 91: | שורה 91: | ||
end | end | ||
elseif propValue['type'] == 'quantity' then | elseif propValue['type'] == 'quantity' then | ||
local noramlizeUnit = mw.ustring.gsub( | local noramlizeUnit = mw.ustring.gsub(wikitext, '[%[%]]', '') | ||
noramlizeUnit = mw.ustring.gsub(noramlizeUnit, '(.+) מטרים', '%1 מטר') | |||
if noramlizeUnit == formattedValue then | if noramlizeUnit == formattedValue then | ||
return CrossValidate.CrossValidateResult.COMPATIBLE | return CrossValidate.CrossValidateResult.COMPATIBLE | ||
end | end | ||
if mw.ustring.match(noramlizeUnit, '^[%d.,]+ מטר$') then | |||
local ConvertModule = require('Module:Convert') | |||
local success, wikidataMeter = pcall(ConvertModule.convert, mw.getCurrentFrame():newChild{ args = { | |||
['input'] = propertyName, | |||
[2] = 'מטר', | |||
['disp'] = 'out', | |||
['qid'] = entityId, | |||
['abbr']='off' | |||
} }:newChild{}) | |||
if success then | |||
wikidataMeter = mw.ustring.gsub(wikidataMeter, '(.+) מטרים', '%1 מטר') | |||
if wikidataMeter==noramlizeUnit then | |||
return CrossValidate.CrossValidateResult.COMPATIBLE | |||
end | |||
end | |||
end | |||
return CrossValidate.CrossValidateResult.INVALID_WIKITEXT -- TODO: parse quantity and units | return CrossValidate.CrossValidateResult.INVALID_WIKITEXT -- TODO: parse quantity and units | ||
elseif propValue['type'] == 'time' then | elseif propValue['type'] == 'time' then | ||