Module:citations

Hello, you have come here looking for the meaning of the word Module:citations. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:citations, but we will also tell you about its etymology, its characteristics and you will know how to say Module:citations in singular and plural. Everything you need to know about the word Module:citations you have here. The definition of the word Module:citations will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:citations, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local m_lang = require("Module:languages")
local link = require("Module:links").full_link
local serial_comma_join = require("Module:table").serialCommaJoin
local format_categories = require("Module:utilities").format_categories
local process = require("Module:parameters").process

local function make_header(terms, lang, full_name, sc, context)
	local term_links = {}
	for i,term in ipairs(terms) do
		term_links = link({term = term, lang = lang, sc = sc}, "term")
	end
	
	return '<h2><span id="' .. full_name .. '">' .. full_name
		.. "</span> citations of "
		.. serial_comma_join(term_links)
		.. (context and ", in context of '']''" or "")
		.. "</h2>"
end

-- If the term is a valid pagename and there isn't an entry for it,
-- return a category.
local function is_undefined(term)
	local success, title = pcall(mw.title.new, term)
	if success and title then
		local existence
		success, existence = pcall(function() return title.exists end)
		if success and not existence then
			return true
		end
	end
	
	return false
end

function export.make_header_and_categories(frame)
	local title		= mw.title.getCurrentTitle()
	local namespace = title.nsText
	local baseText	= title.baseText

	local parent_args = frame:getParent().args
	local compat = parent_args

	local params = {
		 = { required = true },
		 = { list = true, default = baseText },
		lang2 = {},
		sc = {},
		ct = {}, -- context
		sort = {},
	}
	
	local args = process(parent_args, params)
	
	local lang_code = compat or args
	local lang = m_lang.getByCode(lang_code) or m_lang.err(lang_code, "lang")
	local full_name = lang:getFullName()
	
	if args.lang2 then
		require("Module:debug").track("citations/lang2")
	end
	
	local sc = args.sc
	sc = sc and require("Module:scripts").getByCode(sc)
	
	local terms = args
	
	local context = args.ct
	
	local text = {}
	
	table.insert(text, make_header(terms, lang, full_name, sc, context))
	
	if namespace == "Citations" then
		if args.sort then
			table.insert(text, "]")
		end
		
		for _, term in ipairs(terms) do
			if is_undefined(term) then
				table.insert(text, "]")
				break
			end
		end
		
		if terms then
			table.insert(text, "]")
		end
		
		-- "true" to force output in Citations namespace, where ]
		-- may not continue to add categories.
		table.insert(text, format_categories(full_name .. " citations", lang, args.sort, nil, true))
	end
	
	text = table.concat(text)
	
	if compat then
		text = frame:expandTemplate{
			title = "check deprecated lang param usage",
			args = {text, lang = lang_code}
		}
	end
	
	return text
end

return export