Módulo:links/templates

Hej, du har kommit hit för att leta efter betydelsen av ordet Módulo:links/templates. I DICTIOUS hittar du inte bara alla ordboksbetydelser av ordet Módulo:links/templates, utan du får också veta mer om dess etymologi, dess egenskaper och hur man säger Módulo:links/templates i singular och plural. Allt du behöver veta om ordet Módulo:links/templates finns här. Definitionen av ordet Módulo:links/templates hjälper dig att vara mer exakt och korrekt när du talar eller skriver dina texter. Genom att känna till definitionen avMódulo:links/templates och andra ord berikar du ditt ordförråd och får tillgång till fler och bättre språkliga resurser.

A documentação para este módulo pode ser criada na página Módulo:links/templates/doc

local process_params = require("Module:parameters").process
local remove = table.remove
local upper = require("Module:string utilities").upper

local export = {}

--[=[
	Modules used:
	]
	]
	]
	]
	]
]=]

do
	local function get_args(frame)
		-- `compat` is a compatibility mode for {{term}}.
		-- If given a nonempty value, the function uses lang= to specify the
		-- language, and all the positional parameters shift one number lower.
		local iargs = frame.args
		iargs.compat = iargs.compat and iargs.compat ~= ""
		iargs.langname = iargs.langname and iargs.langname ~= ""
		iargs.notself = iargs.notself and iargs.notself ~= ""
		local alias_of_4 = {alias_of = 4}
		local boolean = {type = "boolean"}
		local plain = {}
		local params = {
			 = {required = true, type = "language", default = "und"},
			 = plain,
			 = plain,
			 = plain,
			 = {list = true},
			 = alias_of_4,
			 = plain,
			 = plain,
			 = plain,
			 = {type = "script"},
			 = alias_of_4,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = plain,
			 = boolean,
		}
		if iargs.compat then
			params = {type = "language", default = "und"}
			remove(params, 1)
			alias_of_4.alias_of = 3
		end
		if iargs.langname then
			params = boolean
		end
		return process_params(frame:getParent().args, params), iargs
	end
	
	-- Used in ] and ].
	function export.l_term_t(frame)
		local m_debug = require("Module:debug")
		
		local args, iargs = get_args(frame)
		local compat = iargs.compat
		local lang = args
		
		-- Tracking for und.
		if not compat and lang:getCode() == "und" then
			m_debug.track("link/und")
		end
		
		local term = args
		local alt = args
		term = term ~= "" and term or nil
		
		if not term and not alt and iargs.demo then
			term = iargs.demo
		end
		
		local langname = iargs.langname and (
			args.w and lang:makeWikipediaLink() or
			lang:getCanonicalName()
		) or nil
		
		if langname and term == "-" then
			return langname
		end
		-- Forward the information to full_link
		return (langname and langname .. " " or "") .. require("Module:links").full_link(
			{
				lang = lang,
				sc = args.sc,
				track_sc = true,
				term = term,
				alt = alt,
				gloss = args,
				id = args,
				tr = args,
				ts = args,
				genders = args,
				pos = args,
				lit = args,
				accel = args and {
					form = args,
					translit = args,
					lemma = args,
					lemma_translit = args,
					gender = args,
					nostore = args,
				} or nil
			},
			iargs.face,
			not iargs.notself
		)
	end
end

-- Used in ].
do
	local function get_args(frame)
		local plain = {}
		return process_params(frame:getParent().args, {
			 = {required = true, type = "language", default = "und"},
			 = {allow_empty = true},
			 = plain,
			 = plain,
			 = {type = "script"},
		})
	end
	
	function export.ll(frame)
		local args = get_args(frame)
		local lang = args
		local sc = args
		local term = args
		term = term ~= "" and term or nil
		
		return require("Module:links").language_link{
			lang = lang,
			sc = sc,
			term = term,
			alt = args,
			id = args.id
		} or "<small></small>" ..
			require("Module:utilities").format_categories(
				{lang:getFullName() .. " term requests"},
				lang, "-", nil, nil, sc
			)
	end
end

function export.def_t(frame)
	local args = process_params(frame:getParent().args, {
		 = {required = true, default = ""},
	})
	
	local lang = require("Module:languages").getByCode("en")
	local sc = require("Module:scripts").getByCode("Latn")
	
	return require("Module:script utilities").tag_text(require("Module:links").embedded_language_links{
		term = args,
		lang = lang,
		sc = sc
	}, lang, sc)
end


function export.linkify_t(frame)
	local args = process_params(frame:getParent().args, {
		 = {required = true, default = ""},
	})
	
	args = mw.text.trim(args)
	
	if args == "" or args:find("[[", nil, true) then
		return args
	else
		return " .. "]]"
	end
end

function export.cap_t(frame)
	local args = process_params(frame:getParent().args, {
		 = {required = true},
		 = {type = "language", default = "en"},
	})
	
	local term = args
	
	return require("Module:links").full_link{
		lang = args.lang,
		term = term,
		alt = term:gsub("^.*", upper)
	}
end

function export.section_link_t(frame)
	local args = process_params(frame:getParent().args, {
		 = {},
	})
	
	return require("Module:links").section_link(args)
end

return export