Module:Country links: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
No edit summary
refactor for easier testing of different languages
Line 65: Line 65:


function p.get_donate_url( language_code, country_code )
function p.get_donate_url( language_code, country_code )
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage?utm_medium=Waystogive&utm_source=Waystogive&utm_campaign=C11_Waystogive'
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage'
url = url .. '?utm_medium=Waystogive&utm_source=Waystogive&utm_campaign=C11_Waystogive'
url = url .. '&uselang=' .. language_code
url = url .. '&uselang=' .. language_code
url = url .. '&country=' .. country_code
url = url .. '&country=' .. country_code
Line 71: Line 72:
end
end


function p.make_donate_links( country_list )
function p.make_donate_links( language_code, country_list )


local language_code = p.page_language( frame )
local wikitext = ''
local wikitext = ''
local t = {}
local t = {}
Line 92: Line 92:
end
end


function p.main( frame )
function p.build_all_regions( language_code )
local language_code = p.page_language( frame )
local wikitext = ''
local wikitext = ''
for i,v in ipairs(p.regions) do
for i,v in ipairs(p.regions) do
local region_name = p.get_country_name( language_code, v.name_code )
local region_name = p.get_country_name( language_code, v.name_code )
wikitext = wikitext .. '\n== ' .. region_name .. ' ==\n'
wikitext = wikitext .. '\n== ' .. region_name .. ' ==\n'
wikitext = wikitext .. p.make_donate_links( v.countries )
wikitext = wikitext .. p.make_donate_links( language_code, v.countries )
end
end
return wikitext
return wikitext
end
end


function p.main( frame )
local language_code = p.page_language( frame )
return p.build_all_regions( language_code )
end
function p.page_language( frame )
function p.page_language( frame )
local full_title = mw.title.getCurrentTitle().prefixedText
local full_title = mw.title.getCurrentTitle().prefixedText