Module:Sandbox: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
local p = {} -- p stands for package
local p = {}


function p.get_appeal( frame )
function p.get_langlinks( frame )


-- supported languages
local appeal_name = string.gsub( frame.args.appeal , 'Appeal%-', '' )
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 language = frame.args.language
local country = frame.args.country
local output = '<ul>'


local root = 'Problems donating'
local p1 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/' .. language .. '/' .. country )
local p2 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/' .. language )
local p3 = mw.title.new( 'Template:Appeal/' .. appeal_name .. '/en' )
local p4 = mw.title.new( 'Template:Appeal/default/' .. language )


for i, lang in ipairs(lang_list) do
if p1.exists then
page = p1
local title = root .. '/' .. lang
local p = mw.title.new( title )
elseif p2.exists then
page = p2
if p.exists then
output = output .. string.format('<li lang="%s" style="white-space: nowrap;">[[%s|{{#language:%s}}]]</li>', lang, title, lang)
elseif p3.exists then
page = p3
end
else
page = p4
end
end


return output
local expanded = frame:expandTemplate{ title = page, args = frame.args }


return expanded
end
end


function p.get_langtable( frame )
return p

-- 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
output = output .. string.gsub([==[
|-
! scope="row" | {{#language:~LANG~}}
| [[Thank You/~LANG~]]
| [[Ways to Give/~LANG~]]
| [[Problems donating/~LANG~]]
| [[Cancel or change recurring giving/~LANG~]]
| [[Matching Gifts/~LANG~]]
| [[FAQ/~LANG~]]
| [[Tax deductibility/~LANG~]]
]==], '~LANG~', lang)
end

return output

end

Revision as of 19:42, 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
            output = output .. string.format('<li lang="%s" style="white-space: nowrap;">[[%s|{{#language:%s}}]]</li>', lang, title, lang)
        end
    end

    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
    	output = output .. string.gsub([==[
|-
! scope="row" | {{#language:~LANG~}}
| [[Thank You/~LANG~]]
| [[Ways to Give/~LANG~]]
| [[Problems donating/~LANG~]]
| [[Cancel or change recurring giving/~LANG~]]
| [[Matching Gifts/~LANG~]]
| [[FAQ/~LANG~]]
| [[Tax deductibility/~LANG~]]
]==], '~LANG~', lang)
    end

    return output

end