From ed39e112a945df231eedcfe15893692af3c01a00 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Apr 2025 03:55:51 -0400 Subject: [PATCH] more i18n.js keys added --- CHANGELOG.md | 2 + js/authModals.js | 171 ++++++--------- js/i18n.js | 548 ++++++++++++++++++++++++++++++++++++++++++++--- js/main.js | 8 +- 4 files changed, 590 insertions(+), 139 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b80b3f7..12b49ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## Changes 4//13/2025 - Decreased header height some more and clickable logo. +- authModals.js fully updated with i18n.js keys. +- main.js added Dark & Light mode i18n.js keys. ## Changes 4/12/2025 diff --git a/js/authModals.js b/js/authModals.js index 935442b..cc10470 100644 --- a/js/authModals.js +++ b/js/authModals.js @@ -3,7 +3,8 @@ import { sendRequest } from './networkUtils.js'; import { t, applyTranslations, setLocale } from './i18n.js'; const version = "v1.1.2"; -const adminTitle = `Admin Panel ${version}`; +// Use t() for the admin panel title. (Make sure t("admin_panel") returns "Admin Panel" in English.) +const adminTitle = `${t("admin_panel")} ${version}`; let lastLoginData = null; export function setLastLoginData(data) { @@ -44,7 +45,7 @@ export function openTOTPLoginModal() { - + `; @@ -66,12 +67,12 @@ export function openTOTPLoginModal() { // Switch to recovery totpSection.style.display = "none"; recoverySection.style.display = "block"; - toggleLink.textContent = "Use TOTP Code instead"; + toggleLink.textContent = t("use_totp_code_instead"); } else { // Switch back to TOTP recoverySection.style.display = "none"; totpSection.style.display = "block"; - toggleLink.textContent = "Use Recovery Code instead"; + toggleLink.textContent = t("use_recovery_code_instead"); } }); @@ -79,7 +80,7 @@ export function openTOTPLoginModal() { document.getElementById("submitRecovery").addEventListener("click", () => { const recoveryCode = document.getElementById("recoveryInput").value.trim(); if (!recoveryCode) { - showToast("Please enter your recovery code."); + showToast(t("please_enter_recovery_code")); return; } fetch("totp_recover.php", { @@ -97,11 +98,11 @@ export function openTOTPLoginModal() { // recovery succeeded → finalize login window.location.href = "index.html"; } else { - showToast(json.message || "Recovery code verification failed"); + showToast(json.message || t("recovery_code_verification_failed")); } }) .catch(() => { - showToast("Error verifying recovery code."); + showToast(t("error_verifying_recovery_code")); }); }); @@ -125,14 +126,14 @@ export function openTOTPLoginModal() { if (json.status === "ok") { window.location.href = "index.html"; } else { - showToast(json.message || "TOTP verification failed"); + showToast(json.message || t("totp_verification_failed")); this.value = ""; totpLoginModal.style.display = "flex"; totpInput.focus(); } }) .catch(() => { - showToast("TOTP verification failed"); + showToast(t("totp_verification_failed")); this.value = ""; totpLoginModal.style.display = "flex"; totpInput.focus(); @@ -189,24 +190,24 @@ export function openUserPanel() { userPanelModal.innerHTML = `