Module:Sandbox: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
⚫ | |||
⚫ | |||
function p.get_langlinks( frame ) |
function p.get_langlinks( frame ) |
||
⚫ | |||
⚫ | |||
local output = '<ul>' |
local output = '<ul>' |
||
local root = 'Problems donating' |
local root = 'Problems donating' |
||
⚫ | |||
for i, lang in ipairs(lang_list) do |
for i, lang in ipairs(lang_list) do |
||
Line 13: | Line 15: | ||
local p = mw.title.new( title ) |
local p = mw.title.new( title ) |
||
if p.exists then |
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 |
||
end |
end |
||
⚫ | |||
return output |
return output |
||
Line 23: | Line 27: | ||
function p.get_langtable( frame ) |
function p.get_langtable( frame ) |
||
local output = '' |
|||
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" } |
|||
⚫ | |||
for i, lang in ipairs(lang_list) do |
for i, lang in ipairs(lang_list) do |
||
local lang_name = mw.language.fetchLanguageName( lang ) |
|||
⚫ | |||
local row = string.format([==[ |
|||
|- |
|- |
||
! scope="row" | |
! scope="row" | %s |
||
| [[Thank You/ |
| [[Thank You/%s]] |
||
| [[Ways to Give/ |
| [[Ways to Give/%s]] |
||
| [[Problems donating/ |
| [[Problems donating/%s]] |
||
| [[Cancel or change recurring giving/ |
| [[Cancel or change recurring giving/%s]] |
||
| [[Matching Gifts/ |
| [[Matching Gifts/%s]] |
||
| [[FAQ/ |
| [[FAQ/%s]] |
||
| [[Tax deductibility/ |
| [[Tax deductibility/%s]] |
||
]==], |
]==], lang_name, lang, lang, lang, lang, lang, lang, lang) |
||
⚫ | |||
end |
end |
||
return output |
return output |
||
end |
|||
country_names_data = mw.loadJsonData( 'User:Pcoombe/sandbox.json' ) |
|||
function p.get_country_name( language_code, country_code ) |
|||
local name = country_names_data[language_code][country_code] |
|||
return name |
|||
end |
|||
function p.make_donate_link( language_code, country_code ) |
|||
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage?utm_medium=Waystogive&utm_source=Waystogive&utm_campaign=C11_Waystogive' |
|||
url = url .. '&uselang=' .. language_code |
|||
url = url .. '&country=' ..country_code |
|||
local link_text = p.get_country_name( language_code, country_code ) |
|||
local link = '[' .. url .. ' ' .. link_text .. ']' |
|||
return link |
|||
end |
end |
Latest revision as of 09:42, 29 April 2023
Documentation for this module may be created at Module:Sandbox/doc
local 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' }
function p.get_langlinks( frame )
local output = '<ul>'
local root = 'Problems donating'
output = output .. string.format('<li lang="en" style="white-space: nowrap;">[[%s|English]]</li>', root)
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 )
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)
output = output .. row
end
return output
end
country_names_data = mw.loadJsonData( 'User:Pcoombe/sandbox.json' )
function p.get_country_name( language_code, country_code )
local name = country_names_data[language_code][country_code]
return name
end
function p.make_donate_link( language_code, country_code )
local url = 'https://donate.wikimedia.org/wiki/Special:FundraiserLandingPage?utm_medium=Waystogive&utm_source=Waystogive&utm_campaign=C11_Waystogive'
url = url .. '&uselang=' .. language_code
url = url .. '&country=' ..country_code
local link_text = p.get_country_name( language_code, country_code )
local link = '[' .. url .. ' ' .. link_text .. ']'
return link
end
return p