Jump to content

Template:Fallback: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
Zolo (talk | contribs)
test
m rvv
Tag: Undo
 
(185 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{#ifexist: Template:{{{1|}}}/{{#if: {{{2|}}} |{{{2}}}|{{int:Lang}}}} |{{#if: {{{2|}}} |{{{2}}}|{{int:Lang}}}}|{{CONTENTLANGUAGE}}}}<noinclude>
local p = {}
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'}
}


{{documentation}}
function returnarg(arg)
</noinclude>
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( i, "-", "")
end
if args.lang then
lang = args.lang
else
lang = mw.message:text('{{int:lang}}')
end
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

Latest revision as of 23:55, 18 June 2023

en

Template documentation

This template was imported from commons:Template:Fallback without the here unusable documentation.


Use localised subpage for the user language with fallback to {{CONTENTLANGUAGE}}

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
page1

Template name

Page namerequired
lang2

override user language on localised page

Default
{{int:Lang}}
Stringoptional