This commit is contained in:
DuvelCorp
2026-02-27 18:57:24 +01:00
parent ee8328e903
commit 2c94650993
85 changed files with 30197 additions and 820 deletions
+287 -130
View File
@@ -2,103 +2,174 @@
-- MetaHunt Localization System
------------------------------------------------------
MTH.localization = {}
MTH.localization = MTH.localization or {}
MTH.currentLocale = GetLocale()
-- Binding Headers (must be defined early for keybindings)
BINDING_HEADER_FEEDOMATIC = "[MetaHunt] Feed-O-Matic"
BINDING_HEADER_ZAspectHeader = "[MetaHunt] ZAspect Buttons"
BINDING_HEADER_ZTrackHeader = "[MetaHunt] ZTrack Buttons"
BINDING_HEADER_ZTrapHeader = "[MetaHunt] ZTrap Buttons"
BINDING_HEADER_ZPetHeader = "[MetaHunt] ZPet Buttons"
BINDING_HEADER_ZAmmoHeader = "[MetaHunt] ZAmmo Buttons"
local MTH_LOCALE_ALIASES = {
enGB = "enUS",
esMX = "esES",
zhTW = "zhCN",
frFR = "enUS",
}
-- Localization table structure
local L = {}
-- English (default)
if MTH.currentLocale == "enUS" or MTH.currentLocale == "enGB" then
-- FeedOMatic
L.FEEDOMATIC_NAME = "Feed-O-Matic"
L.FEEDOMATIC_DESC = "Helps a Hunter keep his pets well fed"
L.TOOLTIPS_OPTION_FOOD = "Add tooltips on food"
L.TOOLTIPS_OPTION_FOOD_HELP = "Show your current pet's food preference directly in item tooltips."
L.TOOLTIPS_OPTION_OWNPET = "Activate on my pet"
L.TOOLTIPS_OPTION_OWNPET_HELP = "Show your own pet status details in tooltip when hovering your pet context."
L.TOOLTIPS_FOOD_QUALITY_UNKNOWN = "%s can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_QUALITY_UNDER = "%s doesn't like this anymore."
L.TOOLTIPS_FOOD_QUALITY_MIGHT = "%s might eat this."
L.TOOLTIPS_FOOD_QUALITY_WILL = "%s will eat this."
L.TOOLTIPS_FOOD_QUALITY_LIKE = "%s likes to eat this."
L.TOOLTIPS_FOOD_QUALITY_LOVE = "%s loves to eat this."
L.TOOLTIPS_FOOD_MARKER_UNKNOWN = "can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_MARKER_UNDER = "doesn't like this anymore."
L.TOOLTIPS_FOOD_MARKER_MIGHT = "might eat this."
L.TOOLTIPS_FOOD_MARKER_WILL = "will eat this."
L.TOOLTIPS_FOOD_MARKER_LIKE = "likes to eat this."
L.TOOLTIPS_FOOD_MARKER_LOVE = "loves to eat this."
-- zhunter
L.ZHUNTER_NAME = "zhunter"
L.ZHUNTER_DESC = "Various features to make a hunter's life easier"
-- German / Deutsch
elseif MTH.currentLocale == "deDE" then
L.FEEDOMATIC_NAME = "Futter-O-Mat"
L.ZHUNTER_NAME = "zhunter"
L.TOOLTIPS_OPTION_FOOD = "Add tooltips on food"
L.TOOLTIPS_OPTION_FOOD_HELP = "Show your current pet's food preference directly in item tooltips."
L.TOOLTIPS_OPTION_OWNPET = "Activate on my pet"
L.TOOLTIPS_OPTION_OWNPET_HELP = "Show your own pet status details in tooltip when hovering your pet context."
L.TOOLTIPS_FOOD_QUALITY_UNKNOWN = "%s can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_QUALITY_UNDER = "%s doesn't like this anymore."
L.TOOLTIPS_FOOD_QUALITY_MIGHT = "%s might eat this."
L.TOOLTIPS_FOOD_QUALITY_WILL = "%s will eat this."
L.TOOLTIPS_FOOD_QUALITY_LIKE = "%s likes to eat this."
L.TOOLTIPS_FOOD_QUALITY_LOVE = "%s loves to eat this."
L.TOOLTIPS_FOOD_MARKER_UNKNOWN = "can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_MARKER_UNDER = "doesn't like this anymore."
L.TOOLTIPS_FOOD_MARKER_MIGHT = "might eat this."
L.TOOLTIPS_FOOD_MARKER_WILL = "will eat this."
L.TOOLTIPS_FOOD_MARKER_LIKE = "likes to eat this."
L.TOOLTIPS_FOOD_MARKER_LOVE = "loves to eat this."
-- French / Français
elseif MTH.currentLocale == "frFR" then
L.FEEDOMATIC_NAME = "Nourricier"
L.ZHUNTER_NAME = "zhunter"
L.TOOLTIPS_OPTION_FOOD = "Add tooltips on food"
L.TOOLTIPS_OPTION_FOOD_HELP = "Show your current pet's food preference directly in item tooltips."
L.TOOLTIPS_OPTION_OWNPET = "Activate on my pet"
L.TOOLTIPS_OPTION_OWNPET_HELP = "Show your own pet status details in tooltip when hovering your pet context."
L.TOOLTIPS_FOOD_QUALITY_UNKNOWN = "%s can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_QUALITY_UNDER = "%s doesn't like this anymore."
L.TOOLTIPS_FOOD_QUALITY_MIGHT = "%s might eat this."
L.TOOLTIPS_FOOD_QUALITY_WILL = "%s will eat this."
L.TOOLTIPS_FOOD_QUALITY_LIKE = "%s likes to eat this."
L.TOOLTIPS_FOOD_QUALITY_LOVE = "%s loves to eat this."
L.TOOLTIPS_FOOD_MARKER_UNKNOWN = "can eat this, but hasn't tried it yet."
L.TOOLTIPS_FOOD_MARKER_UNDER = "doesn't like this anymore."
L.TOOLTIPS_FOOD_MARKER_MIGHT = "might eat this."
L.TOOLTIPS_FOOD_MARKER_WILL = "will eat this."
L.TOOLTIPS_FOOD_MARKER_LIKE = "likes to eat this."
L.TOOLTIPS_FOOD_MARKER_LOVE = "loves to eat this."
local MTH_SUPPORTED_LOCALES = {
enUS = true,
deDE = true,
esES = true,
ptBR = true,
ruRU = true,
zhCN = true,
}
local function MTH_ResolveLocale(locale)
local resolved = tostring(locale or "enUS")
if MTH_LOCALE_ALIASES[resolved] then
resolved = MTH_LOCALE_ALIASES[resolved]
end
if not MTH_SUPPORTED_LOCALES[resolved] then
resolved = "enUS"
end
return resolved
end
MTH.localization[MTH.currentLocale] = L
local activeLocale = MTH_ResolveLocale(MTH.currentLocale)
local localeData = MTH_LocaleData or {}
local uiLocales = localeData.ui or {}
local uiDefault = uiLocales.enUS or {}
local uiActive = uiLocales[activeLocale] or {}
-- Get localized string
function MTH:GetLocalization(key, default)
if L[key] then
return L[key]
local function MTH_L(key, default)
if uiActive[key] ~= nil then
return uiActive[key]
end
if uiDefault[key] ~= nil then
return uiDefault[key]
end
return default or key
end
MTH.localization[activeLocale] = uiActive
MTH.localization.enUS = uiDefault
BINDING_HEADER_FEEDOMATIC = MTH_L("BINDING_HEADER_FEEDOMATIC", "[MetaHunt] Feed-O-Matic")
BINDING_HEADER_ZAspectHeader = MTH_L("BINDING_HEADER_ZAspectHeader", "[MetaHunt] ZAspect Buttons")
BINDING_HEADER_ZTrackHeader = MTH_L("BINDING_HEADER_ZTrackHeader", "[MetaHunt] ZTrack Buttons")
BINDING_HEADER_ZTrapHeader = MTH_L("BINDING_HEADER_ZTrapHeader", "[MetaHunt] ZTrap Buttons")
BINDING_HEADER_ZPetHeader = MTH_L("BINDING_HEADER_ZPetHeader", "[MetaHunt] ZPet Buttons")
BINDING_HEADER_ZAmmoHeader = MTH_L("BINDING_HEADER_ZAmmoHeader", "[MetaHunt] ZAmmo Buttons")
function MTH:GetLocalization(key, default)
return MTH_L(key, default)
end
local function MTH_GetLocaleVendorNameMap(locale)
local dataLocales = (MTH_LocaleData and MTH_LocaleData.data) or nil
local vendorLocales = dataLocales and dataLocales.vendors or nil
if type(vendorLocales) ~= "table" then
return nil
end
return vendorLocales[locale]
end
local function MTH_GetLocaleItemNameMap(locale)
local dataLocales = (MTH_LocaleData and MTH_LocaleData.data) or nil
local itemLocales = dataLocales and dataLocales.items or nil
if type(itemLocales) ~= "table" then
return nil
end
return itemLocales[locale]
end
local function MTH_GetLocaleBeastNameMap(locale)
local dataLocales = (MTH_LocaleData and MTH_LocaleData.data) or nil
if type(dataLocales) ~= "table" then
MTH_LocaleData = MTH_LocaleData or {}
MTH_LocaleData.data = MTH_LocaleData.data or {}
dataLocales = MTH_LocaleData.data
end
local beastLocales = dataLocales and dataLocales.beasts or nil
if type(beastLocales) ~= "table" then
dataLocales.beasts = {}
beastLocales = dataLocales.beasts
end
if locale == "enUS" then
local enMap = beastLocales.enUS
if type(enMap) ~= "table" then
enMap = {}
beastLocales.enUS = enMap
end
if next(enMap) == nil then
local beasts = _G and _G.MTH_DS_Beasts or MTH_DS_Beasts
if type(beasts) == "table" then
for beastId, beast in pairs(beasts) do
local id = tonumber(beastId)
local name = type(beast) == "table" and tostring(beast.name or "") or ""
if id and name ~= "" and enMap[id] == nil then
enMap[id] = name
end
end
end
end
end
return beastLocales[locale]
end
function MTH:GetLocalizedVendorName(vendorId, defaultName)
local id = tonumber(vendorId)
if not id then
return defaultName or "Unknown"
end
local locale = MTH_ResolveLocale(self.currentLocale or GetLocale() or "enUS")
local localeMap = MTH_GetLocaleVendorNameMap(locale)
if localeMap and localeMap[id] and localeMap[id] ~= "" then
return localeMap[id]
end
local fallbackMap = MTH_GetLocaleVendorNameMap("enUS")
if fallbackMap and fallbackMap[id] and fallbackMap[id] ~= "" then
return fallbackMap[id]
end
return defaultName or "Unknown"
end
function MTH:GetLocalizedNPCNameById(npcId, defaultName)
return self:GetLocalizedVendorName(npcId, defaultName)
end
function MTH:GetLocalizedItemName(itemId, defaultName)
local id = tonumber(itemId)
if not id then
return defaultName or "Unknown"
end
local locale = MTH_ResolveLocale(self.currentLocale or GetLocale() or "enUS")
local localeMap = MTH_GetLocaleItemNameMap(locale)
if localeMap and localeMap[id] and localeMap[id] ~= "" then
return localeMap[id]
end
local fallbackMap = MTH_GetLocaleItemNameMap("enUS")
if fallbackMap and fallbackMap[id] and fallbackMap[id] ~= "" then
return fallbackMap[id]
end
return defaultName or "Unknown"
end
function MTH:GetLocalizedBeastName(beastId, defaultName)
local id = tonumber(beastId)
if not id then
return defaultName or "Unknown"
end
local locale = MTH_ResolveLocale(self.currentLocale or GetLocale() or "enUS")
local localeMap = MTH_GetLocaleBeastNameMap(locale)
if localeMap and localeMap[id] and localeMap[id] ~= "" then
return localeMap[id]
end
local fallbackMap = MTH_GetLocaleBeastNameMap("enUS")
if fallbackMap and fallbackMap[id] and fallbackMap[id] ~= "" then
return fallbackMap[id]
end
return defaultName or "Unknown"
end
-- Module localization helper
function MTH:RegisterModuleLocalization(module_name, localizationTable)
if not self.localization.modules then
@@ -118,60 +189,146 @@ function MTH:GetModuleLocalization(module_name, key, default)
end
local MTH_SPELL_LOCALE = {
enUS = {
["Banish"] = "Banish",
["Bestial Wrath"] = "Bestial Wrath",
["Concussive Shot"] = "Concussive Shot",
["Counterattack"] = "Counterattack",
["Critical Mass"] = "Critical Mass",
["Clever Traps"] = "Clever Traps",
["Deterrence"] = "Deterrence",
["Explosive Trap"] = "Explosive Trap",
["Explosive Trap Effect"] = "Explosive Trap Effect",
["Feed Pet"] = "Feed Pet",
["Flare"] = "Flare",
["Freezing Trap"] = "Freezing Trap",
["Freezing Trap Effect"] = "Freezing Trap Effect",
["Frost Trap"] = "Frost Trap",
["Frost Trap Aura"] = "Frost Trap Aura",
["Hunter's Mark"] = "Hunter's Mark",
["Holy Strength"] = "Holy Strength",
["Immolation Trap"] = "Immolation Trap",
["Immolation Trap Effect"] = "Immolation Trap Effect",
["Improved Concussive Shot"] = "Improved Concussive Shot",
["Improved Wing Clip"] = "Improved Wing Clip",
["Perception"] = "Perception",
["Piercing Shot"] = "Piercing Shot",
["Piercing Shots"] = "Piercing Shots",
["Quick Shots"] = "Quick Shots",
["Rapid Fire"] = "Rapid Fire",
["Scare Beast"] = "Scare Beast",
["Scatter Shot"] = "Scatter Shot",
["Scorpid Poison"] = "Scorpid Poison",
["Scorpid Sting"] = "Scorpid Sting",
["Serpent Sting"] = "Serpent Sting",
["Stoneform"] = "Stoneform",
["Unstable Power"] = "Unstable Power",
["Ephemeral Power"] = "Ephemeral Power",
["Viper Sting"] = "Viper Sting",
["War Stomp"] = "War Stomp",
["Will of the Forsaken"] = "Will of the Forsaken",
["Wing Clip"] = "Wing Clip",
["Wyvern Sting"] = "Wyvern Sting",
["Blood Fury"] = "Blood Fury",
["Berserking"] = "Berserking",
},
}
local MTH_SPELL_ID_BY_TOKEN = {
["Banish"] = 710,
["Bestial Wrath"] = 19574,
["Concussive Shot"] = 5116,
["Counterattack"] = 19306,
["Clever Traps"] = 19239,
["Deterrence"] = 19263,
["Explosive Trap"] = 13813,
["Explosive Trap Effect"] = 13812,
["Feed Pet"] = 6991,
["Flare"] = 1543,
["Freezing Trap"] = 1499,
["Freezing Trap Effect"] = 3355,
["Frost Trap"] = 13809,
["Frost Trap Aura"] = 13810,
["Hunter's Mark"] = 1130,
["Immolation Trap"] = 13795,
["Immolation Trap Effect"] = 13797,
["Improved Concussive Shot"] = 19407,
["Improved Wing Clip"] = 19229,
["Perception"] = 20600,
["Rapid Fire"] = 3045,
["Scare Beast"] = 1513,
["Scatter Shot"] = 19503,
["Scorpid Sting"] = 3043,
["Serpent Sting"] = 1978,
["Stoneform"] = 20594,
["Viper Sting"] = 3034,
["War Stomp"] = 20549,
["Will of the Forsaken"] = 7744,
["Wing Clip"] = 2974,
["Wyvern Sting"] = 19386,
["Blood Fury"] = 20572,
["Berserking"] = 26297,
}
do
local spellLocales = (MTH_LocaleData and MTH_LocaleData.spells) or nil
if type(spellLocales) == "table" then
for localeKey, localeMap in pairs(spellLocales) do
if type(localeMap) == "table" then
MTH_SPELL_LOCALE[localeKey] = localeMap
end
end
end
end
do
local extras = {
enUS = {
["Devilsaur Eye"] = "Devilsaur Eye",
["Devilsaur Fury"] = "Devilsaur Fury",
["Zandalarian Hero Medallion"] = "Zandalarian Hero Medallion",
["Restless Strength"] = "Restless Strength",
["Earthstrike"] = "Earthstrike",
["Badge of the Swarmguard"] = "Badge of the Swarmguard",
["Jom Gabbar"] = "Jom Gabbar",
["Kiss of the Spider"] = "Kiss of the Spider",
["Slayer's Crest"] = "Slayer's Crest",
},
deDE = {
["Devilsaur Eye"] = "Auge eines Teufelssauriers",
["Devilsaur Fury"] = "Zorn des Teufelssauriers",
["Zandalarian Hero Medallion"] = "Zandalarianisches Heldenmedallion",
["Restless Strength"] = "Ruhelose Stärke",
["Earthstrike"] = "Erdschlag",
["Badge of the Swarmguard"] = "Abzeichen der Schwarmwache",
["Jom Gabbar"] = "Jom Gabbar",
["Kiss of the Spider"] = "Kuss der Spinne",
["Slayer's Crest"] = "Jägerspitze",
},
esES = {
["Devilsaur Eye"] = "Ojo de Demosaurio",
["Devilsaur Fury"] = "Furia del devilsaurio",
["Zandalarian Hero Medallion"] = "Zandalarian Hero Medallion",
["Restless Strength"] = "Fuerza agitada",
["Earthstrike"] = "Golpeterra",
["Badge of the Swarmguard"] = "Badge of the Swarmguard",
["Jom Gabbar"] = "Jom Gabbar",
["Kiss of the Spider"] = "Kiss of the Spider",
["Slayer's Crest"] = "Cresta de Matador",
},
frFR = {
["Devilsaur Eye"] = "Oeil de diablosaure",
["Devilsaur Fury"] = "Fureur du diablosaure",
["Zandalarian Hero Medallion"] = "Médaillon de héros zandalarien",
["Restless Strength"] = "Force inconstante",
["Earthstrike"] = "Choc de terre",
["Badge of the Swarmguard"] = "Insigne de garde-essaim",
["Jom Gabbar"] = "Jom Gabbar",
["Kiss of the Spider"] = "Baiser de l'araignée",
["Slayer's Crest"] = "Ecusson de tueur",
},
zhCN = {
["Devilsaur Eye"] = "魔暴龙眼",
["Devilsaur Fury"] = "魔暴龙之怒",
["Zandalarian Hero Medallion"] = "赞达拉英雄徽记",
["Restless Strength"] = "充沛之力",
["Earthstrike"] = "大地之击",
["Badge of the Swarmguard"] = "虫群守卫徽章",
["Jom Gabbar"] = "Jom Gabbar",
["Kiss of the Spider"] = "蜘蛛之吻",
["Slayer's Crest"] = "屠戮者徽记",
},
}
for localeKey, localeMap in pairs(extras) do
if type(MTH_SPELL_LOCALE[localeKey]) ~= "table" then
MTH_SPELL_LOCALE[localeKey] = {}
end
for token, localized in pairs(localeMap) do
if MTH_SPELL_LOCALE[localeKey][token] == nil then
MTH_SPELL_LOCALE[localeKey][token] = localized
end
end
end
end
MTH.Const = MTH.Const or {}
MTH.Const.SpellLocaleMap = MTH_SPELL_LOCALE
MTH.Const.NPCLocaleMap = (MTH_LocaleData and MTH_LocaleData.data and MTH_LocaleData.data.vendors) or {}
MTH.Const.ItemLocaleMap = (MTH_LocaleData and MTH_LocaleData.data and MTH_LocaleData.data.items) or {}
MTH.Const.BeastLocaleMap = (MTH_LocaleData and MTH_LocaleData.data and MTH_LocaleData.data.beasts) or {}
function MTH:LocalizeSpell(spellToken)
local key = tostring(spellToken or "")
if key == "" then
return key
end
local locale = tostring(self.currentLocale or GetLocale() or "enUS")
local getSpellInfo = _G and _G["GetSpellInfo"] or nil
local spellId = MTH_SPELL_ID_BY_TOKEN[key]
if spellId and getSpellInfo then
local spellName = getSpellInfo(spellId)
if spellName and spellName ~= "" then
return spellName
end
end
local locale = MTH_ResolveLocale(self.currentLocale or GetLocale() or "enUS")
local localeMap = MTH_SPELL_LOCALE[locale] or MTH_SPELL_LOCALE.enUS
if localeMap and localeMap[key] then
return localeMap[key]