Jump to content

Module:TableTranslation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gommeh (talk | contribs) at 15:18, 11 May 2025 (Created page with 'local p = {} function p.render(frame) local args = frame.args -- used if calling directly with #invoke local lang1 = args[1] local lang2 = args[2] if not lang1 or not lang2 then return "Error: Two language names must be provided." end local output = {} table.insert(output, "== Translations ==") -- Start processing from arg #3 for i = 3, #args, 2 do local text = args[i] local translation = args...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.render(frame)
    local args = frame.args  -- used if calling directly with #invoke
    local lang1 = args[1]
    local lang2 = args[2]

    if not lang1 or not lang2 then
        return "Error: Two language names must be provided."
    end

    local output = {}
    table.insert(output, "== Translations ==")

    -- Start processing from arg #3
    for i = 3, #args, 2 do
        local text = args[i]
        local translation = args[i + 1]
        if text and translation then
            table.insert(output, string.format("'''%s''': %s → '''%s''': %s", lang1, text, lang2, translation))
        end
    end

    return table.concat(output, "<br>")
end

return p