Module:ItemData/nav: Difference between revisionsGive feedback
added translation subpage support |
fixed /en subpage being added to links |
||
| Line 51: | Line 51: | ||
local item_name_english = lang_module.get_string(item_key, "en") -- Get the English name | local item_name_english = lang_module.get_string(item_key, "en") -- Get the English name | ||
local lang_code = get_language_from_subpage() -- Get the language code from the subpage | local lang_code = get_language_from_subpage() -- Get the language code from the subpage | ||
local item_name_local = lang_module.get_string(item_key, lang_code) -- Get the localized name | |||
-- Construct the template based on the type | -- Construct the template based on the type | ||
local item_template | local item_template | ||
if template == "ItemIcon" then | if template == "ItemIcon" then | ||
if lang_code == "en" then | |||
-- For English pages, do not include lang or localized name | |||
item_template = "{{ItemIcon|" .. item_name_english .. "}}" | |||
else | |||
-- For non-English pages, include lang and localized name | |||
item_template = "{{ItemIcon|" .. item_name_english .. "|lang=" .. lang_code .. "|" .. item_name_local .. "}}" | |||
end | |||
elseif template == "ItemBox" then | elseif template == "ItemBox" then | ||
if lang_code == "en" then | if lang_code == "en" then | ||
| Line 63: | Line 69: | ||
else | else | ||
-- For non-English pages, include item_loc and link | -- For non-English pages, include item_loc and link | ||
local link = item_name_english .. "/" .. lang_code -- Add subpage for non-English languages | local link = item_name_english .. "/" .. lang_code -- Add subpage for non-English languages | ||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link .. "}}" | item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link .. "}}" | ||