Module:Lang: Difference between revisions

added processing of InlineAttributeName and InlineAttributeIcon
No edit summary
 
(28 intermediate revisions by 7 users not shown)
Line 7: Line 7:
-- the expected key does not have a localization entry
-- the expected key does not have a localization entry
local KEY_OVERRIDES = {
local KEY_OVERRIDES = {
BurnDurationBase_label = 'AfterburnDurationBase_label',
BurnDurationBase_postfix = 'AfterburnDurationBase_postfix',
     MoveSlowPercent_label = 'MovementSlow_label',
     MoveSlowPercent_label = 'MovementSlow_label',
     BonusHealthRegen_label = 'HealthRegen_label',
     BonusHealthRegen_label = 'HealthRegen_label',
Line 21: Line 23:
     PostInvisBuffDuration_label = 'BuffDuration_label',
     PostInvisBuffDuration_label = 'BuffDuration_label',
     PostInvisBuffDuration_postfix = 'BuffDuration_postfix',
     PostInvisBuffDuration_postfix = 'BuffDuration_postfix',
    ProjectileFuse_label = 'BellLifetime_label',
    ProjectileFuse_postfix = 'BellLifetime_postfix',
     SelfBuffDuration_label = 'BuffDuration_label',
     SelfBuffDuration_label = 'BuffDuration_label',
     SelfBuffDuration_postfix = 'BuffDuration_postfix',
     SelfBuffDuration_postfix = 'BuffDuration_postfix',
Line 29: Line 33:
     MoveSlowDuration_label = 'SlowDuration_label',
     MoveSlowDuration_label = 'SlowDuration_label',
     MoveSlowDuration_postfix = 'SlowDuration_postfix',
     MoveSlowDuration_postfix = 'SlowDuration_postfix',
DashRange_label = 'TargetDashRadius_label',
DashRange_postfix = 'TargetDashRadius_postfix',
SpeedOnLandDuration_label = 'BuffDuration_label',
SpeedOnLandDuration_postfix = 'BuffDuration_postfix',
SummonCount_label = 'GhoulCount_label',
TetherDuration_label = 'ImmobilizeTrap_CurseDuration_label'
}
}


