This page is "edit" protected. The "autoconfirmed" right is required to "edit" this page.<ul class='mw-logevent-loglines'> <li data-mw-logid="154789" data-mw-logaction="protect/protect" class="mw-logline-protect"> <a href="/index.php?title=Special:Log&amp;logid=154789" title="Special:Log">22:53, 20 December 2025</a> <a href="/User:Cobblestone" class="mw-userlink" title="User:Cobblestone"><bdi>Cobblestone</bdi></a> <span class="mw-usertoollinks mw-changeslist-links"><span><a href="/User_talk:Cobblestone" class="mw-usertoollinks-talk" title="User talk:Cobblestone">talk</a></span> <span><a href="/Special:Contributions/Cobblestone" class="mw-usertoollinks-contribs" title="Special:Contributions/Cobblestone">contribs</a></span></span> protected <a href="/Module:Trumpspeak" title="Module:Trumpspeak">Module:Trumpspeak</a> [Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite) <span class="comment">(Template)</span> <span class="mw-logevent-actionlink">(<a href="/index.php?title=Module:Trumpspeak&amp;action=history&amp;offset=20251220225336" title="Module:Trumpspeak">hist</a>)</span> </li> </ul></ul>
This page is "move" protected. The "autoconfirmed" right is required to "move" this page.<ul class='mw-logevent-loglines'> <li data-mw-logid="154789" data-mw-logaction="protect/protect" class="mw-logline-protect"> <a href="/index.php?title=Special:Log&amp;logid=154789" title="Special:Log">22:53, 20 December 2025</a> <a href="/User:Cobblestone" class="mw-userlink" title="User:Cobblestone"><bdi>Cobblestone</bdi></a> <span class="mw-usertoollinks mw-changeslist-links"><span><a href="/User_talk:Cobblestone" class="mw-usertoollinks-talk" title="User talk:Cobblestone">talk</a></span> <span><a href="/Special:Contributions/Cobblestone" class="mw-usertoollinks-contribs" title="Special:Contributions/Cobblestone">contribs</a></span></span> protected <a href="/Module:Trumpspeak" title="Module:Trumpspeak">Module:Trumpspeak</a> [Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite) <span class="comment">(Template)</span> <span class="mw-logevent-actionlink">(<a href="/index.php?title=Module:Trumpspeak&amp;action=history&amp;offset=20251220225336" title="Module:Trumpspeak">hist</a>)</span> </li> </ul></ul>

Module:Trumpspeak

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search

Please refer to Module:Readable

{ { #invoke:Trumpspeak|translate|yuor text is winnerer } }

shows


yvQr text is vvinnerer


local g = {}

local str_map = {
    {'M', 'ɅɅ'},
    {'O', 'Q'},
    {'U', 'V'},
    {'W', 'VV'},
    {'u', 'v'},
    {'o', 'Q'},
    {'w', 'vv'},
    {'m', 'ɅɅ'},
}

table.sort(str_map, function(a, b)
    return #a[1] > #b[1]  -- Sort by pattern length descending
end)

function g.translate(frame)
    local input = frame.args[1] or ''
    local result = {}
    
    -- Split the text while preserving content inside {} and []
    local pos = 1
    local length = mw.ustring.len(input)
    
    while pos <= length do
        -- Check if we're at the start of a protected block
        local char = mw.ustring.sub(input, pos, pos)
        
        if char == '{' then
            -- Find matching closing brace
            local bracket_count = 1
            local start_pos = pos
            pos = pos + 1
            
            while pos <= length and bracket_count > 0 do
                local next_char = mw.ustring.sub(input, pos, pos)
                if next_char == '{' then
                    bracket_count = bracket_count + 1
                elseif next_char == '}' then
                    bracket_count = bracket_count - 1
                end
                pos = pos + 1
            end
            
            -- Extract the protected block and add it unchanged
            local protected = mw.ustring.sub(input, start_pos, pos - 1)
            table.insert(result, protected)
            
        elseif char == '[' then
            -- Find matching closing bracket
            local bracket_count = 1
            local start_pos = pos
            pos = pos + 1
            
            while pos <= length and bracket_count > 0 do
                local next_char = mw.ustring.sub(input, pos, pos)
                if next_char == '[' then
                    bracket_count = bracket_count + 1
                elseif next_char == ']' then
                    bracket_count = bracket_count - 1
                end
                pos = pos + 1
            end
            
            -- Extract the protected block and add it unchanged
            local protected = mw.ustring.sub(input, start_pos, pos - 1)
            table.insert(result, protected)
            
        else
            -- Find regular text until next protected block
            local start_pos = pos
            
            while pos <= length do
                local next_char = mw.ustring.sub(input, pos, pos)
                if next_char == '{' or next_char == '[' then
                    break
                end
                pos = pos + 1
            end
            
            -- Extract and translate the regular text
            local text = mw.ustring.sub(input, start_pos, pos - 1)
            
            -- Apply translations to this text segment
            for _, pair in ipairs(str_map) do
                local pattern = pair[1]
                local replacement = pair[2]
                text = mw.ustring.gsub(text, pattern, replacement)
            end
            
            table.insert(result, text)
        end
    end
    
    return table.concat(result)
end

return g