Springe nei ynhâld

Module:taalnamme

Ut Wikiwurdboek
De neikommende dokumintaasje stiet op Module:taalnamme/dokumintaasje. [bewurkje]

Generearet de tekst mei opmaak fan de taalkoade-berjochten, bgl. Berjocht:nl.


p = {}

function p.main(frame)
	local code = frame:getParent():getTitle():gsub("^[^:]*:", "")
	local terms = frame:getParent().args
	local text = ""
	
	local m_languages = require("Module:languages")
	local lang = m_languages.getByCode(code)
	
	if type(lang) ~= "nil" then
		if terms["html"] == "0" then
			if terms[1] then
				error('Termen opjûn, mar HTML is útskeakele.')
			else
				text = lang:getCanonicalName()
			end
		else
			text = '<span title="' .. code .. '">' .. lang:getCanonicalName() .. '</span>'
			
			if terms[1] then
				local template = "Berjocht:t"
				local script = terms["sc"] or ""
				local links = ""
				
				if frame.args["interwiki"] == "1" then
					template = "Berjocht:t+"
				end
				
				for k, v in ipairs(terms) do
					links = links .. ', ' ..
							frame:expandTemplate{ title = template, args = { code, v, sc = script, tr = "-" } }
				end
				
				text = text .. links:gsub("^,", ":")
			end
		end
	else
		local m_families = require("Module:families")
		local fam = m_families.getByCode(code)
		
		if type(fam) ~= "nil" then
			if terms[1] then
				error('De famyljekoade "' .. code .. '" kin gjin termen hawwe.')
			elseif terms["html"] == "0" then
				text = fam:getCanonicalName()
			else
				text = '<span title="' .. code .. '">' .. fam:getCanonicalName() .. '</span>'
			end
		else
			error('De taal- of famyljekoade "' .. code .. '" is net jildich.')
		end
	end
	
	return text
end

return p