Module:Lang: Difference between revisions

m Fixed missing afterburn base duration label
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
Line 208: Line 208:
    local replacement = KEYBINDS[key]
    local replacement = KEYBINDS[key]
    if replacement then
    if replacement then
        return replacement
        local lang_code = p.get_lang_code()
        -- 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
    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>'
        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>'
Line 215: Line 226:
text = text:gsub("{g:citadel_keybind:'(.-)'}", function(key)
text = text:gsub("{g:citadel_keybind:'(.-)'}", function(key)
local replacement = KEYBINDS[key]
    local replacement = KEYBINDS[key]
    if replacement then
    if replacement then
        return replacement
        local lang_code = p.get_lang_code()
        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
    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>'
        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>'