Module:Int

From Islamical Commons
Revision as of 08:42, 25 September 2026 by Shahroudi (talk | contribs) (Created page with "-- This is a helper module for Template:Int local trim = mw.text.trim local isValidCode = mw.language.isValidCode local messageNew = mw.message.new local frameCurrent = mw.getCurrentFrame() local preprocess = frameCurrent.preprocess local pageLang = preprocess(frameCurrent, '{{PAGELANGUAGE}}') local export = {} function export.renderIntMessage(frame) local args = frame.args local msgId = trim(args[1]) local pargs = (frame:getParent() or {}).args local msgArgs...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Int/doc

-- This is a helper module for [[Template:Int]]

local trim = mw.text.trim
local isValidCode = mw.language.isValidCode
local messageNew = mw.message.new

local frameCurrent = mw.getCurrentFrame()
local preprocess = frameCurrent.preprocess
local pageLang = preprocess(frameCurrent, '{{PAGELANGUAGE}}')

local export = {}

function export.renderIntMessage(frame)
	local args = frame.args
	local msgId = trim(args[1])
	local pargs = (frame:getParent() or {}).args
	local msgArgs = {}
	for k, v in pairs(pargs) do
		local n = tonumber(k) or 0
		if n >= 2 then
			msgArgs[n - 1] = trim(v)
		end
	end
	local lang = args.lang
	if not lang or lang == '' or not isValidCode(lang) then
		lang = pageLang
	end
	local msg = messageNew(msgId, msgArgs):inLanguage(lang)
	if lang == 'qqx' or msg:exists() then
			return msg:isDisabled() and (args.missing or '') or preprocess(frameCurrent, msg:plain())
	else
		return args.missing ~= '' and args.missing or '⧼' .. msgId .. '⧽'
	end
end

return export