Module:Lang: Difference between revisions

Jump to navigation Jump to search
integrated process_variables into get_string
refactored process_html_tags function to insert variables into a single style template
Line 39: Line 39:
      
      
     local replacements = {
     local replacements = {
         SpiritIcon = '{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}',
         SpiritIcon = {icon='{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}'},
         SpiritDamage = '{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}<span style="color:#bc8ee8;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_SpiritDamage}}</span>',
         SpiritDamage = {icon='{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8'},
         SpiritResist = '{{Icon/Purple|[[File:Spirit_Armor.png|link=Damage_Resistance|20px]]}}<span style="color:#bc8ee8;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_SpiritResist}}</span>',
         SpiritResist = {icon='{{Icon/Purple|[[File:Spirit_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#bc8ee8'},
         FireRate = '{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_FireRate}}</span>',
         FireRate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7'},
         ReducedFireRate = '{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_ReducedFireRate}}</span>',
         ReducedFireRate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7'},
         MeleeDamage = '{{Icon/Brown|[[File:Melee damage.png|link=Melee Damage|20px]]}}<span style="font-weight: bold;color:#ec981a">{{#invoke:Lang|get_string|InlineAttribute_MeleeDamage}}</span>',
         MeleeDamage = {icon='{{Icon/Brown|[[File:Melee damage.png|link=Melee Damage|20px]]}}', label_color='#ec981a'},
         WeaponDamage = '{{Icon/Brown|[[File:Damage.png|link=Weapon Damage|20px]]}}<span style="color:#ec981a;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_WeaponDamage}}</span>',
         WeaponDamage = {icon='{{Icon/Brown|[[File:Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a'},
         BulletResist = '{{Icon/Brown|[[File:Bullet_Armor.png|link=Damage_Resistance|20px]]}}<span style="color:#ec981a;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_BulletResist}}</span>',
         BulletResist = {icon='{{Icon/Brown|[[File:Bullet_Armor.png|link=Damage_Resistance|20px]]}}', label_color='#ec981a'},
         BonusWeaponDamage = '{{Icon/Brown|[[File:Damage.png|link=Weapon Damage|20px]]}}<span style="color:#ec981a;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_BonusWeaponDamage}}</span>',
         BonusWeaponDamage = {icon='{{Icon/Brown|[[File:Damage.png|link=Weapon Damage|20px]]}}', label_color='#ec981a'},
         MoveSpeed = '{{Icon/White|[[File:Move_speed.png|link=Move speed|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_MoveSpeed}}</span>',
         MoveSpeed = {icon='{{Icon/White|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7'},
         BonusSpiritDamage = '{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}<span style="color:#bc8ee8;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_BonusSpiritDamage}}</span>',
         BonusSpiritDamage = {icon='{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8'},
         BonusFireRate =     '{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_BonusFireRate}}</span>',
         BonusFireRate = {icon='{{Icon/White|[[File:Fire_Rate.png|link=Fire Rate|20px]]}}', label_color='#ffefd7'},
         Heal =             '{{Icon/Green|[[File:Health_regen.png|link=Health_Regen|20px]]}}<span style="color:#13f278;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Heal}}</span>',
         Heal = {icon='{{Icon/Green|[[File:Health_regen.png|link=Health_Regen|20px]]}}', label_color='#13f278'},
         BonusMoveSpeed =   '{{Icon/White|[[File:Move_speed.png|link=Move speed|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_BonusMoveSpeed}}</span>',
         BonusMoveSpeed = {icon='{{Icon/White|[[File:Move_speed.png|link=Move speed|20px]]}}', label_color='#ffefd7'},
         Spirit =           '{{Icon/NoColor|[[File:Spirit_icon.png|link=Spirit Power|20px]]}}<span style="color:#bc8ee8;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Spirit}}</span>',
         Spirit = {icon='{{Icon/NoColor|[[File:Spirit_icon.png|link=Spirit Power|20px]]}}', label_color='#bc8ee8'},
         Stun =             '{{Icon/White|[[File:Status_Stun.png|link=Stun|20px]]}}<span style="font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Stun}}</span>',
         Stun = {icon='{{Icon/White|[[File:Status_Stun.png|link=Stun|20px]]}}'},
         SpiritDPS =         '{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}<span style="color:#bc8ee8;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_SpiritDPS}}</span>',
         SpiritDPS = {icon='{{Icon/Purple|[[File:AttributeIconTechShieldHealth.png|link=Spirit Damage|12px]]}}', label_color='#bc8ee8'},
    Healing =           '{{Icon/Green|[[File:Health_regen.png|link=Healing|20px]]}}<span style="color:#13f278;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Healing}}</span>',
    Healing = {icon='{{Icon/Green|[[File:Health_regen.png|link=Healing|20px]]}}', label_color='#13f278'},
    Regen =             '{{Icon/Green|[[File:Health_regen.png|link=Health_Regen|20px]]}}<span style="color:#13f278;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Regen}}</span>',
    Regen = {icon='{{Icon/Green|[[File:Health_regen.png|link=Health_Regen|20px]]}}', label_color='#13f278'},
    Slow = '{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_Slow}}</span>',
    Slow = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow|20px]]}}', label_color='#ffefd7'},
    SlowResistance = '{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow#Movement_Slow_Resist|20px]]}}<span style="color:#ffefd7;font-weight: bold;">{{#invoke:Lang|get_string|InlineAttribute_SlowResistance}}</span>',
    SlowResistance = {icon='{{Icon/White|[[File:MoveSlow.png|link=Movement_Slow#Movement_Slow_Resist|20px]]}}', label_color='#ffefd7'},
     }
     }
   
 
     -- Process citadel_inline_attribute tags
     -- Process citadel_inline_attribute tags
     text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key)
     text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key)
        if replacements[key] then
    local replacement = replacements[key]
             return replacements[key]
        if replacement then
             return string.format('<span style="text-wrap:nowrap; font-weight:bold; color:%s">%s {{#invoke:Lang|get_string|InlineAttribute_%s}}</span>', replacement.label_color, replacement.icon, key)
         else
         else
             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>'
             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>'