Module:Sandbox/LVL: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 12: Line 12:
     if not success then lang_data = {} end
     if not success then lang_data = {} end


     -- Keys to explicitly ignore (metadata, not stats)
     -- Keys to explicitly ignore (metadata that might have translations but we don't want in search)
     local ignore_keys = {
     local ignore_keys = {
         ["Name"] = true, ["Description"] = true, ["Cost"] = true, ["Tier"] = true,
         ["Name"] = true, ["Description"] = true, ["Cost"] = true, ["Tier"] = true,
         ["Activation"] = true, ["Slot"] = true, ["Components"] = true, ["TargetTypes"] = true,
         ["Activation"] = true, ["Slot"] = true, ["Components"] = true, ["TargetTypes"] = true,
         ["ShopFilters"] = true, ["IsDisabled"] = true, ["StreetBrawl"] = true, ["IsImbue"] = true,
         ["ShopFilters"] = true, ["IsDisabled"] = true, ["StreetBrawl"] = true, ["IsImbue"] = true,
        ["AbilityUnitTargetLimit"] = true, ["AbilityCooldownBetweenCharge"] = true,
         ["ChannelMoveSpeed"] = true -- Keep this ignored since every item has it
         ["ChannelMoveSpeed"] = true, ["NPCDamageMult"] = true, ["DamageHeight"] = true,
        ["Scale"] = true, ["Value"] = true -- Internal sub-table keys we don't need as text
     }
     }


Line 30: Line 28:
                 -- Try to get the in-game name from the lang file
                 -- Try to get the in-game name from the lang file
                 local term = lang_data[k .. "_label"] or lang_data[k]
                 local term = lang_data[k .. "_label"] or lang_data[k]
               
                -- ONLY add if a valid translation exists in the lang file!
                 if term and type(term) == "string" then
                 if term and type(term) == "string" then
                     -- Clean up any HTML tags or inline attributes from the localization string
                     -- Clean up any HTML tags or inline attributes from the localization string
Line 35: Line 35:
                     term = term:gsub("{g:citadel_inline_attribute:'(.-)'}", "%1")
                     term = term:gsub("{g:citadel_inline_attribute:'(.-)'}", "%1")
                     table.insert(terms, string.lower(term))
                     table.insert(terms, string.lower(term))
                else
                    -- Fallback: Convert CamelCase to spaces (e.g., BonusMoveSpeed -> bonus move speed)
                    local fallback_term = string.lower(k:gsub("(%u)", " %1"):gsub("^%s", ""))
                    table.insert(terms, fallback_term)
                 end
                 end
                -- Notice: NO ELSE BLOCK! If it's not in the lang file, we drop it completely.
             end
             end


             if type(v) == "table" then
             if type(v) == "table" then
                 recurse(v)
                 recurse(v)
            -- Notice: We completely ignore string values here, which drops descriptions!
            -- We also ignore numbers and booleans. We only want the stat names (keys).
             end
             end
         end
         end