Module:AbilitySection: Difference between revisions

LVL (talk | contribs)
Switch to visually hidden H3 for TOC parsing; remove unused icon module dependency and dead code.
Use Data:Dictionary keys for ability card tab labels instead of hardcoded English (with help from vergir-bot LLM)
 
Line 6: Line 6:
local AbilityHints    = require "Module:AbilityHints"
local AbilityHints    = require "Module:AbilityHints"
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
local dictionary_data = mw.loadJsonData("Data:Dictionary")


-- Tab definitions — order here determines display order.
-- Tab definitions — order here determines display order.
-- label_dict_key names the [[Data:Dictionary]] entry holding the tab label; the Notes
-- tab reuses the existing 'Notes' entry rather than adding a duplicate.
local TABS = {
local TABS = {
     { key = 'notes',        label = 'Notes'       },
     { key = 'notes',        label_dict_key = 'Notes'                     },
     { key = 'tips',        label = 'Tips'        },
     { key = 'tips',        label_dict_key = 'AbilityCardTabTips'        },
     { key = 'interactions', label = 'Interactions' },
     { key = 'interactions', label_dict_key = 'AbilityCardTabInteractions' },
}
}
local SHOW_ALL_DICT_KEY = 'AbilityCardTabShowAll'
-- Tab labels are read from the dictionary directly instead of going through
-- Module:Dictionary, which appends Template:NeedsTranslationTooltip markup to
-- anything untranslated. mw.ext.tabber.render HTML-escapes a label and reuses it as a
-- DOM id, so that markup would show up as literal text in the tab and mangle the
-- anchor. Untranslated labels therefore fall back to English silently.
local function tab_label(dict_key)
    local entry = dictionary_data[dict_key]
    if entry == nil then return dict_key end
    return entry[lang.get_lang_code()] or entry.en or dict_key
end


local function get_hero_key(hero_name)
local function get_hero_key(hero_name)
Line 61: Line 77:
             table.insert(filled, {
             table.insert(filled, {
                 key    = tab.key,
                 key    = tab.key,
                 label  = tab.label,
                 label  = tab_label(tab.label_dict_key),
                 tab_wt = tab_wt,
                 tab_wt = tab_wt,
                 all_wt = wikitext_map[tab.key],
                 all_wt = wikitext_map[tab.key],
Line 89: Line 105:
         end
         end
         table.insert(tabs, {
         table.insert(tabs, {
             label  = 'Show All',
             label  = tab_label(SHOW_ALL_DICT_KEY),
             content = '<div class="ability-details-panel">' .. table.concat(all_parts) .. '</div>',
             content = '<div class="ability-details-panel">' .. table.concat(all_parts) .. '</div>',
         })
         })