Module:Sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1:
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 )
 
-- 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'
 
output = output .. string.format('<li lang="%sen" style="white-space: nowrap;">[[%s|{{#language:%s}}English]]</li>', lang, title, langroot)
 
for i, lang in ipairs(lang_list) do
Line 13 ⟶ 15:
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|{{#language:%s}}]]</li>', lang, title, lang)
output = output .. string.format('<li lang="%s" style="white-space: nowrap;">[[%s|%s]]</li>', lang, title, lang_name)
end
end
 
output = output .. string.gsub([==['</ul>'
return output
 
Line 23 ⟶ 27:
function p.get_langtable( frame )
 
--local supportedoutput 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
local lang_name = mw.language.fetchLanguageName( lang )
output = output .. string.gsub([==[
local row = string.format([==[
|-
! scope="row" | {{#language:~LANG~}}%s
| [[Thank You/~LANG~%s]]
| [[Ways to Give/~LANG~%s]]
| [[Problems donating/~LANG~%s]]
| [[Cancel or change recurring giving/~LANG~%s]]
| [[Matching Gifts/~LANG~%s]]
| [[FAQ/~LANG~%s]]
| [[Tax deductibility/~LANG~%s]]
]==], '~LANG~'lang_name, lang, lang, lang, lang, lang, lang, lang)
local output = ""output .. row
end
 
Line 44 ⟶ 48:
 
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