Module:pollasena-roots: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 34: Line 34:


local links = {}; local categories = {}
local links = {}; local categories = {}
local term = ""
-- WIP
-- WIP
for i, item in ipairs(args[a]) do
for i, item in ipairs(args[a]) do
if item == " " or item == "-" then
if item == "-" then
table.insert(links, item)
table.insert(links, item)
elseif item == nil then
table.insert(links, " ")
elseif item:find("<") and not item:find("^[^<]*<[a-z]*[^a-z:]") then
elseif item:find("<") and not item:find("^[^<]*<[a-z]*[^a-z:]") then
local run = m_put.parse_balanced_segment_run(item, "<", ">")
local run = m_put.parse_balanced_segment_run(item, "<", ">")
Line 45: Line 46:
error(msg .. ": " .. orig_param .. "= " .. table.concat(run))
error(msg .. ": " .. orig_param .. "= " .. table.concat(run))
end
end
term = run[1]
local term = run[1]


for j = 2, #run - 1, 2 do
for j = 2, #run - 1, 2 do

Revision as of 17:07, 3 May 2023


This module implemented inherited templates for Pollasena languages: {{qsc-inh}}, {{gwax-wasc}}. It was generalized to also include other non-Pollasena languages: {{guim-inh}}.
local m_put = require("Module:parse utilities")
local m_table = require("Module:table")

local gsub = mw.ustring.gsub
local PAGENAME = gsub(mw.title.getCurrentTitle().text, "%s", "&nbsp;")
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch

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

local export = {}

local function ncategories(categories)
	local out_categories = {}
	for key, cat in ipairs(categories) do
		out_categories[key] = "[[Category:" .. cat .. "]]"
	end

	return table.concat(out_categories, "")
end

local function link(term,alt)
	return "[[Contionary:*" .. term .. "|*" .. (alt or term) .. "]]"	
end

function export.getLink(frame)
	local a = 2
	local params = {
		[1] = {},
		[a] = {list = true}, -- Wascotl
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)

	local links = {}; local categories = {}
	-- WIP
	for i, item in ipairs(args[a]) do
		if item == "-" then
			table.insert(links, item)
		elseif item == nil then
			table.insert(links, " ")
		elseif item:find("<") and not item:find("^[^<]*<[a-z]*[^a-z:]") then
			local run = m_put.parse_balanced_segment_run(item, "<", ">")
			local orig_param = a + i - 1
			local function parse_err(msg)
				error(msg .. ": " .. orig_param .. "= " .. table.concat(run))
			end
			local term = run[1]

			for j = 2, #run - 1, 2 do
				local modtext = run[j]:match("^<(.*)>$")
				local prefix, arg = modtext:match("^([a-z]+):(.*)$")
				
				if item:match("><") then
					if prefix == "a" then
						table.insert(links, link(term, arg))
					elseif prefix == "c" then
						table.insert(categories, "Soc'ul' terms from Wascotl *" .. arg)
					end
				elseif prefix == "a" then
					table.insert(links, link(term, arg))
					table.insert(categories, "Soc'ul' terms from Wascotl *" .. term)
				elseif prefix == "c" then
					table.insert(links, link(term))
					table.insert(categories, "Soc'ul' terms from Wascotl *" .. arg)
				end
			end
		else
			table.insert(links, link(args[a][i]))
			table.insert(categories, "Soc'ul' terms from Wascotl *" .. args[a][i])
		end
	end
	
	return table.concat(links) .. ncategories(categories)
end


return export