Line 49: Line 59:
local function process_html_tags(text, frame)
local function process_html_tags(text, frame)
     if not text or type(text) ~= "string" then return text end
     if not text or type(text) ~= "string" then return text end
 
   
     local replacements = {
     local replacements = {
        BonusFireRate = {icon='{{Icon/Brown|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
    BonusFireRate = {icon='{{Icon/Brown|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
        BonusMoveSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
    BonusMoveSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
        BonusSprintSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Sprint speed|20px]]}}', label_color='#ffefd7', link='Sprint speed'},
    BonusSprintSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Sprint speed|20px]]}}', label_color='#ffefd7', link='Sprint speed'},
        BonusSpiritDamage = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
    BonusSpiritDamage = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
        BonusWeaponDamage = {icon='{{Icon/NoColor|[[File:Bullet Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
    BonusWeaponDamage = {icon='{{Icon/NoColor|[[File:Bullet Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
        bullet_armor_up = {icon='{{Icon/White|[[File:Barrier.png|link=Barrier|20px]]}}', label_color='#ffefd7', link='Barrier'},
    bullet_armor_up = {icon='{{Icon/White|[[File:Barrier.png|link=Barrier|20px]]}}', label_color='#ffefd7', link='Barrier'},
        bullet_damage = {icon='{{Icon/Brown|[[File:Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
    bullet_damage = {icon='{{Icon/NoColor|[[File:Bullet_damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
        BulletResist = {icon='{{Icon/Brown|[[File:Bullet_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#ec981a', link='Damage_Resistance'},
    BulletResist = {icon='{{Icon/Brown|[[File:Bullet_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#ec981a', link='Damage_Resistance'},
        cast = {icon='{{Icon/White|[[File:Cast.png|link=|20px]]}}', label_color='#ffefd7', link=''},
    cast = {icon='{{Icon/White|[[File:Cast.png|link=|20px]]}}', label_color='#ffefd7', link=''},
        CombatBarrier = {icon='{{Icon/White|[[File:Bullet Armor (item).png|link=Damage_Resistance|20px]]}}', label_color='#ffefd7', link='Barrier'},
    CombatBarrier = {icon='{{Icon/White|[[File:Bullet Armor (item).png|link=Damage_Resistance|20px]]}}', label_color='#ffefd7', link='Barrier'},
        cooldown = {icon='{{Icon/White|[[File:AttributeIconTechDuration.png|link=Ability Cooldown|20px]]}}', label_color='#ffefd7', link='Ability Cooldown'},
    cooldown = {icon='{{Icon/White|[[File:AttributeIconTechDuration.png|link=Ability Cooldown|20px]]}}', label_color='#ffefd7', link='Ability Cooldown'},
        damage = {icon='{{Icon/NoColor|[[File:Damage heart.png|link=Damage|20px]]}}', label_color='#ec981a', link='Damage'},
    damage = {icon='{{Icon/NoColor|[[File:Damage heart.png|link=Damage|20px]]}}', label_color='#ec981a', link='Damage'},
        FireRate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
    DamageAmp = {icon='{{Icon/White|[[File:Damage heart.png|link=Damage Amp|20px]]}}', label_color='#ffefd7', link='Damage Amp'},
        fire_rate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
    FireRate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
        Heal = {icon='{{Icon/Green|[[File:Healing.png|link=Health_Regen|20px]]}}', label_color='#13f278', link='Health_Regen'},
    fire_rate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
        Healing = {icon='{{Icon/Green|[[File:Healing.png|link=Healing|20px]]}}', label_color='#13f278', link='Healing'},
    Heal = {icon='{{Icon/Green|[[File:Healing.png|link=Health_Regen|20px]]}}', label_color='#13f278', link='Health_Regen'},
        Immobilize = {icon='{{Icon/White|[[File:Immobilize.png|link=Status Effects#Immobilized|20px]]}}', label_color='#ffefd7', link='Status Effects#Immobilized'},
    Healing = {icon='{{Icon/Green|[[File:Healing.png|link=Healing|20px]]}}', label_color='#13f278', link='Healing'},
        invisible = {icon='{{Icon/White|[[File:Invisible.png|link=|20px]]}}', label_color='#ffefd7', link=''},
    Immobilize = {icon='{{Icon/White|[[File:Immobilize.png|link=Status Effects#Immobilized|20px]]}}', label_color='#ffefd7', link='Status Effects#Immobilized'},
        KnockBack = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
    invisible = {icon='{{Icon/White|[[File:Invisible.png|link=|20px]]}}', label_color='#ffefd7', link=''},
        KnockUp = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
    KnockBack = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
        MaxHealth = {icon='{{Icon/Green|[[File:Healing.png|link=Health|20px]]}}', label_color='#13f278', link='Health'},
    KnockUp =   {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
        MeleeDamage = {icon='{{Icon/Brown|[[File:Melee damage.png|link=Melee Damage|20px]]}}', label_color='#ec981a', link='Melee Damage'},
    MaxHealth = {icon='{{Icon/Green|[[File:Healing.png|link=Health|20px]]}}', label_color='#13f278', link='Health'},
        MoveSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
    MeleeDamage = {icon='{{Icon/Brown|[[File:Melee damage.png|link=Melee Damage|20px]]}}', label_color='#ec981a', link='Melee Damage'},
        move_speed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
    MoveSpeed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
        Pull = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
    move_speed = {icon='{{Icon/Green|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7', link='Move speed'},
        Pulling = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
    Pull =     {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
        Pulls = {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
    Pulling =   {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
        ReducedFireRate = {icon='{{Icon/Brown|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
    Pulls =     {icon='{{Icon/NoColor|[[File:Displacement.png|link=|20px]]}}', label_color='#ffefd7', link='Status_Effects'},
        Regen = {icon='{{Icon/Green|[[File:Healing.png|link=Health_Regen|20px]]}}', label_color='#13f278', link='Health_Regen'},
    PureDamage = {icon='{{Icon/NoColor|[[File:Damage.png|link=Pure Damage|20px]]}}', label_color='#ffefd7', link='Pure Damage'},
        revealed = {icon='{{Icon/White|[[File:Revealed.png|link=|20px]]}}', label_color='#ffefd7', link=''},
    ReducedFireRate = {icon='{{Icon/Brown|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7', link='Fire Rate'},
        silence = {icon='{{Icon/White|[[File:Silence.png|link=|20px]]}}', label_color='#ffefd7', link=''},
    Regen = {icon='{{Icon/Green|[[File:Healing.png|link=Health_Regen|20px]]}}', label_color='#13f278', link='Health_Regen'},
        Silence = {icon='{{Icon/Purple|[[File:Silence.png|link=Silence|20px]]}}', label_color='#bc8ee8', link='Silence'},
    revealed = {icon='{{Icon/White|[[File:Revealed.png|link=|20px]]}}', label_color='#ffefd7', link=''},
        Slow = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}', label_color='#ffefd7', link='Movement_Slow'},
    silence = {icon='{{Icon/White|[[File:Silence.png|link=|20px]]}}', label_color='#ffefd7', link=''},
        slow = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}', label_color='#ffefd7', link='Movement_Slow'},
    Silence = {icon='{{Icon/Purple|[[File:Silence.png|link=Silence|20px]]}}', label_color='#bc8ee8', link='Silence'},
        SlowResistance = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow#Movement_Slow_Resist|20px]]}}', label_color='#ffefd7', link='Movement_Slow#Movement_Slow_Resist'},
    Slow = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}', label_color='#ffefd7', link='Movement_Slow'},
        Spirit = {icon='{{Icon/NoColor|[[File:Spirit_icon.png|link=Spirit Power|20px]]}}', label_color='#bc8ee8', link='Spirit Power'},
    slow = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}', label_color='#ffefd7', link='Movement_Slow'},
        SpiritDamage = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
    SlowResistance = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow#Movement_Slow_Resist|20px]]}}', label_color='#ffefd7', link='Movement_Slow#Movement_Slow_Resist'},
        SpiritDPS = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
    Spirit = {icon='{{Icon/NoColor|[[File:Spirit_icon.png|link=Spirit Power|20px]]}}', label_color='#bc8ee8', link='Spirit Power'},
        SpiritIcon = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', link='Spirit Damage'},
    SpiritDamage = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
        SpiritResist = {icon='{{Icon/Purple|[[File:Spirit_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#bc8ee8', link='Damage_Resistance'},
    SpiritDPS = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
        StatDesc_TechPower = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
    SpiritIcon = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', link='Spirit Damage'},
        Stun = {icon='{{Icon/White|[[File:Status_Stun.png|link=Stun|20px]]}}', link='Stun'},
    SpiritResist = {icon='{{Icon/Purple|[[File:Spirit_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#bc8ee8', link='Damage_Resistance'},
        stun = {icon='{{Icon/White|[[File:Stun.png|link=|20px]]}}', label_color='#ffefd7', link=''},
    StatDesc_TechPower = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', label_color='#bc8ee8', link='Spirit Damage'},
        tech_armor_up = {icon='{{Icon/White|[[File:Barrier.png|link=Barrier|20px]]}}', label_color='#ffefd7', link='Barrier'},
    Stun = {icon='{{Icon/White|[[File:Status_Stun.png|link=Stun|20px]]}}', link='Stun'},
        tech_damage = {icon='{{Icon/NoColor|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', link='Spirit Damage'},
    stun = {icon='{{Icon/White|[[File:Stun.png|link=|20px]]}}', label_color='#ffefd7', link=''},
        WeaponDamage = {icon='{{Icon/NoColor|[[File:Bullet Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
    tech_armor_up = {icon='{{Icon/White|[[File:Barrier.png|link=Barrier|20px]]}}', label_color='#ffefd7', link='Barrier'},
    }
    tech_damage = {icon='{{Icon/NoColor|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}', link='Spirit Damage'},
 
    WeaponDamage = {icon='{{Icon/NoColor|[[File:Bullet Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a', link='Weapon Damage'},
     -- 1. Highlight, diminish
    Heal = {icon='{{Icon/Green|[[File:Healing.png|link=Healing|20px]]}}', label_color='#13f278', link='Healing'},
     text = text:gsub('<span class="highlight">(.-)</span>', "<span style='font-weight:bold'>%1</span>")
    Heals = {icon='{{Icon/Green|[[File:Healing.png|link=Healing|20px]]}}', label_color='#13f278', link='Healing'},
}
 
     -- Process HTML spans
     text = text:gsub('<span class="highlight">(.-)</span>', "<span style= font-weight:bold>%1</span>")
     text = text:gsub('<span class="highlight_spirit">(.-)</span>', '<span style="font-weight:bold; color:#bc8ee8">%1</span>')
     text = text:gsub('<span class="highlight_spirit">(.-)</span>', '<span style="font-weight:bold; color:#bc8ee8">%1</span>')
     text = text:gsub('<span class="diminish">(.-)</span>', '<span style="font-style:italic;color:#C0C0C0">%1</span>')
    text = text:gsub('<span class="highlight_courage">(.-)</span>', '<span style="font-weight:bold; color:#ec981a">%1</span>')
 
     text = text:gsub('<span class="diminish">(.-)</span>', '<span style="font-style: italic;color:#C0C0C0">%1</span>')
     -- 2. InlineAttributeName
     text = text:gsub('<span class=".-">(.-)</span>', '%1')
     text = text:gsub('<span class="InlineAttributeName (%w+)">(.-)</span>', function(key, inner)
     text = text:gsub('<Panel class=\"AbilityPropertyIcon StatDesc_TechPower\">', '{{Icon/Purple|[[File:Spirit damage.png|link=Spirit Damage|20px]]}}')
    text = text:gsub('</Panel>', '')
   
    -- Process panel tags
text = text:gsub('<Panel class=\"AbilityPropertyIcon prop_(.-)\">', function(key)
    local replacement = replacements[key]
    local replacement = replacements[key]
    local label_color = replacement and replacement.label_color or '#ffefd7'
    if replacement then
 
        local label_color = replacement.label_color or 'inherit'
    local translated
        local icon = replacement.icon or ''
    if inner and inner ~= '' then
        local link = replacement.link or ''
        translated = inner
        -- pre-process string, then check to omit link if the string is empty
        local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}')
       
        if translated == '' then
            return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s</span>', label_color, icon)
        else
            return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s [[%s|%s]]</span>',
                label_color,
                icon,
                link,
                translated)
        end
    else
    else
        translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}')
        return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing attribute definition - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>'
    end
    end
end)
     
     
    return string.format('<span style="font-weight:bold; color:%s;">%s</span>', label_color, translated)
     -- Process citadel_inline_attribute tags
end)
text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key)
 
 
     -- 3. AbilityPropertyIcon
    text = text:gsub('<[Pp]anel class="AbilityPropertyIcon prop_(.-)"[^>]->', function(key)
        local replacement = replacements[key]
        if replacement then
            local icon = replacement.icon or ''
            local label_color = replacement.label_color or 'inherit'
            local link = replacement.link or ''
            local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}')
            if translated == '' then
                return string.format('<span class="no-blue-link" style="font-weight:bold; color:%s;">%s</span>', label_color, icon)
            else
                return string.format('<span class="no-blue-link" style="font-weight:bold; color:%s;">%s [[%s|%s]]</span>', label_color, icon, link, translated)
            end
        else
            return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;">['..key..']</span>'
        end
    end)
 
    -- 4. InlineAttributeIcon
    text = text:gsub('<[Pp]anel class="InlineAttributeIcon (%w+)"[^>]->', function(key)
    local replacement = replacements[key]
    local replacement = replacements[key]
    if replacement then
    if replacement then
        return string.format('<span class="no-blue-link" style="font-weight:bold; color:%s;">%s</span>', replacement.label_color or 'inherit', replacement.icon or '')
        local label_color = replacement.label_color or 'inherit'
        local icon = replacement.icon or ''
        local link = replacement.link or ''
        -- pre-process string, then check to omit link if the string is empty
        local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}')
       
        if translated == '' then
            return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s</span>', label_color, icon)
        else
            return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s [[%s|%s]]</span>',  
                label_color,
                icon,
                link,
                translated)
        end
    else
    else
        return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;">['..key..']</span>'
        return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing attribute definition - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>'
    end
    end
