Module:mg-spel: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 36: Line 36:
c = c:gsub("x", "is")
c = c:gsub("x", "is")
local list = {e, a, c, s}
local list = {e, a, s}
for i = 1, 4 do
for i = 1, 3 do
for j = 1, 4 do
for j = 1, 3 do
if list[i] == list[j] then
if list[i] == list[j] then
table.insert(qs, abbr[i])
table.insert(qs, abbr[i])

Revision as of 21:47, 23 August 2021


Implements {{mg-mut}} and {{mg-alter}}.
local PAGENAME = mw.title.getCurrentTitle().text
local gsub = mw.ustring.gsub

local lang = require("Module:languages").getByCode("cel-gal")
local m_l = require('Module:links')
local m_q = require('Module:qualifier')

local abbr = {"Spanish", "Asturian", "Celtic", "Southern"}

local export = {}

function export.alter(frame)
	local ret = {}; local qs = {}
	local term = frame:getParent().args[1] or PAGENAME
	
	local e = term; local a = term; local c = term; local s = term
	
	-- Spanish
	e = e:gsub("il", "ll")
	e = e:gsub("v", "b")
	e = e:gsub("[gh]", "j")
	
	-- Asturian	  
	a = a:gsub("il", "ll")
	a = a:gsub("v", "b")
	
	-- Southern
	s = s:gsub("ñ", "nh")
	s = s:gsub("il", "lh")
	s = s:gsub("v", "b")
	
	-- Celtic
	c = c:gsub("c([aou])", "k%1")
	c = c:gsub("qu([ei])", "k%1")
	c = c:gsub("ñ", "in")
	c = c:gsub("x", "is")
	
	local list = {e, a, s}
	
	for i = 1, 3 do
		for j = 1, 3 do
			if list[i] == list[j] then
				table.insert(qs, abbr[i])
			end
		end
		if list[i] ~= term then
			table.insert(ret, "* " .. m_l.full_link({term = list[i], lang = lang}) .. " " .. m_q.format_qualifier(qs or {abbr[i]}) .. "\n")
		end
	end
	
	if e == term and a == term and c == term and s == term then
		error('Delete me')
	end
	
	return table.concat(ret)
end


return export