Module:Translation

From Heroes of Might and Magic: Olden Era Official Wiki

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

-- This module is a backup solution to Template:Translation.
-- It should be used only when the {{Translation}} has a race-condition.
local p = {}
local UtilQuery = require('Module:UtilQuery')

-- Displays a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
    return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end

------------------------------------------------------------------------------------------------------------------------
function p.get(frame)
    local id = frame.args[1]
    local lang = frame.args[2]
    local results = UtilQuery.run([[
        tables =
            Translation = T
        | where =
            T.target_id = "%s"
            AND T.language = "%s"
        | fields =
            T.name = name
        | limit = 1
    ]], id, lang)
    local name = (results[1] or { name = id .. '💬' }).name
    return name
end

return p