Module:Icon: Difference between revisionsGive feedback
mNo edit summary |
mNo edit summary |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 51: | Line 51: | ||
end | end | ||
-- | -- Get the translated name | ||
local function getTranslatedName(iconInfo, langCode) | local function getTranslatedName(iconInfo, langCode) | ||
if langCode == "en" then | if langCode == "en" then | ||
| Line 108: | Line 82: | ||
-- No valid key > fallback | -- No valid key > fallback | ||
return iconInfo.name | return iconInfo.name | ||
end | |||
-- Infer link from type and available fields | |||
local function getLink(iconInfo, langCode) | |||
if iconInfo.type == "ability" then | |||
local hero = iconInfo.hero_name or iconInfo.name | |||
-- Get the translated name for the specific ability | |||
local abilityName = getTranslatedName(iconInfo, langCode) | |||
-- Format for URL: replace spaces with underscores | |||
local anchor = abilityName:gsub(" ", "_") | |||
return hero .. "#" .. anchor | |||
end | |||
return linkOverrides[iconInfo.name] or iconInfo.name | |||
end | end | ||
| Line 130: | Line 121: | ||
end | end | ||
-- Quick hack: ability names are used by MediaWiki:Gadget-infobox-tooltip.js and expected to be localized | |||
local langCode = getLangCode() | local langCode = getLangCode() | ||
| Line 214: | Line 206: | ||
style = 'class="module-icon-ability" style="position:relative; bottom:2px;"' | style = 'class="module-icon-ability" style="position:relative; bottom:2px;"' | ||
else | else | ||
style = 'style="position:relative; bottom:2px;"' | style = 'class="c-icon" style="position:relative; bottom:2px;"' | ||
end | end | ||