Quantcast

Handle unknown locales, better structure.

Jamie Schembri [02-06-14 - 21:19]
Handle unknown locales, better structure.
Filename
core.lua
diff --git a/core.lua b/core.lua
index 9d6fb83..c6855a6 100644
--- a/core.lua
+++ b/core.lua
@@ -1,20 +1,35 @@
-local L = {
-  enUS = "Fishing Bobber",
-  deDE = "Angelschwimmer",
-  esES = "Corcho de pesca",
-  frFR = "Flotteur",
-  ruRU = "поплавок",
-  ptBR = "Flutador para Pesca"
-}
+local frame = CreateFrame("Frame")

-GameTooltip:HookScript("OnShow", function()
-  local localized = L[GetLocale()]
+frame:RegisterEvent("PLAYER_LOGIN")
+frame:SetScript("OnEvent", function()
+  local L = {
+    deDE = "Angelschwimmer",
+    enUS = "Fishing Bobber",
+    esES = "Corcho de pesca",
+    frFR = "Flotteur",
+    ptBR = "Flutador para Pesca",
+    ruRU = "поплавок"

-  -- don't do anything if we don't have a string for this locale
-  if not localized then return end
+    -- itIT = "",
+    -- esMX = "",
+    -- koKR = "",
+    -- zhCN = "",
+    -- zhTW = "",
+  }
+  local localized = L[GetLocale()]

-  local tooltipText = GameTooltipTextLeft1
-  if tooltipText and tooltipText:GetText() == localized then
-    GameTooltip:Hide()
+  if not localized then
+    print("|cFFFF0000HideFishingBobberTooltip does not work under your locale. " ..
+          "You can help to fix this by leaving a comment on the Curse or " ..
+          "WoWInterface addon page with the name of the fishing bobber in your language.")
+    return
   end
+
+  GameTooltip:HookScript("OnShow", function()
+    local tooltipText = GameTooltipTextLeft1
+    if tooltipText and tooltipText:GetText() == localized then
+      GameTooltip:Hide()
+    end
+  end)
 end)
+