local addonName, addon = ...

-- Data table for all languages
local locales = {
    enUS = {
        LOADED_MESSAGE = "Loaded. Hover over players to see GS/iLvl.",
        LOADING = "Loading...",
        WAITING_FOR_INSPECT = "Waiting for Inspect...",
        PARSING_ITEMS = "Parsing Items...",
        GEARSCORE_LABEL = "GearScore:",
        ITEM_LEVEL_LABEL = "Item Level:",
        TALENTS_LABEL = "Talents:",
        OPTIONS_TITLE = "RLGearscore Options",
        ENABLE_GS = "Show GearScore",
        ENABLE_ILVL = "Show Item Level",
        ENABLE_TALENTS = "Show Talents",
        ENABLE_AUTO_INSPECT = "Auto Inspect",
        LANGUAGE = "Language",
        MINIMAP_BUTTON_TOOLTIP = "Left Click: Open Settings",
        TAB_SETTINGS = "Settings",
        TAB_ABOUT = "About",
        COPYRIGHT_HEADER = "Copyright / Contact",
        CREDITS_HEADER = "Credits / Thanks",
        CREDITS_TEXT = "Special thanks to ZamestoTV (Hubbotu) for the translations.\n\nHubbotu's source:",
        ABOUT_CONTACT_INFO = "Xarmina (Robin Oliver) Lucas\nSchwarzbach 148\n42277 Wuppertal\nGermany\n\nE-Mail: me@xarmina.eu"
    },
    deDE = {
        LOADED_MESSAGE = "Geladen. Fahre mit der Maus über Spieler, um GS/iLvl zu sehen.",
        LOADING = "Laden...",
        WAITING_FOR_INSPECT = "Warte auf Inspektion...",
        PARSING_ITEMS = "Gegenstände werden analysiert...",
        GEARSCORE_LABEL = "GearScore:",
        ITEM_LEVEL_LABEL = "Gegenstandsstufe:",
        TALENTS_LABEL = "Talente:",
        OPTIONS_TITLE = "RLGearscore Einstellungen",
        ENABLE_GS = "GearScore anzeigen",
        ENABLE_ILVL = "Gegenstandsstufe anzeigen",
        ENABLE_TALENTS = "Talente anzeigen",
        ENABLE_AUTO_INSPECT = "Automatisch inspizieren",
        LANGUAGE = "Sprache",
        MINIMAP_BUTTON_TOOLTIP = "Linksklick: Einstellungen öffnen",
        TAB_SETTINGS = "Einstellungen",
        TAB_ABOUT = "Über",
        COPYRIGHT_HEADER = "Impressum / Kontakt",
        CREDITS_HEADER = "Danksagung",
        CREDITS_TEXT = "Besonderen Dank an ZamestoTV (Hubbotu) für die Übersetzungen.\n\nHubbotus Quelle:",
        ABOUT_CONTACT_INFO = "Xarmina (Robin Oliver) Lucas\nSchwarzbach 148\n42277 Wuppertal\nDeutschland\n\nE-Mail: me@xarmina.eu"
    },
    ruRU = {
        LOADED_MESSAGE = "Загружен. Наведите на игрока для просмотра GS/iLvl.",
        LOADING = "Загрузка...",
        WAITING_FOR_INSPECT = "Ожидание осмотра...",
        PARSING_ITEMS = "Чтение предметов...",
        GEARSCORE_LABEL = "GS:",
        ITEM_LEVEL_LABEL = "Средний iLvl:",
        TALENTS_LABEL = "Таланты:",
        OPTIONS_TITLE = "Настройки RLGearscore",
        ENABLE_GS = "Отображать GearScore",
        ENABLE_ILVL = "Отображать уровень предметов",
        ENABLE_TALENTS = "Отображать таланты 0/0/0",
        ENABLE_AUTO_INSPECT = "Авто-осмотр",
        LANGUAGE = "Язык",
        MINIMAP_BUTTON_TOOLTIP = "ЛКМ: Открыть настройки",
        TAB_SETTINGS = "Настройки",
        TAB_ABOUT = "Об аддоне",
        COPYRIGHT_HEADER = "Авторское право / Контакты",
        CREDITS_HEADER = "Благодарности",
        CREDITS_TEXT = "Особая благодарность ZamestoTV (Hubbotu) за переводы.\n\nИсточник Hubbotu:",
        ABOUT_CONTACT_INFO = "Copyright © Robin Oliver Lucas\nSchwarzbach 148\n42277 Wuppertal\nГермания\n\nE-mail: me@xarmina.eu\nПожертвования (PayPal): me@xarmina.eu\nБаг-трекер: https://rl-dev.de/bugtracker.html"
    }
}

addon.locales = locales

-- Function to set language
function addon:SetLanguage(lang)
    -- If lang is "Auto" or nil, use game client language
    if not lang or lang == "Auto" then
        lang = GetLocale()
    end
    
    -- Fallback to enUS if language not supported
    if not locales[lang] then
        lang = "enUS"
    end
    
    addon.L = locales[lang]
    addon.currentLanguage = lang
end

-- Initialize with default (will be overwritten by SavedVariables later)
addon:SetLanguage(GetLocale())
