Module:utilities/templates

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

This module implements the following templates:

See their documentation for more information.


local insert = table.insert
local process_params = require("Module:parameters").process

local export = {}

-- Used by {{catfix}}.
function export.catfix(frame)
	local args = process_params(frame:getParent().args, {
		 = {type = "language", required = true},
		 = {alias_of = "sc"},
		 = {type = "script"},
	})
	
	return require("Module:utilities").catfix(args, args.sc)
end

-- Used by {{categorize}}, {{catlangname}} and {{topics}}.
function export.categorize(frame)
	local args = process_params(frame:getParent().args, {
		 = {required = true, type = "language", default = "und"},
		 = {required = true, list = true, allow_holes = true},
		 = {list = true, separate_no_index = true, allow_holes = true},
	})
	
	local lang = args
	if not lang then
		return ""
	end
	local raw_cats = args
	local sort_keys = args.sort
	local default_sort = sort_keys.default
	local cats = {}
	local format = frame.args
	local prefix = format == "pos" and lang:getFullName() .. " " or
		format == "topic" and lang:getFullCode() .. ":" or ""
	
	local cats_with_sort_keys = {}
	for i = 1, raw_cats.maxindex do
		local cat = raw_cats
		if cat then
			cat = prefix .. cat
			insert(cats, cat)
			local sort_key = sort_keys
			if #cats_with_sort_keys > 0 then
				insert(cats_with_sort_keys, {
					category = cat,
					sort_key = sort_key
				})
			elseif sort_key then
				for j = 1, #cats - 1 do
					insert(cats_with_sort_keys, {category = cats})
				end
				insert(cats_with_sort_keys, {
					category = cat,
					sort_key = sort_key
				})
			end
		end
	end
	
	if #cats_with_sort_keys > 0 then
		return require("Module:utilities/format_categories_with_sort_keys")(cats_with_sort_keys, lang, default_sort)
	else
		return require("Module:utilities").format_categories(cats, lang, default_sort)
	end
end

return export