-- Keybinding globals: must be set before Bindings.xml processes
BINDING_HEADER_BPS           = "Battle Pet Statistics"
BINDING_NAME_BPS_FORFEIT     = "Forfeit current pet battle"
BINDING_NAME_BPS_REQUEUE     = "Queue for PvP pet battle"
BINDING_NAME_BPS_ENTERBATTLE = "Accept / Enter pet battle"

BPS_L = {}

local L_EN = {
    -- Battle overlay
    SESSION_TITLE      = "Session:",
    OVERALL            = "Overall : Wins : %d  Lose: %d",
    WINRATE             = "Winrate : %d%%",
    GOAL_LINE           = "Goal: %s (%d/%d)",
    GOAL_DONE_LINE      = "Congratulations, you finished the PvP pet battle achievements.",
    VS                  = "Vs",
    VS_RANDOM            = "Random",
    WIN                 = "Wins",
    LOSE                = "Loses",
    YOU_SHOULD_WIN      = "You should Win",
    YOU_SHOULD_LOSE     = "You should Lose",
    FORFEIT_BUTTON      = "Forfeit",
    REQUEUE_BUTTON      = "Queue Again",

    -- Options
    OPTIONS_TITLE       = "Battle Pet Statistics - Options",
    OPTIONS_TITLE_TAB   = "Options",
    STATS_TITLE_TAB     = "Statistics",
    SESSION_LINE        = "Session: Won: %d  Lost: %d",
    LANGUAGE             = "Language",
    LANG_AUTO            = "Auto (detect)",
    LANG_EN              = "English",
    LANG_FR              = "French",
    LANG_PL              = "Polish",
    LANG_SV              = "Swedish",
    LANG_CS              = "Czech",
    LANG_DE              = "German",
    LANG_IT              = "Italian",
    STATS_TITLE          = "Statistics",
    STATS_GLOBAL_TITLE     = "Global Statistics",
    TOTAL_GAMES             = "Total games: %d",
    TOTAL_WON               = "Won: %d",
    TOTAL_LOST              = "Lost: %d",
    SESSION_COUNT_LINE      = "Number of sessions completed: %d",
    SESSION_CURRENT_TITLE   = "Current session:",
    FAIRPLAY_REFRESH_HINT   = "The ranking may take a few seconds to update.",
    COL_PET              = "Opponent",
    COL_WIN              = "Won",
    COL_LOSE             = "Lost",
    COL_RATIO            = "Ratio",
    COL_WINRATE           = "Winrate",
    FAIRPLAY_TITLE        = "Most fair-play opponents (W/L ratio closest to 1)",
    NO_DATA               = "No data recorded yet.",
    RESET_BUTTON          = "Reset All Stats",
    RESET_CONFIRM         = "Are you sure you want to reset ALL Battle Pet Statistics data?",
    TOTAL                 = "Total games: %d  (Won: %d / Lost: %d)",
    MINIMAP_TOOLTIP        = "Battle Pet Statistics\nClick to open options",
    EDIT_BUTTON            = "Edit",
    EDIT_TITLE             = "Edit stats for %s",
    EDIT_WINS              = "Wins:",
    EDIT_LOSSES            = "Losses:",
    SAVE_BUTTON            = "Save",
    CANCEL_BUTTON          = "Cancel",

    DISPLAY_SECTION_TITLE  = "Battle overlay lines",
    SHOW_OVERALL            = "Show Overall line",
    SHOW_WINRATE             = "Show Winrate line",
    SHOW_GOAL                = "Show Goal line",
    SHOW_VS                  = "Show opponent name line",
    SHOW_VS_STATS            = "Show opponent W/L line",
    SHOW_VS_WINRATE          = "Show opponent winrate line",
    SHOW_PREDICTION          = "Show Win/Lose prediction line",
    SHOW_FORFEIT_BUTTON      = "Show Forfeit button",

    GOAL_SECTION_TITLE      = "Achievement goal",
    GOAL_CURRENT             = "Current goal:",
    GOAL_COMPLETED           = "Completed",
    GOAL_COMPLETED_LIST_TITLE = "Completed achievements:",
    GOAL_NONE_COMPLETED      = "No achievement completed yet.",

    -- Achievement (goal) names - official Blizzard English names
    GOAL_NAME_BRAWLER_10     = "Pet Brawler",
    GOAL_NAME_BRAWLER_50     = "Experienced Pet Brawler",
    GOAL_NAME_BRAWLER_250    = "Master Pet Brawler",
    GOAL_NAME_BRAWLER_1000   = "Grand Master Pet Brawler",
    GOAL_NAME_BRAWLER_5000   = "Legendary Pet Brawler",
    GOAL_NAME_MERCILESS      = "Ruthless Pet Brawler",
    GOAL_NAME_VENGEFUL       = "Vengeful Pet Brawler",
    GOAL_NAME_BRUTAL         = "Brutal Pet Brawler",
    GOAL_NAME_DEADLY         = "Deadly Pet Brawler",

    KEYBIND_SECTION_TITLE   = "Keybindings",
    KEYBIND_HINT             = "Set your keybindings in the standard WoW Key Bindings panel, category \"Battle Pet Statistics\".",
    OPEN_KEYBINDINGS         = "Open Key Bindings",

    -- Trade Win Session section
    TRADEWIN_SECTION_TITLE      = "Trade Win Session",
    TRADEWIN_INTRO              = "Choose one of the following options to automatically rename your pets with your character's name:",
    TRADEWIN_SHOW_STARTUP       = "Show the window at startup",
    TRADEWIN_SHOW_AFTER_BATTLE  = "Show the window after your first battle",
    TRADEWIN_SHOW_NEVER         = "Never show the window",
    TRADEWIN_SHOW_IF_NOT_RENAMED = "Show the window only if your first pet hasn't been renamed yet",
    TRADEWIN_RESTORE_QUESTION   = "When you exit WoW, would you like your current team's pets to be restored to their default names?",
    TRADEWIN_RESTORE_YES        = "Yes",
    TRADEWIN_RESTORE_NO         = "No",

    BIG_CONGRATS             = "Congratulations, you finished the PvP pet battle achievements.",

    -- Alias setup popups
    ALIAS_PROMPT_TITLE          = "Your Alias :",
    ALIAS_VALIDATE               = "Validate",
}

