Module:etymology/templates

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

This module generates content for several etymology templates. They include:

Also, the following specialized borrowing templates (not including {{bor}}/{{borrowed}} itself):

Miscellaneous etymology templates that take a single term parameter:

Miscellaneous etymology templates that take no term parameter:

Some templates that used to be here but have now been moved to submodules:


local export = {}

local require_when_needed = require("Module:require when needed")

local concat = table.concat
local format_categories = require_when_needed("Module:utilities", "format_categories")
local insert = table.insert
local process_params = require_when_needed("Module:parameters", "process")
local trim = mw.text.trim
local lower = mw.ustring.lower

local etymology_module = "Module:etymology"
local etymology_specialized_module = "Module:etymology/specialized"
local m_internal = require("Module:etymology/templates/internal")

-- For testing
local force_cat = false

function export.etyl(frame)
	local params = {
		 = {required = true, type = "language", default = "und"},
		 = {type = "language", default = "en"},
		 = {},
	}
	-- Empty language means English, but "-" means no language. Yes, confusing...
	local args = frame:getParent().args
	if args and trim(args) == "-" then
		params = nil
		args = process_params({
			 = args,
			 = args
		}, params)
	else
		args = process_params(args, params)
	end
	return require(etymology_module).format_source {
		lang = args,
		source = args,
		sort_key = args
	}
end


-- Supports various specialized types of borrowings, according to `frame.args.bortype`:
--   "learned" = {{lbor}}/{{learned borrowing}}
--   "semi-learned" = {{slbor}}/{{semi-learned borrowing}}
--   "orthographic" = {{obor}}/{{orthographic borrowing}}
--   "unadapted" = {{ubor}}/{{unadapted borrowing}}
--   "calque" = {{cal}}/{{calque}}
--   "partial-calque" = {{pcal}}/{{partial calque}}
--   "semantic-loan" = {{sl}}/{{semantic loan}}
--   "transliteration" = {{translit}}/{{transliteration}}
--   "phono-semantic-matching" = {{psm}}/{{phono-semantic matching}}
function export.specialized_borrowing(frame)
	local bortype = frame.args.bortype
	local args = frame:getParent().args
	if args.gloss then
		require("Module:debug").track("borrowing/" .. bortype .. "/gloss param")
	end

	-- More informative error message for {{calque}}, which used to support other params.
	if bortype == "calque" and (args or args or args or args) then
		error("{{]}} no longer supports parameters beginning with etyl. " ..
			"The parameters supported are similar to those used by " ..
			"{{]}}, {{]}}, " ..
			"{{]}}. See ] for more.")
	end
	
	local lang, term, sources
	args, lang, term, sources = m_internal.parse_2_lang_args(frame, "has text")
	local m_etymology_specialized = require(etymology_specialized_module)
	if sources then
		return m_etymology_specialized.specialized_multi_borrowing {
			bortype = bortype,
			lang = lang,
			sc = term.sc,
			sources = sources,
			terminfo = term,
			sort_key = args.sort,
			nocap = args.nocap,
			notext = args.notext,
			nocat = args.nocat,
			conj = args.conj,
			senseid = args.senseid,
		}
	else
		return m_etymology_specialized.specialized_borrowing {
			bortype = bortype,
			lang = lang,
			terminfo = term,
			sort_key = args.sort,
			nocap = args.nocap,
			notext = args.notext,
			nocat = args.nocat,
			senseid = args.senseid,
		}
	end
end


-- Implementation of miscellaneous templates such as {{back-formation}}, {{clipping}},
-- {{ellipsis}}, {{rebracketing}}, and {{reduplication}} that have a single
-- associated term.
do
	local function get_args(frame)
		local alias_of_t = {alias_of = "t"}
		local boolean = {type = "boolean"}
		local plain = {}
		local params = {
			 = {required = true, type = "language", default = "und"},
			 = plain,
			 = {alias_of = "alt"},
			 = alias_of_t,
			
			 = plain,
			 = alias_of_t,
			 = {list = true},
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = {type = "script"},
			
			 = boolean, -- should be processed in the template itself
			 = boolean,
			 = boolean,
			 = plain,
		}
		-- |ignore-params= parameter to module invocation specifies
		-- additional parameter names to allow  in template invocation, separated by
		-- commas. They must consist of ASCII letters or numbers or hyphens.
		local ignore_params = frame.args
		if ignore_params then
			ignore_params = trim(ignore_params)
			if not ignore_params:match("^+$") then
				error("Invalid characters in |ignore-params=: " .. ignore_params:gsub("+", ""))
			end
			for param in ignore_params:gmatch("+") do
				if params then
					error("Duplicate param |" .. param
						.. " in |ignore-params=: already specified in params")
				end
				params = plain
			end
		end
		return process_params(frame:getParent().args, params)
	end
	
	function export.misc_variant(frame)		
		local args = get_args(frame)
		local lang = args
		local sc = args

		local parts = {}
		if not args then
			insert(parts, frame.args)
		end
		if args or args then
			if not args then
				insert(parts, " ")
				insert(parts, frame.args or "of")
				insert(parts, " ")
			end
			insert(parts, require("Module:links").full_link(
				{
					lang = lang,
					sc = sc,
					term = args,
					alt = args,
					id = args,
					tr = args,
					ts = args,
					genders = args,
					gloss = args,
					pos = args,
					lit = args,
				},
				"term"))
		end
		-- Allow |cat=, |cat2=, |cat3=, etc. They must be sequential. If |cat=
		-- is not defined, |cat2= will not be checked. Empty categories are ignored.
		local categories = {}
		if not args and frame.args then
			local cat_number
			while true do
				local cat = frame.args
				if not cat then break end
				cat = trim(cat)
				if cat ~= "" then
					insert(categories, lang:getFullName() .. " " .. cat)
				end
				cat_number = (cat_number or 1) + 1
			end
		end
		if #categories > 0 then
			insert(
				parts,
				format_categories(categories, lang, args, nil, force_cat))
		end

		return concat(parts)
	end
end


-- Implementation of miscellaneous templates such as {{unknown}} that have no
-- associated terms.
do
	local function get_args(frame)
		local boolean = {type = "boolean"}
		local plain = {}
		local params = {
			 = {required = true, type = "language", default = "und"},

			 = plain,
			 = boolean, -- should be processed in the template itself
			 = boolean,
			 = boolean,
			 = plain,
		}
		if frame.args then
			params = {alias_of = "title"}
		end
		return process_params(frame:getParent().args, params)
	end

	function export.misc_variant_no_term(frame)
		local args = get_args(frame)
		local lang = args
		
		local parts = {}
		if not args then
			insert(parts, args or frame.args)
		end
		if not args and frame.args then
			local categories = {}
			insert(categories, lang:getFullName() .. " " .. frame.args)
			insert(parts, format_categories(categories, lang, args, nil, force_cat))
		end

		return concat(parts)
	end

	--This function works similarly to misc_variant_no_term(), but with some automatic linking to the glossary in `title`.
	function export.onomatopoeia(frame)
		local args = get_args(frame)

		if args and (lower(args) == "imitative" or lower(args) == "imitation") then
			args = " .. "]]"
		end

		local lang = args
		
		local parts = {}
		if not args then
			insert(parts, args or frame.args)
		end
		if not args and frame.args then
			local categories = {}
			insert(categories, lang:getFullName() .. " " .. frame.args)
			insert(parts, format_categories(categories, lang, args, nil, force_cat))
		end

		return concat(parts)
	end
end

return export