diff --git a/Core/Utils.lua b/Core/Utils.lua index 5dcb4b5..e555b39 100644 --- a/Core/Utils.lua +++ b/Core/Utils.lua @@ -998,42 +998,31 @@ local localizedBagTypes = {} -- lowercased localized subType -> "quiver"/"am local localizedProjectiles = {} -- localized subType (any case) -> "arrow"/"bullet" local localizedTypesResolved = false --- Reference itemIDs guaranteed to exist in every WoW 1.12 client. --- Soul/herb/enchant bag IDs are intentionally omitted because they vary per --- server (TurtleWoW custom items, etc.) — those still use the English fallback. -local BAG_REFERENCE_ITEMS = { - [2101] = "quiver", -- Light Quiver - [2102] = "ammo", -- Small Ammo Pouch -} -local PROJECTILE_REFERENCE_ITEMS = { - [2512] = "arrow", -- Rough Arrow - [2516] = "bullet", -- Light Shot -} - +-- Locale-specific subType strings live in Localization.lua (Guda_LSubtypes). +-- Avoids GetItemInfo cache cold-start: lookups are pure table reads, populated +-- once on first use from the current client locale (with enUS as a fallback). local function ResolveLocalizedTypes() if localizedTypesResolved then return end - local allResolved = true - - for itemID, key in pairs(BAG_REFERENCE_ITEMS) do - -- Position 6 in TurtleWoW GetItemInfo signature is itemType (subType) - local _, _, _, _, _, itemType = GetItemInfo(itemID) - if itemType then - localizedBagTypes[string.lower(itemType)] = key - else - allResolved = false + if not Guda_LSubtypes then return end + local clientLocale = (GetLocale and GetLocale()) or "enUS" + local map = Guda_LSubtypes[clientLocale] or Guda_LSubtypes.enUS + local en = Guda_LSubtypes.enUS or {} + -- Merge enUS first (so English clients on a partial locale still work), + -- then the active locale on top. + local sources = { en, map } + for i = 1, 2 do + local src = sources[i] + if src then + if src.quiver then localizedBagTypes[string.lower(src.quiver)] = "quiver" end + if src.ammo then localizedBagTypes[string.lower(src.ammo)] = "ammo" end + if src.soul then localizedBagTypes[string.lower(src.soul)] = "soul" end + if src.herb then localizedBagTypes[string.lower(src.herb)] = "herb" end + if src.enchant then localizedBagTypes[string.lower(src.enchant)] = "enchant" end + if src.arrow then localizedProjectiles[src.arrow] = "arrow" end + if src.bullet then localizedProjectiles[src.bullet] = "bullet" end end end - - for itemID, key in pairs(PROJECTILE_REFERENCE_ITEMS) do - local _, _, _, _, _, itemType = GetItemInfo(itemID) - if itemType then - localizedProjectiles[itemType] = key - else - allResolved = false - end - end - - if allResolved then localizedTypesResolved = true end + localizedTypesResolved = true end function Utils:GetSpecializedBagType(bagID) diff --git a/Localization.lua b/Localization.lua index d78e4bd..1b08a91 100644 --- a/Localization.lua +++ b/Localization.lua @@ -292,6 +292,47 @@ L["Name:"] = "Name:" L["Match Mode:"] = "Match Mode:" L["Rules:"] = "Rules:" +-- ============================================================================ +-- Item subType strings (locale-specific) used by Sorting/SortEngine and +-- Core/Utils.lua to identify specialized bags and projectiles WITHOUT relying +-- on GetItemInfo cache cold-start. These are the raw strings WoW returns from +-- GetItemInfo position 6 (subType) for each bag/projectile family. All bags +-- in one family share the same subType string, so one entry per family is +-- enough. Unknown locales fall back to enUS. +-- ============================================================================ +Guda_LSubtypes = { + enUS = { + quiver = "Quiver", ammo = "Ammo Pouch", + soul = "Soul Bag", herb = "Herb Bag", enchant = "Enchanting Bag", + arrow = "Arrow", bullet = "Bullet", + }, + deDE = { + quiver = "Köcher", ammo = "Munitionsbeutel", + soul = "Seelentasche", herb = "Kräutertasche", enchant = "Verzauberertasche", + arrow = "Pfeil", bullet = "Kugel", + }, + frFR = { + quiver = "Carquois", ammo = "Giberne", + soul = "Sac d'âmes", herb = "Sacoche d'herboriste", enchant = "Sac d'enchanteur", + arrow = "Flèche", bullet = "Balle", + }, + esES = { + quiver = "Carcaj", ammo = "Bolsa de munición", + soul = "Bolsa de almas",herb = "Bolsa de hierbas", enchant = "Bolsa de encantamiento", + arrow = "Flecha", bullet = "Bala", + }, + zhCN = { + quiver = "箭袋", ammo = "弹药袋", + soul = "灵魂袋", herb = "草药袋", enchant = "附魔袋", + arrow = "箭", bullet = "子弹", + }, + ruRU = { + quiver = "Колчан", ammo = "Подсумок", + soul = "Сумка для душ", herb = "Сумка травника",enchant = "Сумка зачарователя", + arrow = "Стрела", bullet = "Пуля", + }, +} + -- ============================================================================ -- Locale overrides -- Translators: copy any L["..."] = "..." line above into the matching block