local L_FR = {
    SESSION_TITLE      = "Session :",
    OVERALL            = "Total : Gagnées : %d  Perdues : %d",
    WINRATE             = "Winrate : %d%%",
    GOAL_LINE           = "Objectif : %s (%d/%d)",
    GOAL_DONE_LINE      = "Félicitation vous avez fini les combats de mascottes en Pvp.",
    VS                  = "Vs",
    VS_RANDOM            = "Random",
    WIN                 = "Gagnées",
    LOSE                = "Perdues",
    YOU_SHOULD_WIN      = "Tu dois Gagner",
    YOU_SHOULD_LOSE     = "Tu dois Perdre",
    FORFEIT_BUTTON      = "Abandonner",
    REQUEUE_BUTTON      = "Relancer un combat",

    OPTIONS_TITLE       = "Battle Pet Statistics - Options",
    OPTIONS_TITLE_TAB   = "Options",
    STATS_TITLE_TAB     = "Statistiques",
    SESSION_LINE        = "Session : Gagnées : %d  Perdues : %d",
    LANGUAGE             = "Langue",
    LANG_AUTO            = "Auto (détecter)",
    LANG_EN              = "Anglais",
    LANG_FR              = "Français",
    LANG_PL              = "Polonais",
    LANG_SV              = "Suédois",
    LANG_CS              = "Tchèque",
    LANG_DE              = "Allemand",
    LANG_IT              = "Italien",
    STATS_TITLE          = "Statistiques",
    STATS_GLOBAL_TITLE     = "Statistique Globale",
    TOTAL_GAMES             = "Partie totale : %d",
    TOTAL_WON               = "Gagnées : %d",
    TOTAL_LOST              = "Perdues : %d",
    SESSION_COUNT_LINE      = "Nombre de session effectuées : %d",
    SESSION_CURRENT_TITLE   = "Session actuel :",
    FAIRPLAY_REFRESH_HINT   = "Le classement peut prendre quelques secondes à s'actualiser.",
    COL_PET              = "Adversaire",
    COL_WIN              = "Gagnées",
    COL_LOSE             = "Perdues",
    COL_RATIO            = "Ratio",
    COL_WINRATE           = "Winrate",
    FAIRPLAY_TITLE        = "Adversaires les plus fair-play (ratio G/P le plus proche de 1)",
    NO_DATA               = "Aucune donnée enregistrée pour le moment.",
    RESET_BUTTON          = "Réinitialiser les statistiques",
    RESET_CONFIRM         = "Es-tu sûr de vouloir réinitialiser TOUTES les statistiques de Battle Pet Statistics ?",
    TOTAL                 = "Parties totales : %d  (Gagnées : %d / Perdues : %d)",
    MINIMAP_TOOLTIP        = "Battle Pet Statistics\nClique pour ouvrir les options",
    EDIT_BUTTON            = "Modifier",
    EDIT_TITLE             = "Modifier les stats de %s",
    EDIT_WINS              = "Gagnées :",
    EDIT_LOSSES            = "Perdues :",
    SAVE_BUTTON            = "Enregistrer",
    CANCEL_BUTTON          = "Annuler",

    DISPLAY_SECTION_TITLE  = "Lignes affichées en combat",
    SHOW_OVERALL            = "Afficher la ligne Total",
    SHOW_WINRATE             = "Afficher la ligne Winrate",
    SHOW_GOAL                = "Afficher la ligne Objectif",
    SHOW_VS                  = "Afficher le nom de l'adversaire",
    SHOW_VS_STATS            = "Afficher les G/P contre l'adversaire",
    SHOW_VS_WINRATE          = "Afficher le winrate contre l'adversaire",
    SHOW_PREDICTION          = "Afficher la prédiction Gagner/Perdre",
    SHOW_FORFEIT_BUTTON      = "Afficher le bouton Abandonner",

    GOAL_SECTION_TITLE      = "Objectif (haut faits)",
    GOAL_CURRENT             = "Objectif actuel :",
    GOAL_COMPLETED           = "Terminé",
    GOAL_COMPLETED_LIST_TITLE = "Haut Fait validés :",
    GOAL_NONE_COMPLETED      = "Aucun haut fait validé pour le moment.",

    -- Noms des hauts faits (noms officiels Blizzard en français)
    GOAL_NAME_BRAWLER_10     = "Poids mouche",
    GOAL_NAME_BRAWLER_50     = "Poids coq",
    GOAL_NAME_BRAWLER_250    = "Poids plume",
    GOAL_NAME_BRAWLER_1000   = "Poids léger",
    GOAL_NAME_BRAWLER_5000   = "Poids moyen",
    GOAL_NAME_MERCILESS      = "Dresseur de mascottes impitoyable",
    GOAL_NAME_VENGEFUL       = "Dresseur de mascottes Vengeur",
    GOAL_NAME_BRUTAL         = "Dresseur de mascottes brutal",
    GOAL_NAME_DEADLY         = "Dresseur de mascottes fatal",

    KEYBIND_SECTION_TITLE   = "Raccourcis clavier",
    KEYBIND_HINT             = "Définis tes raccourcis dans le panneau standard de WoW (Touches), catégorie \"Battle Pet Statistics\".",
    OPEN_KEYBINDINGS         = "Ouvrir les raccourcis",

    -- Section Trade Win Session
    TRADEWIN_SECTION_TITLE      = "Session Trade Win",
    TRADEWIN_INTRO              = "Choisis l'une des options suivantes pour renommer automatiquement tes mascottes avec le nom de ton personnage :",
    TRADEWIN_SHOW_STARTUP       = "Afficher la fenêtre au démarrage",
    TRADEWIN_SHOW_AFTER_BATTLE  = "Afficher la fenêtre après ton premier combat",
    TRADEWIN_SHOW_NEVER         = "Ne jamais afficher la fenêtre",
    TRADEWIN_SHOW_IF_NOT_RENAMED = "Afficher la fenêtre seulement si ta première mascotte n'a pas encore été renommée",
    TRADEWIN_RESTORE_QUESTION   = "Quand tu quittes WoW, veux-tu que les mascottes de ton équipe actuelle retrouvent leur nom par défaut ?",
    TRADEWIN_RESTORE_YES        = "Oui",
    TRADEWIN_RESTORE_NO         = "Non",

    BIG_CONGRATS             = "Félicitation vous avez fini les combats de mascottes en Pvp.",

    ALIAS_PROMPT_TITLE          = "Ton pseudo :",
    ALIAS_VALIDATE               = "Valider",
}

