Modulo:Dadduma nga usar ti

Dokumentasion ti modulo

Daytoy a modulo ket isayangkatna ti plantilia ti {{dadduma nga usar ti}}, pangngaasi a kitaen ti dokumetasionna para iti adu pay a pakaammo.

local mArguments --initialize lazily
local mHatList = require('Modulo:Listaan ti hatnote')
local mHatnote = require('Modulo:Hatnote')
local mOtheruses = require('Modulo:Dadduma nga usar')
local yesNo = require('Modulo:Wensaan')
local p = {}

function p.otherusesof (frame)
	mArguments = require('Modulo:Dagiti argumento')
	return p._otherusesof(mArguments.getArgs(frame))
end

function p._otherusesof (args)
	local currentTitle = mw.title.getCurrentTitle()
	local prefixedText = currentTitle.prefixedText
	local maxArg = 0
	for k, v in pairs(args) do
		if type(k) == 'number' and k > maxArg then maxArg = k end
	end
	local page = args[maxArg]
	if maxArg == 1 then page = mHatnote.disambiguate(page) end
	local ofWhat = nil
	if maxArg > 2 then
		local pages = {}
		local midPages = {}
		for k, v in pairs(args) do
			if type(k) == 'number' and k < maxArg then
				midPages[k] = mHatnote.quote(v)
			end
		end
		for i = 1, maxArg do
			if midPages[i] then pages[#pages + 1] = midPages[i] end
		end
		ofWhat = mHatList.orList(pages)
	end
	if not ofWhat then ofWhat = args[1] or prefixedText end
	local options = {
		title = ofWhat,
		otherText =
			args.topic and
			string.format('nga usar ti %s iti %s', mHatnote.quote(ofWhat), args.topic) or
			string.format('nga usar ti %s', mHatnote.quote(ofWhat))
	}
	local skipCat =
		(currentTitle.isTalkPage or (currentTitle.namespace == 2)) or
		(yesNo(args.category) == false)
	local oddCat =
		skipCat and '' or
		"[[Kategoria:Dagiti plantilia ti hatnote nga agus-usar kadagiti di gagangay a parametro]]"
	if (mw.ustring.lower(args[1] or "") == mw.ustring.lower(prefixedText)) and
		maxArg <= 2 or
		((not args[1]) and (not args[2]))
	then
		options.otherText = options.otherText .. oddCat
	end
	arg = page and {page} or {}
	return mOtheruses._otheruses(arg, options)
end

return p