Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Conversion-zh

From Neodyland Wiki
Module documentation[ create · purge ]
This documentation is transcluded from Module:Conversion-zh/doc.
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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.