BPS_L.EN = L_EN
BPS_L.FR = L_FR

-- ===================== New languages =====================
-- Only the battle-overlay strings were provided by the user (native speakers).
-- Everything else (Options tab, popups, etc.) falls back to English below via
-- setmetatable, so nothing is ever missing or guessed.

local L_PL = {
    OVERALL          = "Wszystkie wygrane: %d  wszystkie przegrane: %d",
    WINRATE          = "Procent wygranych: %d%%",
    GOAL_LINE        = "Cel: %s (%d/%d)",
    VS               = "Przeciw",
    WIN              = "Wygrane",
    LOSE             = "Przegrane",
    YOU_SHOULD_WIN   = "Powinieneś wygrać",
    YOU_SHOULD_LOSE  = "Powinieneś przegrać",
    LANG_PL          = "Polski",
}

local L_SV = {
    OVERALL          = "Totalt: Vinster %d  Förluster: %d",
    WINRATE          = "Vinstprocent: %d%%",
    GOAL_LINE        = "Mål: %s (%d/%d)",
    VS               = "Mot",
    WIN              = "Vinster",
    LOSE             = "Förluster",
    YOU_SHOULD_WIN   = "Du bör vinna",
    YOU_SHOULD_LOSE  = "Du bör förlora",
    LANG_SV          = "Svenska",
}

