/* i18n compartido para hub, panel, login/registro (la wiki tiene su propio diccionario
   pero comparte la MISMA cookie 'lang', así el idioma se recuerda en todo el sitio). */
(function () {
  var DICT = {
    es: {
      brandSub:"Minecraft Plugins", navHubPlugins:"Plugins", navMyPanel:"Mi panel",
      navLogin:"Entrar", navRegister:"Crear cuenta", navLogout:"Salir",
      hubTitle:"Minecraft Plugins",
      hubIntro:"Plugins premium y gratuitos para tu servidor. Crea tu cuenta para descargar builds y dejar reseñas.",
      hubTagSlot:"Casino · tragamonedas con jackpot", hubBadgeFP:"Free + Premium",
      hubDesc:"Tragamonedas reales construidas con un tocadiscos y 3 marcos. Premios en dinero vía Vault.",
      hubBtnView:"Ver plugin · descargar · comprar", hubMoreT:"Más plugins", hubMoreD:"En camino",
      hubMoreP:"Pronto se sumarán más plugins de infinity3113 a este hub.",
      hubRevFirst:"Sé el primero en reseñar", hubRevWord:"reseñas",
      sideHi:"Hola", sideNoPrem:"Aún no tienes plugins Premium.",
      navMyPlugins:"Mis plugins", navMyLicenses:"Mis licencias", navStore:"Tienda",
      panelEyebrow:"Mi biblioteca", panelTitle:"Mis plugins",
      panelIntro:"Aquí están los plugins que compraste y descargaste. Descárgalos cuando quieras.",
      panelEmpty:"Aún no tienes plugins. Abre la wiki de un plugin y descárgalo o cómpralo.",
      panelUpd:"Descarga la última versión abajo.",
      panelWiki:"Ver wiki / novedades →",
      tagPremium:"Premium", tagFree:"Free", tagUpdate:"Actualización", tagHaveLatest:"tienes la última",
      btnDlPrem:"Descargar Premium", btnDlFree:"Descargar Free",
      licEyebrow:"Cuenta", licTitle:"Mis licencias", licIntro:"Cada plugin Premium tiene su propia licencia.",
      licKey:"Llave de licencia", licActivated:"Activada el", licOrders:"Mis pedidos",
      licNone:"Aún no tienes licencias Premium. Abre la wiki de un plugin para comprar.",
      loginTitle:"Entrar", loginSub:"Accede a tus descargas y licencias.",
      loginUser:"Usuario o correo", loginPass:"Contraseña", loginBtn:"Entrar",
      loginAlt:"¿No tienes cuenta?", loginAltLink:"Crea una",
      regTitle:"Crear cuenta", regSub:"Regístrate para descargar plugins y dejar reseñas.",
      regUser:"Usuario", regEmail:"Correo", regPass:"Contraseña", regBtn:"Crear cuenta",
      regAlt:"¿Ya tienes cuenta?", regAltLink:"Entra aquí"
    },
    en: {
      brandSub:"Minecraft Plugins", navHubPlugins:"Plugins", navMyPanel:"My panel",
      navLogin:"Log in", navRegister:"Sign up", navLogout:"Log out",
      hubTitle:"Minecraft Plugins",
      hubIntro:"Premium and free plugins for your server. Create an account to download builds and leave reviews.",
      hubTagSlot:"Casino · slots with jackpot", hubBadgeFP:"Free + Premium",
      hubDesc:"Real slot machines built from a Jukebox and 3 Item Frames. Money prizes via Vault.",
      hubBtnView:"View plugin · download · buy", hubMoreT:"More plugins", hubMoreD:"Coming soon",
      hubMoreP:"More infinity3113 plugins will join this hub soon.",
      hubRevFirst:"Be the first to review", hubRevWord:"reviews",
      sideHi:"Hi", sideNoPrem:"You don't have Premium plugins yet.",
      navMyPlugins:"My plugins", navMyLicenses:"My licenses", navStore:"Store",
      panelEyebrow:"My library", panelTitle:"My plugins",
      panelIntro:"Here are the plugins you bought and downloaded. Download them anytime.",
      panelEmpty:"You don't have any plugins yet. Open a plugin's wiki to download or buy it.",
      panelUpd:"Download the latest version below.",
      panelWiki:"View wiki / what's new →",
      tagPremium:"Premium", tagFree:"Free", tagUpdate:"Update", tagHaveLatest:"you have the latest",
      btnDlPrem:"Download Premium", btnDlFree:"Download Free",
      licEyebrow:"Account", licTitle:"My licenses", licIntro:"Each Premium plugin has its own license.",
      licKey:"License key", licActivated:"Activated on", licOrders:"My orders",
      licNone:"You don't have Premium licenses yet. Open a plugin's wiki to buy.",
      loginTitle:"Log in", loginSub:"Access your downloads and licenses.",
      loginUser:"Username or email", loginPass:"Password", loginBtn:"Log in",
      loginAlt:"No account yet?", loginAltLink:"Create one",
      regTitle:"Sign up", regSub:"Register to download plugins and leave reviews.",
      regUser:"Username", regEmail:"Email", regPass:"Password", regBtn:"Sign up",
      regAlt:"Already have an account?", regAltLink:"Log in here"
    },
    fr: {
      brandSub:"Plugins Minecraft", navHubPlugins:"Plugins", navMyPanel:"Mon espace",
      navLogin:"Se connecter", navRegister:"S'inscrire", navLogout:"Déconnexion",
      hubTitle:"Plugins Minecraft",
      hubIntro:"Plugins premium et gratuits pour votre serveur. Créez un compte pour télécharger et laisser des avis.",
      hubTagSlot:"Casino · machines à sous avec jackpot", hubBadgeFP:"Gratuit + Premium",
      hubDesc:"De vraies machines à sous avec un juke-box et 3 cadres. Gains en argent via Vault.",
      hubBtnView:"Voir le plugin · télécharger · acheter", hubMoreT:"Plus de plugins", hubMoreD:"Bientôt",
      hubMoreP:"D'autres plugins d'infinity3113 rejoindront bientôt ce hub.",
      hubRevFirst:"Soyez le premier à donner un avis", hubRevWord:"avis",
      sideHi:"Salut", sideNoPrem:"Vous n'avez pas encore de plugins Premium.",
      navMyPlugins:"Mes plugins", navMyLicenses:"Mes licences", navStore:"Boutique",
      panelEyebrow:"Ma bibliothèque", panelTitle:"Mes plugins",
      panelIntro:"Voici les plugins que vous avez achetés et téléchargés. Téléchargez-les quand vous voulez.",
      panelEmpty:"Vous n'avez pas encore de plugins. Ouvrez la wiki d'un plugin pour le télécharger ou l'acheter.",
      panelUpd:"Téléchargez la dernière version ci-dessous.",
      panelWiki:"Voir la wiki / nouveautés →",
      tagPremium:"Premium", tagFree:"Gratuit", tagUpdate:"Mise à jour", tagHaveLatest:"vous avez la dernière",
      btnDlPrem:"Télécharger Premium", btnDlFree:"Télécharger Gratuit",
      licEyebrow:"Compte", licTitle:"Mes licences", licIntro:"Chaque plugin Premium a sa propre licence.",
      licKey:"Clé de licence", licActivated:"Activée le", licOrders:"Mes commandes",
      licNone:"Vous n'avez pas encore de licences Premium. Ouvrez la wiki d'un plugin pour acheter.",
      loginTitle:"Se connecter", loginSub:"Accédez à vos téléchargements et licences.",
      loginUser:"Utilisateur ou e-mail", loginPass:"Mot de passe", loginBtn:"Se connecter",
      loginAlt:"Pas de compte ?", loginAltLink:"Créez-en un",
      regTitle:"S'inscrire", regSub:"Inscrivez-vous pour télécharger des plugins et laisser des avis.",
      regUser:"Utilisateur", regEmail:"E-mail", regPass:"Mot de passe", regBtn:"S'inscrire",
      regAlt:"Déjà un compte ?", regAltLink:"Connectez-vous"
    },
    zh: {
      brandSub:"Minecraft 插件", navHubPlugins:"插件", navMyPanel:"我的面板",
      navLogin:"登录", navRegister:"注册", navLogout:"退出",
      hubTitle:"Minecraft 插件",
      hubIntro:"为你的服务器提供高级版和免费插件。注册账号即可下载并留下评价。",
      hubTagSlot:"赌场 · 带头奖的老虎机", hubBadgeFP:"免费 + 高级版",
      hubDesc:"用唱片机和 3 个物品展示框搭建的真正老虎机。通过 Vault 派发金钱奖励。",
      hubBtnView:"查看插件 · 下载 · 购买", hubMoreT:"更多插件", hubMoreD:"即将推出",
      hubMoreP:"infinity3113 的更多插件即将加入本站。",
      hubRevFirst:"来做第一个评价的人", hubRevWord:"条评价",
      sideHi:"你好", sideNoPrem:"你还没有高级版插件。",
      navMyPlugins:"我的插件", navMyLicenses:"我的授权", navStore:"商店",
      panelEyebrow:"我的库", panelTitle:"我的插件",
      panelIntro:"这里是你购买和下载的插件。随时可以下载。",
      panelEmpty:"你还没有任何插件。打开某个插件的 wiki 去下载或购买。",
      panelUpd:"在下方下载最新版本。",
      panelWiki:"查看 wiki / 更新 →",
      tagPremium:"高级版", tagFree:"免费", tagUpdate:"更新", tagHaveLatest:"你已是最新",
      btnDlPrem:"下载高级版", btnDlFree:"下载免费版",
      licEyebrow:"账户", licTitle:"我的授权", licIntro:"每个高级版插件都有自己的授权。",
      licKey:"授权密钥", licActivated:"激活于", licOrders:"我的订单",
      licNone:"你还没有高级版授权。打开某个插件的 wiki 去购买。",
      loginTitle:"登录", loginSub:"访问你的下载和授权。",
      loginUser:"用户名或邮箱", loginPass:"密码", loginBtn:"登录",
      loginAlt:"还没有账号？", loginAltLink:"创建一个",
      regTitle:"注册", regSub:"注册后即可下载插件并留下评价。",
      regUser:"用户名", regEmail:"邮箱", regPass:"密码", regBtn:"注册",
      regAlt:"已有账号？", regAltLink:"在此登录"
    }
  };

  function getLang() {
    try { var l = localStorage.getItem('lang'); if (l) return l; } catch (e) {}
    var m = document.cookie.match(/(?:^|;\s*)lang=([^;]+)/);
    return m ? m[1] : 'es';
  }
  function saveLang(l) {
    try { localStorage.setItem('lang', l); } catch (e) {}
    document.cookie = 'lang=' + l + ';path=/;max-age=31536000';
  }
  function apply(l) {
    var d = DICT[l] || DICT.es;
    document.querySelectorAll('[data-i18n]').forEach(function (el) {
      var k = el.getAttribute('data-i18n'); if (d[k] != null) el.textContent = d[k];
    });
    document.querySelectorAll('[data-i18n-ph]').forEach(function (el) {
      var k = el.getAttribute('data-i18n-ph'); if (d[k] != null) el.setAttribute('placeholder', d[k]);
    });
    document.querySelectorAll('.langsw button').forEach(function (b) {
      b.classList.toggle('on', b.getAttribute('data-lang') === l);
    });
    document.documentElement.lang = l;
  }
  function setLang(l) { saveLang(l); apply(l); }
  window.setLang = setLang;

  document.addEventListener('click', function (e) {
    var b = e.target.closest('.langsw button');
    if (b) { e.preventDefault(); setLang(b.getAttribute('data-lang')); }
  });
  if (document.readyState !== 'loading') apply(getLang());
  else document.addEventListener('DOMContentLoaded', function () { apply(getLang()); });
})();
