Module:tln-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Nehster9 (talk | contribs)
mNo edit summary
Nehster9 (talk | contribs)
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


local function get_args(frame)
    return frame:getParent().args
end
local function format_rom(rom)
    if rom and rom ~= "" then
        return " • (" .. rom .. ")"
    end
    return ""
end
local function format_gender(g)
    local gender_map = {
        m = "m.",
        f = "f.",
        n = "n."
    }
    local label = gender_map[g] or (g and (g .. ".") or "?.")
    return " ''" .. label .. "''"
end
-- =========================
-- NOUN
-- =========================
function p.noun(frame)
function p.noun(frame)
     local args = frame:getParent().args
     local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text


     local title = mw.title.getCurrentTitle().text
     local rom = args.rom or ""
    local g = args.g or "?"
    local pl = args.pl or ""
    local plrom = args.plrom or ""


local g = args.g or "?"
    local text = "'''" .. title .. "'''"
local rom = args.rom or ""
    text = text .. format_rom(rom)
local pl = args.pl or ""
    text = text .. format_gender(g)
local plrom = args.plrom or ""


local gender_map = {
     if pl ~= "" then
     m = "m.",
        text = text .. ", plural '''[[" .. pl .. "]]'''"
    f = "f.",
    n = "n."
}


local text = "'''" .. title .. "'''"
        if plrom ~= "" then
            text = text .. " (" .. plrom .. ")"
        end
    end


if rom ~= "" then
     return text
     text = text .. " • (" .. rom .. ")"
end
end


text = text .. " ''" .. (gender_map[g] or (g .. ".")) .. "''"
-- =========================
-- VERB
-- =========================
function p.verb(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text
 
    local rom = args.rom or ""
    local past = args.past or ""
 
    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)


if pl ~= "" then
     text = text .. " ''v.''"
     text = text .. " plural '''[[" .. pl .. "]]'''"


     if plrom ~= "" then
     if past ~= "" then
         text = text .. " (" .. plrom .. ")"
         text = text .. ", past '''" .. past .. "'''"
     end
     end
    return text
end
end
-- =========================
-- ADJECTIVE (basic placeholder)
-- =========================
function p.adj(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text
    local rom = args.rom or ""
    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)
    text = text .. " ''adj.''"


     return text
     return text

Revision as of 19:38, 18 June 2026



local p = {}

local function get_args(frame)
    return frame:getParent().args
end

local function format_rom(rom)
    if rom and rom ~= "" then
        return " • (" .. rom .. ")"
    end
    return ""
end

local function format_gender(g)
    local gender_map = {
        m = "m.",
        f = "f.",
        n = "n."
    }

    local label = gender_map[g] or (g and (g .. ".") or "?.")

    return " ''" .. label .. "''"
end

-- =========================
-- NOUN
-- =========================
function p.noun(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""
    local g = args.g or "?"
    local pl = args.pl or ""
    local plrom = args.plrom or ""

    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)
    text = text .. format_gender(g)

    if pl ~= "" then
        text = text .. ", plural '''[[" .. pl .. "]]'''"

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

    return text
end

-- =========================
-- VERB
-- =========================
function p.verb(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""
    local past = args.past or ""

    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)

    text = text .. " ''v.''"

    if past ~= "" then
        text = text .. ", past '''" .. past .. "'''"
    end

    return text
end

-- =========================
-- ADJECTIVE (basic placeholder)
-- =========================
function p.adj(frame)
    local args = get_args(frame)
    local title = mw.title.getCurrentTitle().text

    local rom = args.rom or ""

    local text = "'''" .. title .. "'''"
    text = text .. format_rom(rom)
    text = text .. " ''adj.''"

    return text
end

return p