模块:Translate

From Limbo Wiki

此模块的文档可以在模块:Translate/doc创建

local p = {};

function p.get(frame)
	f = mw.getCurrentFrame();
	a = ":Limbo_Wiki:Config/" .. frame.args[1];
	if not(frame.args[2] == frame.args[3]) then
		b = a .. "/" .. frame.args[3];
		if (mw.title.new(b,"").exists) then
			a = b;
		end
		b = nil;
	end
	a = f:expandTemplate{title = a};
	return a;
end

function p.single(frame)
	a = p.get{args={frame.args[1],frame.args[2],frame.args[3]}};
	a = mw.text.split(a,"\n",true);
	return a[tonumber(frame.args[4])+1];
end

function p.trs(frame)
	f = mw.getCurrentFrame();
	a = frame.args[1];
	if not(frame.args[2] == frame.args[3]) then
		b = a .. "/" .. frame.args[3];
		if (mw.title.new(b,"").exists) then
			a = b;
		end
		b = nil;
	end
	a = f:expandTemplate{title = a};
	return a;
end

function p.ind(frame)
	f = mw.getCurrentFrame();
	f:extensionTag {
	name = "indicator",
	content = frame.args[2],
	args = {name = frame.args[1]}
	};
	return;
end

return p;
-- =p.get{args={"Date","zh","en"}}