Module:Main: Difference between revisions
Content deleted Content added
add similar function for Template:Infobox |
refactor to use a shared fallback_pages function |
||
(7 intermediate revisions by the same user not shown) | |||
Line 2:
local p = {} -- p stands for package
-- Given an array of titles as strings, check them in order and return the first page which exists
function p.fallback_pages( list )
for key, value in ipairs( list ) do
return p
end
end
function p.get_appeal( frame )
Line 8 ⟶ 18:
local language = frame.args.language
local country = frame.args.country
local
'Template:Appeal/' .. appeal_name .. '/' .. language .. '/' .. country ▲ if p1.exists then
page = p1▼
page = p2▼
page = p3▼
▲ else
▲ end
local expanded = frame:expandTemplate{ title = page, args = frame.args }
return expanded
end
Line 37:
local language = frame.args.language
local country = frame.args.country
local page = p.fallback_pages({
'Template:Infobox/Default/en'
})
local expanded = frame:expandTemplate{ title = page, args = frame.args }
▲ local p1 = mw.title.new( 'Template:Infobox/' .. infobox_name .. '/' .. language .. '/' .. country )
return expanded
▲ local p2 = mw.title.new( 'Template:Infobox/' .. infobox_name .. '/' .. language )
▲ local p3 = mw.title.new( 'Template:Infobox/' .. infobox_name .. '/en' )
end
▲ local p4 = mw.title.new( 'Template:Infobox/Default/' .. language )
▲ local p5 = mw.title.new( 'Template:Infobox/Default/en' )
function p.get_tax_message( frame )
local tax_message = frame.args.tax_message
local language = frame.args.language
local country = frame.args.country
if
page =
else
'Template:Tax/' .. tax_message .. '/' .. language, -- custom message
'Template:Tax/' .. country .. '/' .. language, -- special countries e.g. FR/NL
'Template:Tax/Default/' .. language,
'Template:Tax/LinkOnly'
})
end
Line 59 ⟶ 72:
return expanded
end
function p.page_language( frame )
local full_title = mw.title.getCurrentTitle().prefixedText
local t = mw.text.split( full_title, '/' )
local lang = t[#t]
if mw.language.isKnownLanguageTag( lang ) then
else
end
end
|