end)
end)
 
   
 
     -- List for keybinds with mismatched names. Replace with the correct name under "citadel_keybind_[key]" in Data:Lang
     -- 5. citadel_inline_attribute
    keybinds = {
     text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key)
        MoveForward = "forward",
         local replacement = replacements[key]
        AltCast = "alt_cast",
         if replacement then
        }
            local icon = replacement.icon or ''
   
            local label_color = replacement.label_color or 'inherit'
     -- Process citadel_binding/citadel_keybind tags to replace with keybind strings/templates
            local link = replacement.link or ''
text = text:gsub("{g:citadel_binding:'(.-)'}", function(key)
            local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}')
  -- convert key to lowercase
            if translated == '' then
         local lower_key = key:lower()
                return string.format('<span class="no-blue-link" style="font-weight:bold; color:%s;">%s</span>', label_color, icon)
         -- look up key with Module:Lang. check if it has a replacement key first
            else
        local replacement = keybinds[key] or lower_key
                return string.format('<span class="no-blue-link" style="font-weight:bold; color:%s;">%s [[%s|%s]]</span>', label_color, icon, link, translated)
        local translated = frame:preprocess('{{#invoke:Lang|get_string|citadel_keybind_'.. replacement ..'}}')
            end
  if translated ~= nil and translated ~= '' then
        return "'''" .. translated .. "'''"
         else
         else
             return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;">['..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>'
         end
         end
    end)
