Module:nn-noun-common-irreg

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

local export = {}

local lang = require("Module:languages").getByCode("nn")
 
function export.main(frame)
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	local length = mw.ustring.len(PAGENAME)
	
	local t5 = mw.ustring.sub(PAGENAME, length-4, length)
	local t4 = mw.ustring.sub(PAGENAME, length-3, length)
	local t3 = mw.ustring.sub(PAGENAME, length-2, length)
	local t2 = mw.ustring.sub(PAGENAME, length-1, length)
			 
	if t4 ~= 'mann' then
		return "<span style=\"color:Red\">'''The noun ''" .. PAGENAME .. "'' is not supported by this template.'''</span> Use {{[[Template:nn-noun-irreg|nn-noun-irreg]]|<gender>|<definite singular>|etc.}} instead" 
	end
	
	local data = {lang = lang, pos_category = "nouns", categories = {}, genders = {"m"}}
	
	local p1 = mw.ustring.sub(PAGENAME, 1, length-4)
	definite_singular = p1 .. 'mannen'
	indefinite_plural = p1 .. 'menn'
	definite_plural = p1 .. 'mennene'		
	
	data.inflections = {
		{label = 'definite singular', definite_singular},
		{label ='indefinite plural', indefinite_plural}, 
		{label = 'definite plural', definite_plural} }
	
	return require("Module:headword").full_headword(data)
end

return export