Lompat ke isi

Modul:Available

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Revisi sejak 18 September 2013 16.41 oleh Bennylin (bicara | kontrib)

p = {}
p.link = function ( frame )
    local link_available =  "{| "
    local label = ""
--    for i,v in ipairs(frame.args) do
--        if ( mw.wikibase.label( frame.args[i] ) ) then 
--            label = mw.wikibase.label( frame.args[i] )
--        else
--            label = "[[w:d:" .. frame.args[i] .. "|" .. frame.args[i] .. "]]"
--        end

        link_available = link_available .. "\n| " .. mw.wikibase.label( frame.args[1] ) .. "\n| " .. mw.wikibase.sitelink( frame.args[1] ) .. "\n| "

local kodebahasa = frame.args[2]
local nilai = mw.wikibase.getEntity().labels[kodebahasa]

if (nilai) then link_available = link_available .. "\n| " .. kodebahasa ..":[[:" .. kodebahasa ..":" .. nilai.value .. "|" .. nilai.value .. "]]\n| "

end


--        if ( mw.wikibase.sitelink( frame.args[i] ) ) then
--            link_available = link_available .. "[[" .. mw.wikibase.sitelink( frame.args[i] ) .. "]]"
--        else
--            link_available = link_available .. '<span style="color:red">' .. label .. '</span>'
--        end

    local code = mw.language.getContentLanguage():getCode()
--[[
    if code == nil then return nil end
    local entity = php.getEntity( frame.args[i] )
    if entity == nil or entity.labels == nil then return nil end
    local label = entity.labels[code]
    if label == nil then return nil end
    return label.value
--]]
        link_available = link_available .. code .. ":[[" .. mw.wikibase.sitelink( frame.args[1] ) .. "]]"
--    end
    link_available = link_available .. "\n|}"
    return link_available
end
 
return p