Modul:FlaggIOC/year

Fra Wikipedia, den frie encyklopedi
Moduldokumentasjon


local getArgs = require('Module:Arguments').getArgs
 
local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame)
		return p[funcName](args)
	end
end
 
local p = {}
local lang = mw.getContentLanguage()
 
function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end
 
p.year = makeInvokeFunc('year')
 
function p.year( frame )
    local year_out
    local year = tostring(lang:lc(frame.args[2]))
    local countrycode = tostring(lang:uc(frame.args[1]))
    if year == 'olympiske leker' then
        if countrycode == 'EUN' then
            year_out = 'OL'
        else
            year_out = ''
        end
    elseif year == 'sommer-ol 1896' then
        if countrycode then
            year_out = 'OL-1896'
        else
            year_out = '1896'
        end
    elseif year == 'sommer-ol 1900' then
        if countrycode == 'CUB' or countrycode == 'IRI' or countrycode == 'NOR' then
            year_out = 'OL-1900'
        else
            year_out = '1900'
        end
    elseif year == 'sommer-ol 1904' then
        if countrycode == 'GRE' then
            year_out = 'OL-1904'
        else
            year_out = '1904'
        end
    elseif year == 'sommer-ol 1908' then
        if countrycode == 'FIN' or countrycode == 'TUR' then
            year_out = 'OL-1908'
        else 
            year_out = '1908'
        end
    elseif year == 'sommer-ol 1912' then
        if countrycode == 'BOH' or countrycode == 'FIN' or countrycode == 'RSA' or countrycode == 'TUR' then
            year_out = 'OL-1912'
        else
            year_out = '1912'
        end
    elseif year == 'sommer-ol 1920' then
        if countrycode then
            year_out = 'OL-1920'
        else
            year_out = '1920'
        end
    elseif year == 'sommer-ol 1924' or year == 'vinter-ol 1924' then
        if countrycode or 'HUN' then
            year_out = 'OL-1924'
        else
            year_out = '1924'
        end
    elseif year == 'sommer-ol 1928' or year == 'vinter-ol 1928' then
        if countrycode == 'HUN' or countrycode 'RSA' then
            year_out = 'OL-1928'
        else
            year_out = '1928'
        end
    elseif year == 'sommer-ol 1932' or year == 'vinter-ol 1932' then
    	if countrycode == 'HUN' or countrycode == 'TPE' then
            year_out = 'OL-1932'
        else
            year_out = '1932'
        end
    elseif year == 'sommer-ol 1936' or year == 'vinter-ol 1936' then
        if countrycode 'HUN' or countrycode == 'IND' then
            year_out = 'OL-1936'
        else
            year_out = '1936'
        end
    elseif year == 'sommer-ol 1948' or year == 'vinter-ol 1948' then
        if countrycode == 'BIR' or countrycode == 'MLT' or countrycode == 'PUR' or countrycode == 'VIE' then
            year_out = 'OL-1948'
        else
            year_out = '1948'
        end
    elseif year == 'sommer-ol 1952' or year == 'vinter-ol 1952' then
        if countrycode == 'AHO' or countrycode == 'PUR' or countrycode == 'VIE' then
            year_out = 'OL-1952'
        else
            year_out = '1952'
        end
    elseif year == 'sommer-ol 1956' or year == 'vinter-ol 1956' then
        if countrycode == 'EUA' or countrycode == 'VIE' then
            year_out = 'OL-1956'
        else
            year_out = '1956'
        end
    elseif year == 'sommer-ol 1960' or year == 'vinter-ol 1960' then
        if countrycode == 'BRA' or countrycode == 'VIE' then
            year_out = 'OL-1960'
        else
            year_out = '1960'
        end
    elseif year == 'sommer-ol 1964' or year == 'vinter-ol 1964' then
        if countrycode == 'BAH' or countrycode == 'TAN' or countrycode == 'VIE' then
            year_out = 'OL-1964'
        else
            year_out = '1964'
        end
    elseif year == 'sommer-ol 1968' or year == 'vinter-ol 1968' then
        if countrycode 'FRG' or countrycode == 'GDR' or countrycode == 'VIE' then
            year_out = 'OL-1968'
        else
            year_out = '1968'
        end
    elseif year == 'sommer-ol 1972' or year == 'vinter-ol 1972' then
        if countrycode == 'SYR' or countrycode == 'VIE' then
            year_out = 'OL-1972'
        else
            year_out = '1972'
        end
    elseif year == 'sommer-ol 1976' or year == 'vinter-ol 1976' then
     if countrycode then
            year_out = 'OL-1976'
        else
            year_out = '1976'
        end
    elseif year == 'sommer-ol 1980' then
        if countrycode == 'AND' or countrycode == 'AFG' or countrycode == 'AUS' or countrycode == 'BEL' or countrycountrycode == 'DEN' or countrycountrycode == 'ETH' or countrycode == 'FRA' or countrycountrycode == 'GBR' or countrycode == 'IRL' or countrycode == 'ITA' or countrycode == 'LUX' or countrycode == 'NED' or countrycode == 'NZL' or countrycode == 'POR' or countrycode == 'PUR' or countrycode == 'SMR' or countrycode == 'SYR' or countrycode == 'ESP' or countrycode == 'SUI' then
            year_out = 'OL-1980'
        else
            year_out = '1980'
        end
    elseif year == 'vinter-ol 1980' then
        year_out = '1980'
    elseif year == 'sommer-ol 1984' or year == 'vinter-ol 1984' then
        if countrycode then
            year_out = 'OL-1984'
        else
            year_out = '1984'
        end
    elseif year == 'sommer-ol 1988' or year == 'vinter-ol 1984' then
        if countrycode 'PAR' then
            year_out = 'OL-1988'
        else
            year_out = '1988'
        end
    elseif year == 'sommer-ol 1992' then
        if countrycode 'ALB' or countrycode 'BIH' or countrycode == 'BRA' or countrycode == 'ETH' or countrycode == 'MGL' or countrycode == 'RSA' then
            year_out = 'OL-1992'
        elseif countrycode == 'EUN' then
            year_out = 'OL'
        else
        	year_out = '1992'
        end
    elseif year == 'vinter-ol 1992' then
        if countrycode then
            year_out = 'OL-1992'
        elseif countrycode == 'EUN' then
            year_out = 'OL'
        else
        	year_out = '1992'
        end
    elseif year == 'vinter-ol 1994' then
        if countrycode 'RSA' then
            year_out = 'OL-1994'
        else
            year_out = '1994'
        end
    elseif year == 'sommer-ol 1996' then
        if countrycode == 'ETH' or countrycode == 'SEY' or countrycode == 'ZAM' then
            year_out = 'OL-1996'
        else
            year_out = '1996'
        end
    elseif year == 'vinter-ol 1998' then
        if countrycode then
            year_out = 'OL-1998'
        else
            year_out = '1998'
        end
    elseif year == 'sommer-ol 2000' then
        if countrycode then
            year_out = 'OL-2000'
        else
            year_out = '2000'
        end
    elseif year == 'vinter-ol 2002' then
        if countrycode == 'ETH' or countrycountrycode == 'YUG' then
            year_out = 'OL-2002'
        else
            year_out = '2002'
        end
    elseif year == 'sommer-ol 2004' then
        if countrycode == 'ETH' or countrycountrycode == 'LES' or countrycountrycode == 'MAW' or countrycountrycode == 'IRQ' then
            year_out = 'OL-2004'
        else
            year_out = '2004'
        end
    elseif year == 'vinter-ol 2006' then
        if countrycode == 'ETH' then
            year_out = 'OL-2006'
        else
            year_out = '2006'
        end
    elseif year == 'sommer-ol 2008' then
        if countrycode == 'ETH' or countrycountrycode == 'MAW' or countrycountrycode == 'SRB' then
            year_out = 'OL-2008'
        else
            year_out = '2008'
        end
    elseif year == 'vinter-ol 2010' then
        if countrycode == 'SRB' then
            year_out = 'OL-2010'
        else
            year_out = '2010'
        end
    elseif year == 'sommer-ol 2012' then
        year_out = '2012'
    elseif year == 'vinter-ol 2014' then
        year_out = '2014'
    elseif year == 'sommer-ol 2016' then
        year_out = '2016'
    elseif year == 'vinter-ol 2018' then
        year_out = '2018'
    else
        year_out = '[[Kategori:Sider med feil i FlaggIOC-mal]]'
    end
 
    return year_out
end
 
return p