Module:Fallback

local langlist = { af = {'nl'}, als = {'de'}, arz = {'ar'}, bar = {'de'}, bexold = {'betarask'}, br = {'fr'}, ckb = {'fa'}, co = {'fr'}, crhcyrl = {'crh'}, crhlatn = {'crh'}, csb = {'pl'}, deat = {'de'}, dech = {'de'}, deformal = {'de'}, engb = {'en'}, frp = {'fr'}, frr = {'de'}, fy = {'nl'}, glk = {'fa'}, hifdeva = {'hif'}, hilatn = {'hif'}, ht = {'fr'}, ikecans = {'ik'}, kkarab = {'kk'}, kkcn = {'kk'}, kkcyrl = {'kk'}, kkkz = {'kk'}, kklatn = {'kk'}, kktr = {'kk'}, ksh = {'de'}, kuarab = {'ku'}, kulatn = {'ku'}, li = {'nl'}, mg = {'fr'}, mzn = {'fa'}, nds = {'ndsnl', 'de'}, ndsnl = {'nds', 'nl'}, nlinformal = {'nl'}, pdt = {'nds', 'de'}, ptbr = {'pt'}, ruggrek = {'ruq'}, rulatn = {'ruq'}, ruqcyrl = {'ruq'}, srec = {'sr'}, srel = {'sr'}, szl = {'pl'}, tgcyrl = {'tg'}, tglatn = {'tg'}, ttcyrl = {'tt'}, ttlatn = {'tt'}, ty = {'fr'}, vec = {'it'}, vls = {'nl'}, wa = {'fr'}, zea = {'nl'}, zh = {'zhhans'}, zhcn = {'zhhans'}, zhhans = {'zhcn', 'zh'}, zhhant = {'zh'}, zhhk = {'zhhant'}, zhmo = {'zhhant'}, zhmy = {'zhhans'}, zhsg = {'zhhans'}, zhtw = {'zhhant'} }

function returnarg(arg) if arg == '~' then return '' elseif arg then return arg else return nil end end

function p.langSwitch(frame) local args = frame.args for i, j in pairs(args) do		i = mw.ustring.gsub( str, "-", "") end lang = args.lang if args[lang] then return returnarg(args[lang]) end if langlist[lang] then tested = {} -- keep track of tested languages to avoid loops for i, j in pairs(langlist[lang]) do			if args[langlist[lang]] then return returnarg(args[langlist[lang]]) end end end if args.default then return returnarg(args.default) end if args.en then return returnarg(args.en) end return end return p