Module:User:Benwing2/links/templates

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

This is a private module sandbox of Benwing2, for their own experimentation. Items in this module may be added and removed at Benwing2's discretion; do not rely on this module's stability.


local export = {}

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

-- Used in ] and ].
function export.l_term_t(frame)
	local face = frame.args
	local allowSelfLink = frame.args; allowSelfLink = not allowSelfLink or allowSelfLink == ""
	
	local params = {
		 = {required = true},
		 = {},
		 = {},
		 = {alias_of = "gloss"},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {type = "boolean"},
		 = {list = true},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {alias_of = "gloss"},
		 = {},
		 = {},
		 = {},
	}
	
	-- 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 compat = (frame.args or "") ~= ""
	
	if compat then
		params = {},
		table.remove(params, 1)
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local lang = args
	
	-- Tracking for missing language or und
	if not lang then
		require("Module:debug").track("link/no lang")
	elseif lang == "und" then
		require("Module:debug").track("link/und")
	end
	
	lang = lang or "und"
	local sc = args
	
	local term = args
	local alt = args
	
	-- Check parameters
	lang = require("Module:languages").getByCode(lang, 1, "allow etym")
	lang = require("Module:languages").getFull(lang)
	
	if sc then
		sc = require("Module:scripts").getByCode(sc, "sc")
	end
	
	if not term and not alt and frame.args then
		term = frame.args
	end
	
	-- Forward the information to full_link
	return require("Module:User:Benwing2/links").full_link( 
		{
			lang = lang, 
			sc = sc, 
			term = term,
			alt = alt, 
			id = args, 
			tr = args,
			ts = args,
			genders = args, 
			gloss = args, 
			pos = args, 
			lit = args,
			accel = args and {
				form = args,
				translit = args,
				lemma = args,
				lemma_translit = args,
				gender = args,
				nostore = args,
			} or nil,
		},
		face,
		allowSelfLink
	)
end

-- Used in ].
function export.ll(frame)
	local params = {
		 = { required = true },
		 = { allow_empty = true },
		 = {},
		 = { type = "boolean", default = false },
		 = {},
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local allowSelfLink = not args
	
	local lang = args
	lang = require("Module:languages").getByCode(lang, 1, "allow etym")
	lang = require("Module:languages").getFull(lang)

	local text = args
	local alt = args
	if text == "" then
		return alt or ""
	end
	
	local id = args
	
	return require("Module:User:Benwing2/links").language_link(
		{
			term = text,
			alt = alt,
			lang = lang,
			id = id
		},
		allowSelfLink
	)
end

function export.def_t(frame)
	local params = {
		 = {required = true, default = ""},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	return require("Module:User:Benwing2/links").english_links(args)
end


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

function export.section_link_t(frame)
	local params = {
		 = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	return require("Module:User:Benwing2/links").section_link(args)
end

function export.language_name_link_t(frame)
	local face = frame.args
	local allowSelfLink = frame.args; allowSelfLink = not allowSelfLink or allowSelfLink == ""
	
	local params = {
		 = {required = true},
		 = {},
		 = {},
		 = {alias_of = "gloss"},
		 = {list = true},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {alias_of = "gloss"},
		 = {},
		 = {},
		 = {},
		 = { type = "boolean", default = false },
	}
	
	-- 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 compat = (frame.args or "") ~= ""
	
	if compat then
		params = {},
		table.remove(params, 1)
	end
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local lang = args
	
	-- Tracking for missing language or und
	if not lang then
		require("Module:debug").track("link/no lang")
	elseif lang == "und" then
		require("Module:debug").track("link/und")
	end
	
	lang = lang or "und"
	local sc = args
	
	local term = args
	local alt = args
	
	-- Check parameters
	lang = require("Module:languages").getByCode(lang, 1, "allow etym")
	local non_etym_lang = require("Module:languages").getFull(lang)
	
	if sc then
		sc = require("Module:scripts").getByCode(sc, "sc")
	end

	if not term and not alt and frame.args then
		term = frame.args
	end
	
	--[[
		Add a language name, linked to Wikipedia if the Wikipedia parameter is set to true.
		Forward the information to full_link.
	]]
	local language_name = args.w and lang:makeWikipediaLink() or lang:getCanonicalName()
	
	if term == "-" then
		return language_name
	else
		return language_name .. " " ..
			require("Module:User:Benwing2/links").full_link( 
				{
					lang = non_etym_lang, 
					sc = sc, 
					term = term, 
					alt = alt, 
					id = args, 
					tr = args, 
					ts = args, 
					genders = args, 
					gloss = args, 
					pos = args, 
					lit = args
				},
				face,
				allowSelfLink
			)
	end
end

function export.light_link_t(frame)
	local params = {
		 = { required = true },
		 = { required = true },
		 = {},
		 = {},
		 = { required = true },
	}
	
	local args = frame:getParent().args
	
	for key, value in pairs (params) do
		if value.required then
			if not args then
				error('Parameter "' .. key .. '" is required.')
			end
		end
	end
	
	return require("Module:User:Benwing2/links").light_link{  
		langCode = args, 
		term = args, 
		alt = args, 
		scCode = args.sc or "Latn",  
		langName = args.langname
	}
end

return export