Module:Country links: Difference between revisions
Content deleted Content added
No edit summary |
update donate links to use wmf parameters |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 4:
{
name = "Africa",
name_code = "
countries = {
"DZ", "AO", "BI", "TD", "EG", "GH", "KE", "LR", "MA", "NE",
Line 12:
{
name = "Asia",
name_code = "
countries = {
"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", "
}
},
{
name = "Europe",
name_code = "
countries = {
"AL", "AD", "AT", "BE", "BA", "BG", "HR", "CY", "CZ", "DK",
"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
}
},
{
name = "North America",
name_code = "
countries = {
"US", "AW", "BS", "BB", "BZ", "BM", "CA", "CR", "DM", "GD",
Line 41 ⟶ 40:
{
name = "South America",
name_code = "
countries = {
"AR", "BO", "BR", "CL", "CO", "EC", "FK", "GF", "GY", "
}
},
{
name = "Oceania",
name_code = "
countries = {
"AS", "AU", "CK", "FJ", "PF", "GU", "KI", "MH", "FM", "NR",
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 name = country_names_data['en'][country_code]
else
name = country_names_data[language_code][country_code]
end
return name
end
function p.get_donate_url( language_code, country_code )
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage'
url = url .. '? url = url .. '&uselang=' .. language_code
url = url .. '&country=' .. country_code
Line 71 ⟶ 77:
end
function p.make_donate_links( language_code, country_list )
local language_code = p.page_language( frame )▼
local wikitext = ''
local t = {}
Line 92 ⟶ 97:
end
function p.
local
for i,v in ipairs(p.regions) do
local region_name = p.get_country_name( language_code, v.name_code )
out = out .. '<div class="mw-collapsible-toggle continent-header">' .. region_name .. '</div>\n'
wikitext = wikitext .. p.make_donate_links( v.countries )▼
out = out .. '<div class="mw-collapsible-content country-list">\n'
out = out .. '</div>\n'
out = out .. '</div>\n'
end
return
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 112 ⟶ 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
|