Jump to content

Module:Ustring

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Uzume (talk | contribs) at 20:08, 30 April 2020 (maintain error messages). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require('Module:No globals')
return setmetatable({}, {
	__index = function(t, f)
		return function(frame)
			if nil == mw.ustring[f] then
				return '<strong class="error">'..mw.message.new('scribunto-common-nosuchfunction', '', f):plain()..'</strong>'
			end
			if 'function' ~= type(mw.ustring[f]) then
				return '<strong class="error">'..mw.message.new('scribunto-common-notafunction', '', f):plain()..'</strong>'
			end
			local args = frame.args
			for i, v in ipairs(args) do
				args[i] = tonumber(v) or v:gsub("^\\", "", 1)
			end
			if args.tag then
				local tagargs = {}
				for k, v in pairs(args) do
					if 'number' ~= type(k) and 'tag' ~= k then tagargs[k] = v end
				end
				return frame:extensionTag{name = args.tag, content = mw.ustring[f](unpack(args)), args = tagargs}
			end
			return (mw.ustring[f](unpack(args)))
		end
	end
})