local L_CS = {
    OVERALL          = "Celkem: Výhry %d  Prohry: %d",
    WINRATE          = "Úspěšnost: %d%%",
    GOAL_LINE        = "Cíl: %s (%d/%d)",
    VS               = "Proti",
    WIN              = "Výhry",
    LOSE             = "Prohry",
    YOU_SHOULD_WIN   = "Měl bys vyhrát",
    YOU_SHOULD_LOSE  = "Měl bys prohrát",
    LANG_CS          = "Čeština",
}

-- German and Italian: no native translation was provided for the overlay
-- strings, so these currently mirror English until real translations are
-- supplied. They still exist as selectable languages so the structure is
-- ready to receive proper text.
local L_DE = {
    LANG_DE          = "Deutsch",
}

local L_IT = {
    LANG_IT          = "Italiano",
}

BPS_L.PL = L_PL
BPS_L.SV = L_SV
BPS_L.CS = L_CS
BPS_L.DE = L_DE
BPS_L.IT = L_IT

-- Any key missing from a non-English table silently falls back to the
-- English string, so partially-translated languages never show blanks.
for _, tbl in pairs({ L_PL, L_SV, L_CS, L_DE, L_IT }) do
    setmetatable(tbl, { __index = L_EN })
end

function BPS_GetLocale()
    local mode = BattlePetStatisticsDB and BattlePetStatisticsDB.language or "AUTO"

    if mode == "EN" then return L_EN end
    if mode == "FR" then return L_FR end
    if mode == "PL" then return L_PL end
    if mode == "SV" then return L_SV end
    if mode == "CS" then return L_CS end
    if mode == "DE" then return L_DE end
    if mode == "IT" then return L_IT end

    -- AUTO: fall back to the client's locale. Swedish and Czech have no
    -- official WoW client locale, so they can only be picked manually.
    local clientLocale = GetLocale()
    if clientLocale == "frFR" then return L_FR end
    if clientLocale == "plPL" then return L_PL end
    if clientLocale == "deDE" then return L_DE end
    if clientLocale == "itIT" then return L_IT end
    return L_EN
end