end)
 
     -- 6. Удаляем закрывающие теги panel
     -- Force spaces around keybinds where the source data omits them
     text = text:gsub('</[Pp]anel>', '')
     text = text:gsub("'''([a-zA-Z])", "''' %1")
 
    -- 7. Keybinds
    local KEYBINDS = {
        MoveForward = "'''Move Forward button'''",
        MoveBackwards = "'''Move Backward button'''",
        MoveLeft = "'''Move Left button'''",
        MoveRight = "'''Move Right button'''",
        Mantle = "'''Jump button'''",
        Zipline = "'''Zipline button'''",
        Roll = "'''Dash button'''",
        Crouch = "'''Crouch button'''",
        MoveDown = "'''Fly Down button'''",
        MoveUp = "'''Fly Up button'''",
        Attack = "'''Fire button'''",
        ADS = "'''Alt-Fire button'''",
        Reload = "'''Reload button'''",
        AbilityMelee = "'''Melee button'''",
        HeldItem = "'''Melee Parry/Throw Held Item button'''",
        Ability1 = "'''Ability 1 button'''",
        Ability2 = "'''Ability 2 button'''",
        Ability3 = "'''Ability 3 button'''",
        Ability4 = "'''Ability 4 button'''",
        AltCast = "'''Alternate Cast'''",
        OpenHeroSheet = "'''Open Shop button'''",
        PurchaseQuickbuy = "'''Purchase Quickbuy button'''",
        Scoreboard = "'''Scoreboard button'''",
        OpenMainMenu = "'''Open Main Menu button'''",
        PushToTalk = "'''Voice Chat button'''",
        Pause = "'''Pause button'''",
        ReplayDeath = "'''Replay Death button'''",
        HideoutUse = "'''Interact with an object in the Hideout button'''",
        HideoutCancelMatchmaking = "'''Cancel Matchmaking button'''",
    }


     text = text:gsub("{g:citadel_binding:'(.-)'}", function(key)
     -- Clean up extra spaces between a keybind and following punctuation
        return KEYBINDS[key] or '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;">['..key..']</span>'
    end)
    text = text:gsub("{g:citadel_keybind:'(.-)'}", function(key)
        return KEYBINDS[key] or '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;">['..key..']</span>'
    end)
 
    -- Force spaces around keybinds
    text = text:gsub("'''([a-zA-Z])", "''' %1")
     text = text:gsub("'''%s+:", "''':")
     text = text:gsub("'''%s+:", "''':")


    return frame:preprocess(text)
