Module:Sitelen

Documentation for this module may be created at Module:Sitelen/doc

Documentation for this module may be created at Module:Sitelen/doc

local p = {}

-- ============================
-- SITELEN KALAMA INVENTORY
-- ============================
local sitelen_kalama = {
    ka=true, kan=true, ke=true, ken=true, ki=true, kin=true,
    ko=true, kon=true, ku=true, kun=true,
    la=true, lan=true, le=true, len=true, li=true, lin=true,
    lo=true, lon=true, lu=true, lun=true,
    ma=true, man=true, me=true, men=true, mi=true, min=true,
    mo=true, mon=true, mu=true, mun=true,
    na=true, nan=true, ne=true, nen=true, ni=true, nin=true,
    no=true, non=true, nu=true, nun=true,
    pa=true, pan=true, pe=true, pen=true, pi=true, pin=true,
    po=true, pon=true, pu=true, pun=true,
    sa=true, san=true, se=true, sen=true, si=true, sin=true,
    so=true, son=true, su=true, sun=true,
    ta=true, tan=true, te=true, ten=true, ti=true, tin=true,
    to=true, ton=true, tu=true, tun=true,
    wa=true, wan=true, we=true, wen=true, wi=true, win=true,
    wo=true, won=true, wu=true, wun=true,
    xa=true, xan=true, xe=true, xen=true, xi=true, xin=true,
    xo=true, xon=true, xu=true, xun=true,
    ya=true, yan=true, ye=true, yen=true, yi=true, yin=true,
    yo=true, yon=true, yu=true, yun=true,
}

-- ============================
-- BOOLEAN HELPERS
-- ============================
local function isFalse(v)
    if not v then return false end
    v = mw.ustring.lower(v)
    return (v == "false" or v == "0" or v == "no" or v == "off")
end

local function isTrue(v)
    if not v then return false end
    v = mw.ustring.lower(v)
    return (v == "true" or v == "1" or v == "yes" or v == "on")
end

-- ============================
-- KALAMA NORMALIZER
-- ============================
-- x- prefix indicates no onset consonant (A → xa, AN → xan, etc)
local function kalama_key_for(lower)
    if sitelen_kalama[lower] then
        return lower
    end

    if lower:match("^[aeiou]") then
        local with_x = "x" .. lower
        if sitelen_kalama[with_x] then
            return with_x
        end
    end

    return nil
end

-- ============================
-- FILENAME SELECTOR
-- ============================
local function filename_for(word, usePona)
    -- ALL CAPS = sitelen pona sound symbol
    if word:match("^%u+$") then
        local lower = mw.ustring.lower(word)
        local key = kalama_key_for(lower) or lower
        return "File:Sitelen kalama pona - " .. key .. ".svg"
    end

    local lower = mw.ustring.lower(word)

    -- Sitelen sitelen word symbols
    if not usePona then
        local cap = lower:sub(1,1):upper() .. lower:sub(2)
        return "File:" .. cap .. " - sitelen sitelen word symbol.svg"
    end

    -- Sitelen pona (seli-kiwen set)
    return "File:Sitelen-seli-kiwen-" .. lower .. ".svg"
end

-- ============================
-- MAIN
-- ============================
function p.main(frame)
    local invokeArgs = frame.args
    local parent = frame:getParent()
    local tplArgs = parent and parent.args or {}

    local ponaParam   = invokeArgs.pona   or tplArgs.pona
    local inlineParam = invokeArgs.inline or tplArgs.inline

    local usePona = not isFalse(ponaParam)
    local inline  = isTrue(inlineParam)

    -- gather positional args
    local words = {}
    local i = 1
    while invokeArgs[i] ~= nil do
        local v = invokeArgs[i]
        if v ~= nil and v ~= "" then
            table.insert(words, v)
        end
        i = i + 1
    end

    local files = {}
    for _, w in ipairs(words) do
        table.insert(files, filename_for(w, usePona))
    end

    -- INLINE MODE
    if inline then
        local out = {}
        for _, fn in ipairs(files) do
            table.insert(out,
                string.format('[[%s|25x25px|class=skin-invert-image]]', fn)
            )
        end
        return table.concat(out, " ")
    end

    -- GALLERY MODE
    local gallery = {}
    for _, fn in ipairs(files) do
        table.insert(gallery, fn .. '|class=skin-invert-image')
    end

    return '<gallery widths="30" heights="30">\n'
        .. table.concat(gallery, "\n")
        .. '\n</gallery>'
end

return p


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.