Module:AlbumCertification
Appearance
Documentation for this module may be created at Module:AlbumCertification/doc
local p = {}
function p.getCertification(frame)
local certInput = mw.text.trim(frame.args['certification'] or '')
local output = ''
local categories = {}
if certInput == '' then
-- not certified yet (under 500 units); not an error
output = 'Uncertified'
table.insert(categories, '[[Category:Uncertified Albums]]')
elseif certInput:lower() == 'gold' then
output = '[[Gold]] ●'
table.insert(categories, '[[Category:Gold Albums]]')
elseif certInput:match('^%d+$') then
local num = tonumber(certInput)
if num >= 1 and num <= 9 then
output = num .. 'x [[Platinum]] ▲'
table.insert(categories, '[[Category:Platinum Albums]]')
elseif num >= 10 then
output = num .. 'x [[Diamond]] ⬥'
table.insert(categories, '[[Category:Diamond Albums]]')
else
output = certInput
table.insert(categories, '[[Category:Albums with Invalid Certifications]]')
end
else
output = certInput
table.insert(categories, '[[Category:Albums with Invalid Certifications]]')
end
return output .. table.concat(categories, '')
end
return p