fix(login-i18n): translate the 3 hardcoded JS toasts in customer login
Some checks failed
Some checks failed
Three more hardcoded English strings in customers/storefront/login.html were still bypassing i18n because they were emitted from Alpine showAlert() calls in <script>: - "Account created successfully! Please sign in." (post-register toast) - "Login successful! Redirecting..." (post-login toast) - "Invalid email or password" (login-error fallback) Same pattern as the earlier forgot/reset-password sweep: defined window.__customerLoginI18n with `tojson` server-rendered values, read them once at function entry as `const i18n = ...`, and swapped each hardcoded string for an i18n property. Two new auth.* keys × 4 locales (registration_success_signin, login_success_redirecting). The third reuses the existing auth.invalid_credentials. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -187,6 +187,15 @@
|
|||||||
<!-- Alpine.js v3 -->
|
<!-- Alpine.js v3 -->
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js"></script>
|
||||||
|
|
||||||
|
{# Translated client-side strings — kept in sync with auth.* keys above #}
|
||||||
|
<script>
|
||||||
|
window.__customerLoginI18n = {
|
||||||
|
registrationSuccess: {{ _('auth.registration_success_signin')|tojson }},
|
||||||
|
loginSuccess: {{ _('auth.login_success_redirecting')|tojson }},
|
||||||
|
invalidCredentials: {{ _('auth.invalid_credentials')|tojson }},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Login Logic -->
|
<!-- Login Logic -->
|
||||||
<script>
|
<script>
|
||||||
function languageSelector(currentLang, enabledLanguages) {
|
function languageSelector(currentLang, enabledLanguages) {
|
||||||
@@ -206,6 +215,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function customerLogin() {
|
function customerLogin() {
|
||||||
|
const i18n = window.__customerLoginI18n || {};
|
||||||
return {
|
return {
|
||||||
// Data
|
// Data
|
||||||
credentials: {
|
credentials: {
|
||||||
@@ -234,7 +244,7 @@
|
|||||||
checkRegistrationSuccess() {
|
checkRegistrationSuccess() {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
if (urlParams.get('registered') === 'true') {
|
if (urlParams.get('registered') === 'true') {
|
||||||
this.showAlert('Account created successfully! Please sign in.', 'success');
|
this.showAlert(i18n.registrationSuccess, 'success');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -293,7 +303,7 @@
|
|||||||
localStorage.setItem('customer_token', data.access_token);
|
localStorage.setItem('customer_token', data.access_token);
|
||||||
localStorage.setItem('customer_user', JSON.stringify(data.user));
|
localStorage.setItem('customer_user', JSON.stringify(data.user));
|
||||||
|
|
||||||
this.showAlert('Login successful! Redirecting...', 'success');
|
this.showAlert(i18n.loginSuccess, 'success');
|
||||||
|
|
||||||
// Redirect to account page or return URL.
|
// Redirect to account page or return URL.
|
||||||
// Accepts `?next=` (apiClient's 401-handler convention)
|
// Accepts `?next=` (apiClient's 401-handler convention)
|
||||||
@@ -306,7 +316,7 @@
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Login error:', error);
|
console.error('Login error:', error);
|
||||||
this.showAlert(error.message || 'Invalid email or password');
|
this.showAlert(error.message || i18n.invalidCredentials);
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,8 @@
|
|||||||
"try_again": "versuchen Sie es erneut",
|
"try_again": "versuchen Sie es erneut",
|
||||||
"remember_password": "Passwort wieder eingefallen?",
|
"remember_password": "Passwort wieder eingefallen?",
|
||||||
"login_subtitle": "Willkommen zurück in Ihrem Konto",
|
"login_subtitle": "Willkommen zurück in Ihrem Konto",
|
||||||
|
"registration_success_signin": "Konto erfolgreich erstellt! Bitte anmelden.",
|
||||||
|
"login_success_redirecting": "Anmeldung erfolgreich! Weiterleitung...",
|
||||||
"reset_password_subtitle": "Neues Passwort erstellen",
|
"reset_password_subtitle": "Neues Passwort erstellen",
|
||||||
"reset_your_password": "Passwort zurücksetzen",
|
"reset_your_password": "Passwort zurücksetzen",
|
||||||
"reset_password_form_desc": "Geben Sie unten Ihr neues Passwort ein. Es muss mindestens 8 Zeichen lang sein.",
|
"reset_password_form_desc": "Geben Sie unten Ihr neues Passwort ein. Es muss mindestens 8 Zeichen lang sein.",
|
||||||
|
|||||||
@@ -142,6 +142,8 @@
|
|||||||
"try_again": "try again",
|
"try_again": "try again",
|
||||||
"remember_password": "Remember your password?",
|
"remember_password": "Remember your password?",
|
||||||
"login_subtitle": "Welcome back to your account",
|
"login_subtitle": "Welcome back to your account",
|
||||||
|
"registration_success_signin": "Account created successfully! Please sign in.",
|
||||||
|
"login_success_redirecting": "Login successful! Redirecting...",
|
||||||
"reset_password_subtitle": "Create new password",
|
"reset_password_subtitle": "Create new password",
|
||||||
"reset_your_password": "Reset Your Password",
|
"reset_your_password": "Reset Your Password",
|
||||||
"reset_password_form_desc": "Enter your new password below. Password must be at least 8 characters.",
|
"reset_password_form_desc": "Enter your new password below. Password must be at least 8 characters.",
|
||||||
|
|||||||
@@ -142,6 +142,8 @@
|
|||||||
"try_again": "réessayez",
|
"try_again": "réessayez",
|
||||||
"remember_password": "Vous vous souvenez de votre mot de passe ?",
|
"remember_password": "Vous vous souvenez de votre mot de passe ?",
|
||||||
"login_subtitle": "Heureux de vous revoir",
|
"login_subtitle": "Heureux de vous revoir",
|
||||||
|
"registration_success_signin": "Compte créé avec succès ! Veuillez vous connecter.",
|
||||||
|
"login_success_redirecting": "Connexion réussie ! Redirection...",
|
||||||
"reset_password_subtitle": "Créer un nouveau mot de passe",
|
"reset_password_subtitle": "Créer un nouveau mot de passe",
|
||||||
"reset_your_password": "Réinitialisez votre mot de passe",
|
"reset_your_password": "Réinitialisez votre mot de passe",
|
||||||
"reset_password_form_desc": "Saisissez votre nouveau mot de passe ci-dessous. Il doit comporter au moins 8 caractères.",
|
"reset_password_form_desc": "Saisissez votre nouveau mot de passe ci-dessous. Il doit comporter au moins 8 caractères.",
|
||||||
|
|||||||
@@ -142,6 +142,8 @@
|
|||||||
"try_again": "probéiert et nach eng Kéier",
|
"try_again": "probéiert et nach eng Kéier",
|
||||||
"remember_password": "Passwuert erëm agefall?",
|
"remember_password": "Passwuert erëm agefall?",
|
||||||
"login_subtitle": "Wëllkomm zréck an Ärem Kont",
|
"login_subtitle": "Wëllkomm zréck an Ärem Kont",
|
||||||
|
"registration_success_signin": "Kont erfollegräich erstallt! Loggt Iech w.e.g. an.",
|
||||||
|
"login_success_redirecting": "Login erfollegräich! Weiderleeden...",
|
||||||
"reset_password_subtitle": "Neit Passwuert erstellen",
|
"reset_password_subtitle": "Neit Passwuert erstellen",
|
||||||
"reset_your_password": "Ärt Passwuert zrécksetzen",
|
"reset_your_password": "Ärt Passwuert zrécksetzen",
|
||||||
"reset_password_form_desc": "Gitt hei drënner Ärt neit Passwuert an. Et muss mindestens 8 Zeechen laang sinn.",
|
"reset_password_form_desc": "Gitt hei drënner Ärt neit Passwuert an. Et muss mindestens 8 Zeechen laang sinn.",
|
||||||
|
|||||||
Reference in New Issue
Block a user