I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
-- This module is used for section titles
local p = {}
local builder = require("Module:Builder")
local languages = require("Module:Lingaedje")
local titles = mw.loadData("Module:Hagnon/data")

function p.is_alias(title)
    if titles['alias'][title] then
        return true
    else
        return false
    end
end

function p.is_title(title)
    if p.is_alias(title) or titles['text'][title] ~= nil then
        return true
    else
        return false
    end
end

-- return the name of a section
function p.get_title(frame)
	args = frame.args
	builder.init(frame, 'Årtikes avou ene flotche dins l\' modele hagnon')
	
	if not args.title or args.title == "" then
		builder.error("el tite est vude")
	end
	
	local langObj = mw.language.new("wa")
	local title = mw.ustring.lower( args.title )
	      title = mw.ustring.gsub( title, "’[  ]", "' " )
	local help_link = ' <sup>[[Aidance:Hagnons|(?)]]</sup>'
	local lang_code = nil
	local unknown_title = false
	local id_title = ""
	local id_title2 = ""
	local cat = nil
	
	if p.is_title(title) then
		if p.is_alias(title) then
			title = titles['alias'][title]
		elseif titles['text'][title] ~= nil then
			title = titles['text'][title]
		end
		if title["category"] ~= nil then
			cat = title["category"]
		end
	else
		unknown_title = true
		builder.add_category('Årtikes avou on tite nén rkinoxhou')
	end
	
	if args.lang ~=nil then
		lang_code = args.lang
		local lang = languages.get_name(lang_code)
		if lang ~=nil then
			id_title = langObj:ucfirst(lang)

			if title.name ~=nil then
				-- compatibility with old links
				if title.name == "etimolodjeye" and string.match(lang_code, "-fel") then
					id_title2 = id_title .. "-Fel"
				end
				
				-- special case
				if string.match(lang_code, "-fel") then
					id_title = id_title .. "-Feller"
				end
				if string.match(lang_code, "-vsis") then
					id_title = id_title .. " (vîs sistinmes)"
				end
				-- special alias
				if title.name == "codjowas" then
					id_title2 = id_title ..' '.. langObj:ucfirst("codjowa")
				end
				
				if title.name ~= "etimolodjeye" then
					id_title = id_title ..' '.. langObj:ucfirst(title.name)
				end
				
				if title.level ~= 3 or (not cat and title.level == 3 and title.name ~= "etimolodjeye") then 
					builder.add_category("Årtikes avou on lingaedje dins on tite sins lingaedje")
				end
			else
				id_title = id_title ..' '.. langObj:ucfirst(title)
			end
		end
	end
	
	if title.name ~= nil then
		title = title.name
	end
	
	if args.number ~=nil and tonumber(args.number) then
		id_title = id_title ..' '.. args.number
		if id_title2 ~= ""
		then
			id_title2 = id_title2 ..' '.. args.number
		end
		title = title .. " " .. args.number
	end
	
	title = langObj:ucfirst(title)
	
	if cat ~=nil then
		local cat_start = cat[1]
		local cat_end, vow = ""
		if cat[2] ~= nil then cat_end = cat[2] end
		if cat.vow ~= nil and cat.vow then vow = "1" end
		if cat.fem ~= nil and cat.fem then fem = "1" end
		builder.add_category( languages.grammar({args={cat_start, lang_code, cat_end, vowel=vow, fem=fem}}) )
	end
	
	if unknown_title then
		title = title .. help_link
	end

	title = '<span id="'.. id_title:gsub(" ", "_") ..'">'.. title ..'</span>'
	if id_title2 ~= ""
	then
		title = '<span id="'.. id_title2:gsub(" ", "_") ..'">'.. title ..'</span>'
	end
	builder.add_content(title)
	
	return builder.get_content()
end

return p