[go: up one dir, main page]

Gaan na inhoud

Module:hyphenation

Vanuit Wiktionary, die vrye woordeboek.

Dokumentasie vir hierdie module kan geskep word by: Module:hyphenation/doc

local export = {}

local categorise_syllables = {
	["es"] = true,
	["fr"] = true,
	["it"] = true,
	["pt"] = true,
}

function export.hyphenation(frame)
	local params = {
		[1] = {list = true, required = true, default = "{{{1}}}"},
		
		["caption"] = {},
		["lang"] = {required = false, default = "af"},
		["nocaption"] = {type = "boolean"},
		["sc"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local lang = require("Module:languages").getByCode(args["lang"]) or error("The language code \"" .. args["lang"] .. "\" is not valid.")
	local sc = args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. sc .. "\" is not valid.")) or nil
	
	local text = require("Module:links").full_link({lang = lang, sc = sc, alt = table.concat(args[1], "‧"), tr = "-"})
	local category = ""
	
	if categorise_syllables[lang:getCode()] then
		category = require("Module:utilities").format_categories({lang:getCanonicalName() .. " " .. tostring(#args[1]) .. "-syllable words"}, lang)
	end
	
	return (args["nocaption"] and "" or (args["caption"] or "Woordafbreking") .. ": ") .. text .. category
end

return export