Module:Icon: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
Fall back to english page when localized version doesnt exist
LVL (talk | contribs)
Fix expensive parser function limit errors by removing title.exists check, now uses direct linking for localized pages
Line 7: Line 7:
local iconDataCache = nil
local iconDataCache = nil
local cachedLangCode, cachedLangData
local cachedLangCode, cachedLangData
-- Cache for expensive existence checks (persists during page render)
local existenceCache = {}


-- Heroes/Items that don't have images uploaded yet
-- Heroes/Items that don't have images uploaded yet
Line 228: Line 231:
     end
     end


     -- Localize link if on translated subpage (with fallback)
     -- Localize link if on translated subpage
local baseLink = iconData.link or ""
    local baseLink = iconData.link or ""
local link = baseLink
    local link = baseLink
   
if langCode ~= "en" and baseLink ~= "" then
    if langCode ~= "en" and baseLink ~= "" then
    local localizedTitle = mw.title.new(baseLink .. "/" .. langCode)
        link = baseLink .. "/" .. langCode
    if localizedTitle and localizedTitle.exists then
    end
        link = baseLink .. "/" .. langCode
    end
end


     -- Style logic (only abilities get theme class by default)
     -- Style logic (only abilities get theme class by default)