Module:Lang: Difference between revisions

Jump to navigation Jump to search
Changed the logic of looking up text display. Now it searches the Data:Dictionary first and return to the KEYBIND section if result is not found in the Dictionary
removed duplicate code
Line 211: Line 211:
        -- strip bold markup before dictionary lookup
        -- strip bold markup before dictionary lookup
        local raw = replacement:gsub("^'''", ""):gsub("'''$", "")
        local translated = dictionary_module.translate(raw, lang_code)
        if translated ~= nil and translated ~= '' then
            return "'''" .. translated .. "'''"
        else
            return replacement
        end
    else
        return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing keybind - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>'
    end
end)
text = text:gsub("{g:citadel_keybind:'(.-)'}", function(key)
    local replacement = KEYBINDS[key]
    if replacement then
        local lang_code = p.get_lang_code()
        local raw = replacement:gsub("^'''", ""):gsub("'''$", "")
        local raw = replacement:gsub("^'''", ""):gsub("'''$", "")