Module:fi-dialects/helper

From Wiktionary, the free dictionary
Jump to navigation Jump to search

local export = {}

local function add_word(syns, parish, word)
	if not syns[parish] then
		syns[parish] = word
	elseif type(syns[parish]) == "string" then
		syns[parish] = { syns[parish], word }
	else
		table.insert(syns[parish], word)
	end
end

function export.add_word_for(syns, word, parishes)
	if type(parishes) == "string" then
		for parish in mw.text.gsplit(parishes, ",") do
			add_word(syns, mw.ustring.gsub(mw.text.trim(parish), "[ .]", ""), word)
		end
	else
		for _, parish in ipairs(parishes) do
			add_word(syns, parish, word)
		end
	end
end

return export