Модуль:Interwiki: различия между версиями
Buto (обсуждение | вклад) Нет описания правки |
Buto (обсуждение | вклад) Нет описания правки |
||
| (не показаны 2 промежуточные версии этого же участника) | |||
| Строка 56: | Строка 56: | ||
return pathQuery2:find(pattern) ~= nil | return pathQuery2:find(pattern) ~= nil | ||
end | end | ||
local langcode = { | local langcode = { | ||
['bat_smg'] = 'bat-smg', | ['bat_smg'] = 'bat-smg', | ||
| Строка 68: | Строка 69: | ||
['zh_min_nan'] = 'zh-min-nan', -- a comma have to be added when new lines are added | ['zh_min_nan'] = 'zh-min-nan', -- a comma have to be added when new lines are added | ||
['zh_yue'] = 'zh-yue' | ['zh_yue'] = 'zh-yue' | ||
} | |||
p460 = function(entity) -- access the first valid value of P460 | local p460 = function(entity) -- access the first valid value of P460 | ||
if entity and entity.claims and entity.claims["P460"] then | if entity and entity.claims and entity.claims["P460"] then | ||
for i, j in pairs(entity:getBestStatements( "P460" )) do | for i, j in pairs(entity:getBestStatements( "P460" )) do | ||
| Строка 80: | Строка 81: | ||
return nil | return nil | ||
end | end | ||
Prefix.interwiki = function(frame) | Prefix.interwiki = function(frame) | ||
local s = {} | local s = {} | ||
local entity = mw.getEntity() | |||
-- Проверяем, установлено ли расширение Wikibase на сайте. Если нет — выходим без ошибок. | |||
if not mw.wikibase then | |||
return '' | |||
end | |||
local entity = mw.wikibase.getEntity() | |||
local qid = frame.args.qid or frame:getParent().args.qid or p460(entity) -- uses parameter qid of the module if it exists, otherwise follow P460 | local qid = frame.args.qid or frame:getParent().args.qid or p460(entity) -- uses parameter qid of the module if it exists, otherwise follow P460 | ||
if frame.args.qid == '' or frame:getParent().args.qid == '' then | if frame.args.qid == '' or frame:getParent().args.qid == '' then | ||