feat: localize login page

This commit is contained in:
a.tolmachev
2026-04-02 23:45:10 +03:00
parent 2f79eb8f48
commit 581d50c33c
3 changed files with 38 additions and 14 deletions
+11 -11
View File
@@ -24,33 +24,33 @@
</div>
<div class="login-box">
<div class="login-heading">Sign in</div>
<div class="login-sub">Welcome back to your workspace</div>
<div class="login-heading" data-i18n="login.title">Sign in</div>
<div class="login-sub" data-i18n="login.subtitle">Welcome back to your workspace</div>
<div class="login-error" id="login-error">
<div class="login-error" id="login-error" data-i18n="login.error.invalid">
Invalid email or password. Please try again.
</div>
<form id="login-form" novalidate>
<div class="field">
<label class="field-label" for="email">Email address</label>
<input class="field-input" type="email" id="email" placeholder="you@acme.com" autocomplete="email" autofocus>
<label class="field-label" for="email" data-i18n="login.email_label">Email address</label>
<input class="field-input" type="email" id="email" data-i18n-ph="login.email_placeholder" placeholder="you@acme.com" autocomplete="email" autofocus>
</div>
<div class="field">
<label class="field-label" for="password">Password</label>
<label class="field-label" for="password" data-i18n="login.password">Password</label>
<input class="field-input" type="password" id="password" placeholder="••••••••" autocomplete="current-password">
<div class="field-footer">
<a href="#" class="field-link">Forgot password?</a>
<a href="#" class="field-link" data-i18n="login.forgot">Forgot password?</a>
</div>
</div>
<button class="btn-signin" type="submit">Sign in</button>
<button class="btn-signin" type="submit" data-i18n="login.submit">Sign in</button>
</form>
<div class="login-divider">
<div class="login-divider-line"></div>
<span class="login-divider-text">or continue with</span>
<span class="login-divider-text" data-i18n="login.divider">or continue with</span>
<div class="login-divider-line"></div>
</div>
@@ -61,13 +61,13 @@
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z" fill="#FBBC05"/>
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
</svg>
Google SSO
<span data-i18n="login.sso_short">Google SSO</span>
</button>
</div>
<div class="login-footer">
Don't have an account? <a href="#">Request access</a>
<span data-i18n="login.request_prefix">Don't have an account?</span> <a href="#" data-i18n="login.request_link">Request access</a>
</div>
<div class="version-badge">Crank v0.9.0-beta</div>
+20
View File
@@ -369,6 +369,16 @@ var TRANSLATIONS = {
'login.password': 'Password',
'login.submit': 'Sign in',
'login.sso': 'Continue with Google',
'login.email_label': 'Email address',
'login.email_placeholder': 'you@acme.com',
'login.forgot': 'Forgot password?',
'login.divider': 'or continue with',
'login.sso_short': 'Google SSO',
'login.request_prefix': "Don't have an account?",
'login.request_link': 'Request access',
'login.error.required': 'Please enter your email and password.',
'login.error.invalid': 'Invalid email or password. Please try again.',
'login.error.generic': 'Unable to sign in right now. Please try again.',
},
ru: {
@@ -736,6 +746,16 @@ var TRANSLATIONS = {
'login.password': 'Пароль',
'login.submit': 'Войти',
'login.sso': 'Войти через Google',
'login.email_label': 'Email адрес',
'login.email_placeholder': 'you@acme.com',
'login.forgot': 'Забыли пароль?',
'login.divider': 'или продолжить через',
'login.sso_short': 'Google SSO',
'login.request_prefix': 'Нет аккаунта?',
'login.request_link': 'Запросить доступ',
'login.error.required': 'Введите email и пароль.',
'login.error.invalid': 'Неверный email или пароль. Попробуйте еще раз.',
'login.error.generic': 'Сейчас не удается войти. Попробуйте еще раз.',
}
};
+7 -3
View File
@@ -1,4 +1,8 @@
(function() {
function tKey(key) {
return window.t ? t(key) : key;
}
function showError(message) {
var errorElement = document.getElementById('login-error');
errorElement.style.display = 'block';
@@ -22,7 +26,7 @@
var password = document.getElementById('password').value;
if (!email || !password) {
showError('Please enter your email and password.');
showError(tKey('login.error.required'));
return;
}
@@ -32,10 +36,10 @@
await window.CrankAuth.login(email, password);
} catch (error) {
if (error && error.status === 401) {
showError('Invalid email or password. Please try again.');
showError(tKey('login.error.invalid'));
return;
}
showError('Unable to sign in right now. Please try again.');
showError(tKey('login.error.generic'));
}
});
});