Module:Conversion-zh: Difference between revisions

m
7 revisions imported: Import template for test
m (Protected "Module:Conversion-zh": High-risk template or module (more info) ([Edit=Allow only autoconfirmed users] (indefinite)))
m (7 revisions imported: Import template for test)
 
(One intermediate revision by the same user not shown)
Line 1:
local lthis = {}
local getArgs
 
lthis.fallbackList = {
local args
, ['zh-mo']={'zh-mo','zh-hant','zh-tw','zh-hk','zh-mo','zh-hans','zh-cn','zh-sg','zh-my'},
l.fallbackList={
['zh-hans']={'zh','zh-hans','zh-cn','zh-sg','zh-my','zh-hant'},'zh-tw','zh-hk','zh-mo'}
, ['zh-hanscn']={'zh-hanscn','zh-cnhans','zh-sgmy','zh-mysg','zh'},
, ['zh-hantsg']={'zh-hantsg','zh-twhans','zh-hkcn','zh-momy','zh'},
, ['zh-cnmy']={'zh-cnmy','zh-hans','zh-mycn','zh-sg','zh'},
, ['zh-sghant']={'zh-sghant','zh-hanstw','zh-cnhk','zh-mymo','zh'},
, ['zh-mytw']={'zh-mytw','zh-hanshant','zh-cnhk','zh-sgmo','zh'},
, ['zh-twhk']={'zh-twhk','zh-hant','zh-hktw','zh-mo','zh'},
, ['zh-hkmo']={'zh-hkmo','zh-hant','zh-tw','zh-mohk','zh'}
,['zh-mo']={'zh-mo','zh-hant','zh-tw','zh-hk','zh'}
}
 
function lthis._main(args, frame)
local frame = mw.getCurrentFrame()
local userlanguage=frame:callParserFunction{ name = 'int', args = {'lang'} }
iflocal ((userlanguage = frame:callParserFunction{ name = 'zhint'), orargs = {'lang'} }
local fallback =l this.fallbackList[userlanguage]
(userlanguage == 'zh-hans') or
if (not fallback) then
(userlanguage == 'zh-hant') or
fallback = this.fallbackList['zh']
(userlanguage == 'zh-cn') or
(userlanguage == 'zh-sg') or
(userlanguage == 'zh-my') or
(userlanguage == 'zh-tw') or
(userlanguage == 'zh-hk') or
(userlanguage == 'zh-mo')) then
else
userlanguage = 'zh'
end
local fallback=l.fallbackList[userlanguage]
for _,langArgName in ipairs(fallback) do
if args[langArgName] ~= nil then
return args[langArgName]
end
Line 38 ⟶ 28:
end
 
function lthis.main(frame)
local getArgs
local args
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
args = getArgs(frame, {parentFirst=true})
return lthis._main(args, frame)
end
 
return lthis
21

edits