From Afropedia.world
Revision as of 17:03, 19 January 2026 by Djehuti (talk | contribs) (Created page with "-- Module:Transl -- Provides transliteration functionality for MediaWiki templates local p = {} function p.transl(frame) local args = frame.args local parent_args = frame:getParent().args -- Get parameters from either direct call or template call local lang = args[1] or parent_args[1] or '' local system = args[2] or parent_args[2] or args['system'] or parent_args['system'] or '' local text = args[3] or parent_args[3] or args['text'] or pare...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

-- Module:Transl
-- Provides transliteration functionality for MediaWiki templates

local p = {}

function p.transl(frame)
    local args = frame.args
    local parent_args = frame:getParent().args
    
    -- Get parameters from either direct call or template call
    local lang = args[1] or parent_args[1] or ''
    local system = args[2] or parent_args[2] or args['system'] or parent_args['system'] or ''
    local text = args[3] or parent_args[3] or args['text'] or parent_args['text'] or ''
    
    -- Handle positional parameters
    if text == '' and system ~= '' then
        -- If only 2 params, second is the text
        if args[3] == nil and parent_args[3] == nil then
            text = system
            system = ''
        end
    end
    
    -- Build the output
    local result = ''
    
    if text ~= '' then
        -- Add language code if provided
        if lang ~= '' then
            result = '<span class="transl" lang="' .. lang .. '"'
            if system ~= '' then
                result = result .. ' title="' .. system .. ' transliteration"'
            end
            result = result .. '>' .. text .. '</span>'
        else
            result = '<span class="transl">' .. text .. '</span>'
        end
    end
    
    return result
end

-- Alias for compatibility
p.main = p.transl

return p