Module:Buildup: Difference between revisions

LVL (talk | contribs)
Fix for Silver's transformed state. She seems to use her normal form buildup numbers.
LVL (talk | contribs)
Handle missing translation for Silver (Transformed) on /ru pages
Line 167: Line 167:


     -- Rows
     -- Rows
    for _, h in ipairs(hero_list) do
for _, h in ipairs(hero_list) do
        local row = html:tag('tr')
    local row = html:tag('tr')
        local icon_template = frame:expandTemplate{ title = 'HeroIcon', args = { h.name } }
    local hero_display
       
        -- Use data-sort-value so the table sorts correctly even with the icon
    if h.name == "Silver (Transformed)" then
        row:tag('td')
    -- Detect page language from subpage (e.g. /ru)
            :attr('data-sort-value', h.name) -- Uses the name including "The" for consistent default sort
    local currentTitle = mw.title.getCurrentTitle().fullText
            :wikitext(icon_template)
    local langCode = currentTitle:match("/([^/]+)$") or "en"
           
    local isRussian = (langCode == "ru")
        row:tag('td'):wikitext(string.format("%.1f", h.bps))
        row:tag('td'):wikitext(tostring(h.shots))
    local displayName = isRussian and "Сильвер (Трансформация)" or "Silver (Transformed)"
    end
    local linkTarget = isRussian and "Silver (Transformed)/ru" or "Silver (Transformed)"
    local icon_file = string.format('[[File:Silver.png|20px|link=%s]]', linkTarget)
    local name_link = string.format('[[%s|%s]]', linkTarget, displayName)
    hero_display = string.format(
        '<span style="white-space:nowrap;">'
        .. '<span style="position:relative; bottom:2px;">%s</span>'
        .. ' %s'
        .. '</span>',
        icon_file, name_link
    )
else
    hero_display = frame:expandTemplate{ title = 'HeroIcon', args = { h.name } }
end
    row:tag('td')
        :attr('data-sort-value', h.name)
        :wikitext(hero_display)
    row:tag('td'):wikitext(string.format("%.1f", h.bps))
    row:tag('td'):wikitext(tostring(h.shots))
end


     return tostring(html)
     return tostring(html)