Module:IPA/templates/sandbox

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local m_IPA = require("Module:IPA")

local U = mw.ustring.char
local syllabic = U(0x0329)


local tracking = {
	en = {
		{
			symb = "iə",
			cat = "ambig",
		},
		{
			symb = { "ɪi", "ʊu", "ɪj", "ʊw" },
			cat = "eeoo",
		},
	},
	cs = {
		{
			symb = "",
			cat = "syllabic-consonant",
		},
	},
	ps = {
		{
			symb = "ɤ",
			cat = "Pashto",
		},
	},
	fa = {
		{
			symb = "ʔ",
			cat = "glottal-stop",
		},
	},
	{
		{
			symb = "",
			cat = "",
		},
	},
}

local function run_tracking(IPA, lang)
	lang = lang:getCode()
	
	for i, arguments in ipairs(tracking) do
		mw.log("found tracking parameters")
		if type(arguments) == "table" then
			local required = { "symb", "cat" }
			
			hasArgs = true
			
			for i, arg in pairs(required) do
				if not arguments or arguments == "" then
					hasArgs = false
				end
			end
			
			if hasArgs == true then
				local symbols = arguments.symb
				local category = arguments.cat
				
				if type(symbols) == "string" then
					symbols = { symbols }
				end
				
				for _, symbol in pairs(symbols) do
					if mw.ustring.find(IPA, symbol) then
						require("Module:debug").track("IPA/" .. lang .. "/" .. category)
					end
				end
			end
		end
	end
end

-- Used for ].
function export.IPA(frame)
	local params = {
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {required = false, default = ""},
	}
	
	local err = nil
	local args = require("Module:parameters").process(frame.getParent and frame:getParent().args or frame, params)
	local lang = mw.title.getCurrentTitle().nsText == "Template" and "en" or args
	lang = require("Module:languages").getByCode(lang)
	
	if not lang then
		if args == "" then
			err = "No language code specified.]"
		else
			err = "The language code '" .. args .. "' is not valid.]"
		end
	end
	
	-- Temporary test to see which Finnish entries use {{IPA}} rather than {{fi-IPA}}
	if lang and (lang:getCode() == "ca" or lang:getCode() == "fi") then
		require("Module:debug").track("IPA/" .. lang:getCode())
	end
	
	local items = {}
	
	for i = 1, math.max(args.maxindex, args.maxindex) do
		local pron = args
		local note = args
		local qual = args
		
		run_tracking(pron, lang)
		
		if pron or note or qual then
			table.insert(items, {pron = pron, note = note, qualifiers = {qual}})
		end
	end
	
	return m_IPA.format_IPA_full { lang = lang, items = items, err = err }
end

-- Used for ].
function export.IPAchar(frame)
	local params = {
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true},
		 = {}, -- This parameter is not used and does nothing, but is allowed for futureproofing.
	}
	
	local args = require("Module:parameters").process(frame.getParent and frame:getParent().args or frame, params)
	
	local items = {}
	
	for i = 1, math.max(args.maxindex, args.maxindex) do
		local pron = args
		local note = args
		
		if pron or note then
			table.insert(items, {pron = pron, note = note})
		end
	end
	
	-- Format
	return m_IPA.format_IPA_multiple(nil, items)
end

function export.XSAMPA(frame)
	local params = {
		 = { required = true },
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	return m_IPA.XSAMPA_to_IPA(args or "")
end

-- Used by ]
function export.X2IPAtemplate(frame)
	local params = {
		 = { list = true, allow_holes = true },
		 = { list = true, allow_holes = true },
		 = { list = true, allow_holes = true },
		 = { required = true },
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	pronunciations, notes, qualifiers, lang = args, args, args, args
	
	local output = {}
	table.insert(output, "{{IPA")
	
	for i = 1, math.max(pronunciations.maxindex, notes.maxindex, qualifiers.maxindex) do
		if pronunciations then
			table.insert(output, "|"..m_IPA.XSAMPA_to_IPA(pronunciations))
		end
		if notes then
			table.insert(output, "|n"..i.."="..notes)
		end
		if qualifiers then
			table.insert(output, "|qual"..i.."="..qualifiers)
		end
	end
	
	if lang then
		table.insert(output, "|lang="..lang.."}}")
	end
	
	return table.concat(output)
end

-- Used by ]
function export.X2IPAchar(frame)
	local params = {
		 = { list = true, allow_holes = true },
		 = { list = true, allow_holes = true },
		 = { },
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	pronunciations, notes, lang = args, args, args
	
	local output = {}
	table.insert(output, "{{IPAchar")
	
	for i = 1, math.max(pronunciations.maxindex, notes.maxindex) do
		if pronunciations then
			table.insert(output, "|"..m_IPA.XSAMPA_to_IPA(pronunciations))
		end
		if notes then
			table.insert(output, "|n"..i.."="..notes)
		end
	end
	
	if lang then
		table.insert(output, "|lang="..lang)
	end
	
	table.insert(output, "}}")
	
	return table.concat(output)
end

-- Used by ]
function export.X2rhymes(frame)
	local params = {
		 = { required = true, list = true, allow_holes = true },
		 = { required = true },
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	pronunciations, lang = args, args
	
	local output =  {}
	table.insert(output, "{{rhymes")
	
	for i = 1, pronunciations.maxindex do
		if pronunciations then
			table.insert(output, "|"..m_IPA.XSAMPA_to_IPA(pronunciations))
		end
	end
	
	if lang then
		table.insert(output, "|lang="..lang)
	end
	
	table.insert(output, "}}")
	
	return table.concat(output)
end

return export