Module:tln-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Nehster9 (talk | contribs)
Created page with "local p = {} function p.noun(frame) local args = frame:getParent().args local title = mw.title.getCurrentTitle().text local g = args.g or "?" local rom = args.rom or "" local pl = args.pl or "" local plrom = args.plrom or "" local text = "'''" .. title .. "'''" if rom ~= "" then text = text .. " • (" .. rom .. ")" end text = text .. " " .. g if pl ~= "" then text = text .. ", plural '''" .. pl .. "'''"..."
 
Nehster9 (talk | contribs)
mNo edit summary
Line 1: Line 1:
local p = {}
local export = {}
local pos_functions = {}


function p.noun(frame)
local lang = require("Module:languages").getByCode("tln")
    local args = frame:getParent().args


    local title = mw.title.getCurrentTitle().text
local PAGENAME = mw.title.getCurrentTitle().text


    local g = args.g or "?"
-- Nouns
    local rom = args.rom or ""
pos_functions.nouns = function(class, args, data)
local params = {
[1] = {required = true}, -- gender
["pl"] = {},
["head"] = {},
["tr"] = {},
["pltr"] = {},
}


    local pl = args.pl or ""
local args = require("Module:parameters").process(args, params)
    local plrom = args.plrom or ""


    local text = "'''" .. title .. "'''"
local head = args.head or PAGENAME


    if rom ~= "" then
data.lang = lang
        text = text .. " • (" .. rom .. ")"
data.heads = {head}
    end
data.genders = {args[1]}
data.inflections = {}


    text = text .. " " .. g
-- plural handling
if args.pl then
local infl = {
label = "plural",
{ term = args.pl }
}


    if pl ~= "" then
if args.pltr then
        text = text .. ", plural '''" .. pl .. "'''"
infl[1].tr = args.pltr
end


        if plrom ~= "" then
table.insert(data.inflections, infl)
            text = text .. " (" .. plrom .. ")"
end
        end
    end


    return text
if args.tr then
data.translits = {args.tr}
end
end
end


return p
-- Entry point
function export.show(frame)
local parent_args = frame:getParent().args
 
local poscat = frame.args[1] or "nouns"
 
local data = {
inflections = {},
genders = {},
categories = {},
}
 
if pos_functions[poscat] then
pos_functions[poscat](nil, parent_args, data)
end
 
return require("Module:headword").full_headword(data)
end
 
return export

Revision as of 19:11, 18 June 2026



local export = {}
local pos_functions = {}

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

local PAGENAME = mw.title.getCurrentTitle().text

-- Nouns
pos_functions.nouns = function(class, args, data)
	local params = {
		[1] = {required = true}, -- gender
		["pl"] = {},
		["head"] = {},
		["tr"] = {},
		["pltr"] = {},
	}

	local args = require("Module:parameters").process(args, params)

	local head = args.head or PAGENAME

	data.lang = lang
	data.heads = {head}
	data.genders = {args[1]}
	data.inflections = {}

	-- plural handling
	if args.pl then
		local infl = {
			label = "plural",
			{ term = args.pl }
		}

		if args.pltr then
			infl[1].tr = args.pltr
		end

		table.insert(data.inflections, infl)
	end

	if args.tr then
		data.translits = {args.tr}
	end
end

-- Entry point
function export.show(frame)
	local parent_args = frame:getParent().args

	local poscat = frame.args[1] or "nouns"

	local data = {
		inflections = {},
		genders = {},
		categories = {},
	}

	if pos_functions[poscat] then
		pos_functions[poscat](nil, parent_args, data)
	end

	return require("Module:headword").full_headword(data)
end

return export