Module:Icon: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Put the "nowrap" around the icon and text – not just icon, it doesn't do anything that way |
Cleaned up the code for displaying the icon text. |
||
| Line 58: | Line 58: | ||
local langCode, langData = getLangData() | local langCode, langData = getLangData() | ||
local | |||
-- Determine display name with clear priority | |||
local displayName = "" | |||
if customText ~= "" then | |||
displayName = customText | |||
elseif iconData.key and langData[iconData.key] then | |||
displayName = langData[iconData.key] | |||
elseif iconData.name then | |||
displayName = iconData.name | |||
elseif iconOnly then | |||
displayName = "" | |||
else | |||
displayName = name -- fallback to input name | |||
end | |||
-- Localize link if on a translated subpage | -- Localize link if on a translated subpage | ||
| Line 77: | Line 84: | ||
end | end | ||
local iconHtml = string.format('<span %s>[[File:%s|%s|link=]]</span>', style, iconData.image, size) | local iconHtml = string.format('<span %s>[[File:%s|%s|link=]]</span>', style, iconData.image, size) | ||
if iconOnly or displayName == "" then | |||
return iconHtml | |||
end | |||
local textHtml = (noLink or link == "") and | local textHtml = (noLink or link == "") and displayName or string.format('[[%s|%s]]', link, displayName) | ||
return '<span style="white-space:nowrap;">' .. iconHtml .. " " .. textHtml .. '</span>' | return '<span style="white-space:nowrap;">' .. iconHtml .. " " .. textHtml .. '</span>' | ||
end | end | ||
return p | return p | ||