Module:Conversion-zh
Jump to navigation
Jump to search
Lua
Documentation for this module may be created at Module:Conversion-zh/doc
Code
local this = {}
this.fallbackList = {
['zh']={'zh','zh-hans','zh-hant','zh-cn','zh-tw','zh-hk','zh-mo','zh-sg','zh-my'},
['zh-hans']={'zh-hans','zh-cn','zh-sg','zh-my','zh'},
['zh-cn']={'zh-cn','zh-hans','zh-my','zh-sg','zh'},
['zh-sg']={'zh-sg','zh-hans','zh-cn','zh-my','zh'},
['zh-my']={'zh-my','zh-hans','zh-cn','zh-sg','zh'},
['zh-hant']={'zh-hant','zh-tw','zh-hk','zh-mo','zh'},
['zh-tw']={'zh-tw','zh-hant','zh-hk','zh-mo','zh'},
['zh-hk']={'zh-hk','zh-hant','zh-tw','zh-mo','zh'},
['zh-mo']={'zh-mo','zh-hant','zh-tw','zh-hk','zh'}
}
function this._main(args)
local frame = mw.getCurrentFrame()
local userlanguage = frame:callParserFunction{ name = 'int', args = {'lang'} }
local fallback = this.fallbackList[userlanguage]
if (not fallback) then
fallback = this.fallbackList['zh']
end
for _,langArgName in ipairs(fallback) do
if args[langArgName] ~= nil then
return args[langArgName]
end
end
return ''
end
function this.main(frame)
local getArgs
local args
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
args = getArgs(frame, {parentFirst=true})
return this._main(args)
end
return this