Module:Sandbox: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
Line 17: Line 17:
end
end
end
end

output = output .. '</ul>'


return output
return output
Line 29: Line 31:


for i, lang in ipairs(lang_list) do
for i, lang in ipairs(lang_list) do
local lang_name = mw.language.fetchLanguageName( lang )
output = output .. string.gsub([==[
local row = string.format([==[
|-
|-
! scope="row" | {{#language:~LANG~}}
! scope="row" | %s
| [[Thank You/~LANG~]]
| [[Thank You/%s]]
| [[Ways to Give/~LANG~]]
| [[Ways to Give/%s]]
| [[Problems donating/~LANG~]]
| [[Problems donating/%s]]
| [[Cancel or change recurring giving/~LANG~]]
| [[Cancel or change recurring giving/%s]]
| [[Matching Gifts/~LANG~]]
| [[Matching Gifts/%s]]
| [[FAQ/~LANG~]]
| [[FAQ/%s]]
| [[Tax deductibility/~LANG~]]
| [[Tax deductibility/%s]]
]==], '~LANG~', lang)
]==], lang_name, lang, lang, lang, lang, lang, lang, lang)
end
end



Revision as of 19:56, 11 October 2019

Documentation for this module may be created at Module:Sandbox/doc

local p = {}

function p.get_langlinks( frame )

    -- supported languages
    local lang_list = { 'ca', 'da', 'de', 'es', 'es-419', 'fr', 'he', 'hu', 'it', 'ja', 'lv', 'nb', 'nl', 'pl', 'pt', 'pt-br', 'ro', 'ru', 'sk', 'sv', 'uk', 'zh-hans' }
    local output = '<ul>'

    local root = 'Problems donating'

    for i, lang in ipairs(lang_list) do
        local title = root .. '/' .. lang
        local p = mw.title.new( title )
        if p.exists then
            local lang_name = mw.language.fetchLanguageName( lang )
            output = output .. string.format('<li lang="%s" style="white-space: nowrap;">[[%s|%s]]</li>', lang, title, lang_name)
        end
    end

    output = output .. '</ul>'

    return output

end

function p.get_langtable( frame )

    -- supported languages
    local lang_list = { 'ca', 'da', 'de', 'es', 'es-419', 'fr', 'he', 'hu', 'it', 'ja', 'lv', 'nb', 'nl', 'pl', 'pt', 'pt-br', 'ro', 'ru', 'sk', 'sv', 'uk', 'zh-hans' }
    local output = ''

    for i, lang in ipairs(lang_list) do
        local lang_name = mw.language.fetchLanguageName( lang )
        local row = string.format([==[
|-
! scope="row" | %s
| [[Thank You/%s]]
| [[Ways to Give/%s]]
| [[Problems donating/%s]]
| [[Cancel or change recurring giving/%s]]
| [[Matching Gifts/%s]]
| [[FAQ/%s]]
| [[Tax deductibility/%s]]
]==], lang_name, lang, lang, lang, lang, lang, lang, lang)
    end

    return output

end

return p