return frame:preprocess(text)
end
end


Line 222: Line 204:
     local frame
     local frame
     if type(key) == "table" and key.args then
     if type(key) == "table" and key.args then
         frame = key
         frame = type(key.preprocess) == "function" and key or mw.getCurrentFrame()
         key = frame.args[1]
       
         lang_code_override = frame.args["lang_code_override"]
        local args = key.args
         fallback_str = frame.args["fallback_str"]
         key = args[1]
         remove_var_index = frame.args["remove_var_index"]
         lang_code_override = args["lang_code_override"]
         item_name = frame.args["item_name"]
         fallback_str = args["fallback_str"]
         remove_var_index = args["remove_var_index"]
         item_name = args["item_name"]
     else
     else
         frame = mw.getCurrentFrame()
         frame = mw.getCurrentFrame()
Line 295: Line 279:
             -- If value exists, remove non-number symbols (but keep + and -)
             -- If value exists, remove non-number symbols (but keep + and -)
             if value then
             if value then
                 value = value:gsub("[^0-9+-]", "")
                 value = value:gsub("[^0-9+-.]", "")
                 -- Return empty string if nothing left, otherwise return the filtered value
                 -- Return empty string if nothing left, otherwise return the filtered value
                 return value ~= "" and value or variable_name
                 return value ~= "" and value or variable_name