Module:STConversion
Jump to navigation
Jump to search
此模块用于为{{STConversion}}提供功能,具体用法见模板文档。
local p = {}
function p.call( args )
local fallbackString = '<span></span>'
local strings = {
mode = mw.text.trim( args.mode or '' ),
[ 'zh-cn' ] = args[ 'zh-cn' ] or args[ 1 ] or fallbackString,
[ 'zh-tw' ] = args[ 'zh-tw' ] or args[ 2 ] or fallbackString,
[ 'zh-hk' ] = args[ 'zh-hk' ] or args[ 3 ] or fallbackString,
}
if not args.closehkinherit and strings[ 'zh-hk' ] == fallbackString then
strings[ 'zh-hk' ] = strings[ 'zh-tw' ]
end
local static = require( 'Module:Static' )
if not static.STConversion then
static.STConversion = {}
end
if not static.STConversion.currentPageType then
static.STConversion.currentPageType = mw.title.getCurrentTitle().contentModel
end
if static.STConversion.currentPageType == 'css' or static.STConversion.currentPageType == 'javascript' or static.STConversion.currentPageType == 'json' then
return require( 'Module:Lan' ).call( strings )
else
return mw.ustring.format( "-{%szh-cn:%s;zh-tw:%s;zh-hk:%s;}-", ( ( strings.mode ~= '' ) and ( strings.mode .. '|' ) or '' ), strings[ 'zh-cn' ], strings[ 'zh-tw' ], strings[ 'zh-hk' ] )
end
end
function p.main( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
end
return p.call( args )
end
return p