Module:fo-noun/table

Hello, you have come here looking for the meaning of the word Module:fo-noun/table. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:fo-noun/table, but we will also tell you about its etymology, its characteristics and you will know how to say Module:fo-noun/table in singular and plural. Everything you need to know about the word Module:fo-noun/table you have here. The definition of the word Module:fo-noun/table will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:fo-noun/table, 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 m_links = require("Module:links")
local m_utils = require("Module:utilities")

local lang = require("Module:languages").getByCode("fo")

local export = {}

local function make_headers(data, wikicode)
	if data.defective ~= "p" then
		table.insert(wikicode, '! class="outer" colspan=')
		table.insert(wikicode, data.defective:find("def") and "1" or "2")
		table.insert(wikicode, " | singular\n")
	end
	if not data.defective:find("s") then
		table.insert(wikicode, '! class="outer" colspan=2 | plural\n')
	end
	table.insert(wikicode, '|-\n')
	--Singular
	if data.defective ~= "s_def" and data.defective ~= "p" then
		table.insert(wikicode, '! indefinite\n')
	end
	if data.defective ~= "s_indef" and data.defective ~= "p" then
		table.insert(wikicode, '! definite\n')
	end
	--Plural
	if not data.defective:find("s") then
		table.insert(wikicode, '! indefinite\n! definite\n')
	end
end

local function show_form(form, tag)
	if not form then
		return "—"
	end
	
	local ret = {}
	
	for key, subform in ipairs(form) do
		table.insert(ret, m_links.full_link({lang = lang, term = subform, accel = {form = tag}}))
	end
	
	return table.concat(ret, ", ")
end

local function make_case(data, wikicode, case)
	local case_short = case:sub(1, 3)
	table.insert(wikicode, '|- \n')
	table.insert(wikicode, =] .. case .. =] .. case .. "]]\n")
	if data.defective ~= "s_def" and data.defective ~= "p" then
		table.insert(wikicode, ] .. show_form(data.forms, case_short .. '|s|indef') .. "\n")
	end
	if data.defective ~= "s_indef" and data.defective ~= "p" then
		table.insert(wikicode, ] .. show_form(data.forms, case_short .. '|s|def') .. "\n")
	end
	if not data.defective:find("s") then
		table.insert(wikicode, ] .. show_form(data.forms, case_short .. '|p|indef') .. "\n")
		table.insert(wikicode, ] .. show_form(data.forms, case_short .. '|p|def') .. "\n")
	end
end

function export.make_table(data)
	
	local colspan = {s_indef = "2", s_def = "2", s = "3", p = "3", no = "5"}
	
	local wikicode = {
		mw.getCurrentFrame():expandTemplate{ 
			title = 'inflection-table-top', 
			args = {
				title = '-',
				palette = 'magenta'
			}
		}
	}
	table.insert(wikicode, '! rowspan="2" style="font-weight:normal" | ' .. data.decl_type .. "\n")
	
	make_headers(data, wikicode)
	make_case(data, wikicode, "nominative")
	make_case(data, wikicode, "accusative")
	make_case(data, wikicode, "dative")
	make_case(data, wikicode, "genitive") 
	
	table.insert(wikicode, mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' })
	
	return table.concat(wikicode)
end

return export