Module:Country links: Difference between revisions

Content deleted Content added
refactor for easier testing of different languages
update donate links to use wmf parameters
 
(5 intermediate revisions by 2 users not shown)
Line 16:
"AZ", "BH", "BD", "BT", "BN", "KH", "CN", "TL", "HK", "IN",
"IL", "JP", "JO", "KZ", "KW", "MO", "MY", "MV", "MN", "NP",
"OM", "PK", "PH", "QA", "SG", "LK", "TW", "TJ", "TH", "AEVN",
"VN"
}
},
Line 27 ⟶ 26:
"EE", "FR", "GE", "DE", "GR", "HU", "IS", "IT", "LV", "LI",
"LT", "LU", "MT", "MC", "ME", "NL", "NO", "PL", "PT", "IE",
"RO", "RS", "SK", "SI", "ES", "SE", "CH", "UA", "GB", "VA"
}
},
Line 43 ⟶ 42:
name_code = "r005",
countries = {
"AR", "BO", "BR", "CL", "CO", "EC", "FK", "GF", "GY", "PYPE",
"PE", "SR", "UY", "VE"
}
},
Line 59 ⟶ 58:
function p.get_country_name( language_code, country_code )
local name
if country_names_data[language_code] == nil then
language_code = 'en'
end
local name =if country_names_data[language_code][country_code] == nil then
name = country_names_data['en'][country_code]
else
name = country_names_data[language_code][country_code]
end
return name
end
Line 66 ⟶ 71:
function p.get_donate_url( language_code, country_code )
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage'
url = url .. '?utm_mediumwmf_medium=Waystogive&utm_sourcewmf_source=Waystogive&utm_campaignwmf_campaign=C11_Waystogive'
url = url .. '&uselang=' .. language_code
url = url .. '&country=' .. country_code
Line 93 ⟶ 98:
 
function p.build_all_regions( language_code )
local wikitextout = ''
for i,v in ipairs(p.regions) do
local region_name = p.get_country_name( language_code, v.name_code )
wikitextout = wikitextout .. '\n=<div class="mw-collapsible ' .. region_name .. ' ==mw-collapsed">\n'
out = out .. '<div class="mw-collapsible-toggle continent-header">' .. region_name .. '</div>\n'
wikitext = wikitext .. p.make_donate_links( language_code, v.countries )
out = out .. '<div class="mw-collapsible-content country-list">\n'
wikitextout = wikitextout .. p.make_donate_links( language_code, v.countries )
out = out .. '</div>\n'
out = out .. '</div>\n'
end
return wikitextout
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 )
local full_title = mw.title.getCurrentTitle().prefixedText
Line 116 ⟶ 125:
return 'en'
end
end
 
-- version we can #invoke with parameters
function p.get_country_name_wrapper( frame )
return p.get_country_name( frame.args[1], frame.args[2] )
end