Module:tln-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Nehster9 (talk | contribs)
mNo edit summary
Nehster9 (talk | contribs)
m Undo revision 529967 by Nehster9 (talk)
Tag: Undo
Line 1: Line 1:
local export = {}
local p = {}
local pos_functions = {}


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


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


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


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


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


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


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


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


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


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


-- Entry point
return p
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:15, 18 June 2026



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 .. "'''"

        if plrom ~= "" then
            text = text .. " (" .. plrom .. ")"
        end
    end

    return text
end

return p