模組:NoteTA/MediaWiki

維基詞典,自由的多語言詞典


-- 本頁面複製自[[w:zh:Module:NoteTA/MediaWiki]],由機器人定期更新。請直接編輯原維基項目頁面,或自設定頁面[[User:Cewbot/log/20211203/configuration]]去除本頁面之後再編輯。
local z = {}
local WikitextLC = require( 'Module:WikitextLC' )
local NoteTA = require( 'Module:NoteTA' )

function Tcode( args )
	if args.T == nil or args.T == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		:attr( 'class', 'noteTA-title' )
		:attr( 'data-noteta-code', args.T )
		:wikitext( WikitextLC.title( args.T ) )
	if args.dt ~= nil and args.dt ~= '' then
		div:attr( 'data-noteta-desc', args.dt )
	end
	return tostring( div )
end

function local_( i, code, desc )
	if code == nil or code == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		-- :attr( 'id', 'noteTA-local-' .. i )
		:attr( 'data-noteta-code', code )
		:wikitext( WikitextLC.hidden( code ) )
	if desc ~= nil and desc ~= '' then
		div:attr( 'data-noteta-desc', desc )
	end
	return tostring( div )
end

function Lcode( args )
	local code = {}
	for i = 1, 30 do
		table.insert( code, local_( i, args[i], args['d' .. i] ) )
	end
	code = table.concat( code )
	if code ~= '' then
		code = tostring( mw.html.create( 'div' )
				:attr( 'class', 'noteTA-local' )
				:wikitext( code ) )
		if args[31] ~= nil then
			code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
		end
	end
	return code
end

function z.main( frame, args )
	local args = frame:getParent().args
	local Tc = NoteTA.Tcode( args )
	--local Gc = NoteTA.Gcode( args, frame )
	--==>不接受轉換組
	local Gc = require( 'Module:CGroupViewer2' )._conversion(frame, {[1] = 'MediaWiki_special'})
	local Lc = NoteTA.Lcode( args )
	local code = Tc .. Gc .. Lc
	if code ~= '' then
		local hash = require( 'Module:Crc32lua' ).crc32( mw.dumpObject( args ) )
		code = frame:extensionTag{
			name = 'indicator',
			content = '[[File:Zh conversion icon m.svg|35px|本页使用了标题或全文手工转换|link=]]',
			args = { name = string.format( 'noteTA-%x', hash ) },
		} .. tostring( mw.html.create( 'div' )
				:attr( 'id', string.format( 'noteTA-%x', hash ) )
				:attr( 'class', 'noteTA' )
				:wikitext( code ) )
		if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
			code = code .. '[[Category:放置于模板的noteTA]]'
		elseif mw.title.getCurrentTitle():inNamespace( 0 ) then
			code = require( 'Module:Error' ).error{'警告:條目頁面不允許使用[[Wikipedia:字詞轉換處理/公共轉換組|公共轉換組]][[模块:CGroup/MediaWiki_special|MediaWiki]]及其相關模板'}
		end
	end
	return code
end