Jump to content

Module:fi:Dialects

Wiktionary වෙතින්


local labels, aliases = {}, {}
local m_data = mw.loadData("Module:fi-dialects/data/area")

labels['Western Finnish'] = {
	link = 'Finnish language#Western dialects',
	display = 'Western Finnish',
}
aliases['Western'] = 'Western Finnish'
aliases['Western Finland'] = 'Western Finnish'

labels['Eastern Finnish'] = {
	link = 'Finnish language#Eastern dialects',
	display = 'Eastern Finnish',
}
aliases['Eastern'] = 'Eastern Finnish'
aliases['Eastern Finland'] = 'Eastern Finnish'

local function visit(area_key, area)
	labels[area_key] = {
		link = area.Wikipedia,
		display = area.english
	}
	aliases[area.english] = area_key
	
	if area.subareas then
		for subarea_key, subarea in pairs(area.subareas) do
			visit(area_key .. "/" .. subarea_key, subarea)
		end
	end
end

for area_key, area in pairs(m_data.areas) do
	visit(area_key, area)
end

for alias_key, alias in pairs(m_data.area_aliases) do
	aliases[alias_key] = alias
end

local function northern_to_north_etc(key)
	local words = { "(North)ern", "(West)ern", "(South)ern", "(Southwest)ern", "(East)ern", "(Southeast)ern" }
	for _, word in ipairs(words) do
		key = mw.ustring.gsub(key, word .. " ", "%1 ")
		key = mw.ustring.gsub(key, word .. "$", "%1")
	end
	return key
end

local old_aliases = aliases
aliases = {}
for alias_key, alias in pairs(old_aliases) do
	aliases[alias_key] = alias
	if mw.ustring.find(alias_key, "ern ") then
		local alias_key2 = northern_to_north_etc(alias_key)
		if alias_key ~= alias_key2 then
			aliases[alias_key2] = alias
		end
	end
end

return {
	labels = labels,
	aliases = aliases,
}
"https://si.wiktionary.org/w/index.php?title=Module:fi:Dialects&oldid=55203" වෙතින් සම්ප්‍රවේශනය කෙරිණි