Модуль:Interwiki: различия между версиями

Новая страница: «-- This module provides functions and objects for dealing with interwiki links. local checkType = require('libraryUtil').checkType local interwikiData = mw.loadData('Module:Interwiki/data') -------------------------------------------------------------------------------- -- Prefix class -------------------------------------------------------------------------------- local Prefix = {} Prefix.__index = Prefix function Prefix.new(code) checkType('Prefix.new...»
 
Нет описания правки
 
(не показаны 4 промежуточные версии этого же участника)
Строка 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 = {}
-- Проверяем, установлено ли расширение Wikibase на сайте. Если нет — выходим без ошибок.
if not mw.wikibase then
return ''
end
local entity = mw.wikibase.getEntity()
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