Module:alternative forms/sandbox

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

This module is used to test changes to Module:alternative forms without messing up entries.

Testcases

ὑμεῖς (humeîs)
honor
  • honour (British, Commonwealth, Irish)
random
  • testity, test
  • (dʾl /⁠dār⁠/)

local export = {}
local m_link = require('Module:links')
local m_languages = require("Module:languages")
local m_debug = require("Module:debug")

-- See if the language's dialectal data module has a label corresponding to the dialect argument.
function export.getLabel(dialect, dialect_data)
	local data = dialect_data or ( dialect_data.labels and dialect_data.labels )
	local alias_of = ( dialect_data.aliases and dialect_data.aliases )
	if not data then
		if alias_of then
			data = dialect_data or ( dialect_data.labels and dialect_data.labels )
		end
	end
	if data then
		local display = data.display or dialect
		if data.appendix then
			dialect = ']'
		else
			local target = data.link
			dialect = target and ']' or display
		end
	end
	return dialect
end

local function make_dialects(raw, lang)
	local dialect_page = 'Module:'.. lang:getCode() ..':Dialects'
	local dialect_info = mw.title.new(dialect_page).exists and mw.loadData(dialect_page) or false
		
	local dialects = {}
	
	for _, dialect in ipairs(raw) do
		table.insert(dialects, dialect_info and export.getLabel(dialect, dialect_info) or dialect)
	end
	
	return dialects
end

local function track(args, arg, number)
	if args and args and args then
		m_debug.track("alter/" .. arg)
	end
end

local function maxindex_of_args(args, arg_keys)
	return math.max(unpack(require "Module:fun".map(
		function (arg)
			return args.maxindex
		end,
		arg_keys)))
end

local function any_arg_at_index(args, arg_keys, i)
	return require "Module:fun".some(
		function (arg)
			return args
		end,
		arg_keys)
end

function export.create(frame)
	local title = mw.title.getCurrentTitle()
	local NAMESPACE = title.nsText
	local PAGENAME = title.text
	
	local list_with_holes = { list = true, allow_holes = true }
	local params = {
		 = { required = true },
		 = list_with_holes,
		 = list_with_holes,
		 = list_with_holes,
		 = {},
		
		 = list_with_holes,
		 = list_with_holes,
		 = list_with_holes,
		 = list_with_holes,
		 = list_with_holes,
		 = { alias_of = "t" },
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local lang = ( args and m_languages.getByCode(args) ) or ( NAMESPACE == "Template" and m_languages.getByCode("und") ) or m_languages.err(args, 1)
	local sc = require("Module:scripts").getByCode(args)
	
	local rawDialects = {}
	local links = {}
	
	-- Alert! Adding t and pos will change behavior!
	local term_args = { 2, "alt", "id", "tr", "ts", "t", "pos" }
	local maxindex = maxindex_of_args(args, term_args)
	if maxindex == 0 then
		require("Module:debug").track("alter/maxindex is 0")
		-- error("Either a positional parameter, alt parameter, id parameter, tr parameter, or ts parameter is required.")
	end
	
	-- Is set to true if there is a term (entry link, alt text,
	-- transliteration, transcription) at the previous index.
	local prev = false
	local use_semicolon = false

	for i = 1, maxindex do
		-- If the previous parameter was empty and we're not on the first parameter,
		-- this parameter and any others contain dialect or other labels.
		if i > 1 and not prev then
			rawDialects = {unpack(args, i, maxindex)}
			break
		-- If any of the arguments used for formatting a term is present, create
		-- a term and add it to the list.
		-- Alert! Using term_args will change behavior!
		elseif any_arg_at_index(args, term_args, i) then
			track(args, "alt", i) -- ]
			track(args, "id", i) -- ]
			track(args, "tr", i) -- ]
			track(args, "ts", i) -- ]
			track(args, "t", i) -- ]
			track(args, "pos", i) -- ]
			track(args, "g", i) -- ]
			
			local term_text = args or args.alt
			if not use_semicolon and term_text then
				if term_text:find(",", 1, true) then
					use_semicolon = true
				end
			end
			
			if args and not args.alt then
				args.alt = args
				args = lang:makeEntryName(args)
			end
			if args == PAGENAME then -- Unlink if term is pagename.
				require "Module:debug".track("alter/term is pagename")
				args = nil
			end
			term = m_link.full_link{
				lang = lang,
				sc = sc,
				term = args,
				alt = args.alt,
				id = args.id,
				tr = args.tr,
				ts = args.ts,
				gloss = args.t,
				pos = args.pos,
				genders = args.g
			}
			table.insert(links, term)
			prev = true
		else
			if maxindex_of_args(args, { "alt", "id", "tr", "ts" }) >= i then
				require("Module:debug").track("alter/too few terms")
			end
			
			prev = false
		end
	end
	
	-- The template must have either links or dialect labels.
	if links == nil and rawDialects == nil then error("No terms found!") end

	local dialects  = make_dialects(rawDialects, lang)
	
	local output = { table.concat(links, use_semicolon and '; ' or ', ') }
	if #dialects > 0 then
		if lang:hasTranslit() then
			dialect_label = " – ''" .. table.concat(dialects, ", ") .. "''" 
		else
			dialect_label = " (''" .. table.concat(dialects, ", ") .. "'')"
		end
		
		-- Fixes the problem of '' being added to '' at the end of last dialect parameter
		dialect_label = mw.ustring.gsub(dialect_label, "''''", "")
		table.insert(output, dialect_label)
	end
	
	return table.concat(output)
end

function export.categorize(frame)
	local content = {}
	
	local title = mw.title.getCurrentTitle()
	local titletext = title.text
	local namespace = title.nsText
	local subpagename = title.subpageText
	
	-- subpagename ~= titletext if it is a documentation page
	if namespace == "Module" and subpagename == titletext then
		local langCode = mw.ustring.match(titletext, "^(+):")
		local lang = m_languages.getByCode(langCode) or error('"' .. langCode .. '" is not a valid language code.')
		content.canonicalName = lang:getCanonicalName()
		
		local categories =
[=[
]
]
]=]
		
		categories = mw.ustring.gsub(categories, "<(+)>", content)
		return categories
	end
end

return export