Modul:Wikidata-redirect

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Die Dokumentation für dieses Modul kann unter Modul:Wikidata-redirect/Doku erstellt werden

local p = {}

local function tabletostr( t, s, o, c )
    if type( t ) == "table" then
        local f = {};
        for k, v in pairs( t ) do
            table.insert( f, string.format( '%s = %s', k, tabletostr( v, s, o, c ) ) )
        end;
        table.sort( f );
        return ( o or '' ) .. table.concat( f, s or '' ) .. ( c or '' )
    else
    	return tostring( t )
    end
end

function p.interwikiNumber()
	local entity = mw.wikibase.getEntity();
    local sitelinks_table = entity[ 'sitelinks' ];
	local sitelinks = tabletostr( sitelinks_table, '; ', '{', '}' );
    local _, res = mw.ustring.gsub(sitelinks, 'wiki', '');
	return res / 2;
end

return p