fix: localization bags
This commit is contained in:
+21
-32
@@ -998,42 +998,31 @@ local localizedBagTypes = {} -- lowercased localized subType -> "quiver"/"am
|
|||||||
local localizedProjectiles = {} -- localized subType (any case) -> "arrow"/"bullet"
|
local localizedProjectiles = {} -- localized subType (any case) -> "arrow"/"bullet"
|
||||||
local localizedTypesResolved = false
|
local localizedTypesResolved = false
|
||||||
|
|
||||||
-- Reference itemIDs guaranteed to exist in every WoW 1.12 client.
|
-- Locale-specific subType strings live in Localization.lua (Guda_LSubtypes).
|
||||||
-- Soul/herb/enchant bag IDs are intentionally omitted because they vary per
|
-- Avoids GetItemInfo cache cold-start: lookups are pure table reads, populated
|
||||||
-- server (TurtleWoW custom items, etc.) — those still use the English fallback.
|
-- once on first use from the current client locale (with enUS as a 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
|
|
||||||
}
|
|
||||||
|
|
||||||
local function ResolveLocalizedTypes()
|
local function ResolveLocalizedTypes()
|
||||||
if localizedTypesResolved then return end
|
if localizedTypesResolved then return end
|
||||||
local allResolved = true
|
if not Guda_LSubtypes then return end
|
||||||
|
local clientLocale = (GetLocale and GetLocale()) or "enUS"
|
||||||
for itemID, key in pairs(BAG_REFERENCE_ITEMS) do
|
local map = Guda_LSubtypes[clientLocale] or Guda_LSubtypes.enUS
|
||||||
-- Position 6 in TurtleWoW GetItemInfo signature is itemType (subType)
|
local en = Guda_LSubtypes.enUS or {}
|
||||||
local _, _, _, _, _, itemType = GetItemInfo(itemID)
|
-- Merge enUS first (so English clients on a partial locale still work),
|
||||||
if itemType then
|
-- then the active locale on top.
|
||||||
localizedBagTypes[string.lower(itemType)] = key
|
local sources = { en, map }
|
||||||
else
|
for i = 1, 2 do
|
||||||
allResolved = false
|
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
|
||||||
end
|
end
|
||||||
|
localizedTypesResolved = true
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utils:GetSpecializedBagType(bagID)
|
function Utils:GetSpecializedBagType(bagID)
|
||||||
|
|||||||
@@ -292,6 +292,47 @@ L["Name:"] = "Name:"
|
|||||||
L["Match Mode:"] = "Match Mode:"
|
L["Match Mode:"] = "Match Mode:"
|
||||||
L["Rules:"] = "Rules:"
|
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
|
-- Locale overrides
|
||||||
-- Translators: copy any L["..."] = "..." line above into the matching block
|
-- Translators: copy any L["..."] = "..." line above into the matching block
|
||||||
|
|||||||
Reference in New Issue
Block a user