Skip to content

Commit

Permalink
Refine i18n
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
ruibaby committed Sep 24, 2024
1 parent a0c9111 commit 7a88f00
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!doctype html>
<!DOCTYPE html>
<html
xmlns:th="https://www.thymeleaf.org"
th:replace="~{gateway_modules/layout :: layout(title = |两步验证 - ${site.title}|, head = null, body = ~{::body})}"
th:replace="~{gateway_modules/layout :: layout(title = |#{title} - ${site.title}|, head = null, body = ~{::body})}"
>
<th:block th:fragment="body">
<div class="gateway-page-wrapper">
<div th:replace="~{gateway_modules/common_fragments::halo_logo}"></div>
<div class="halo-form-wrapper">
<h1 style="margin-top: 0">两步验证</h1>
<h1 class="form-title" th:text="#{title}"></h1>
<form
class="halo-form"
th:action="@{/challenges/two-factor/totp}"
Expand All @@ -16,10 +16,10 @@ <h1 style="margin-top: 0">两步验证</h1>
method="post"
>
<p style="color: red" role="alert" th:if="${param.error.size() > 0}">
<strong><span>Invalid TOTP code</span></strong>
<strong><span th:text="#{messages.invalidError}"></span></strong>
</p>
<div class="form-item">
<label for="code">TOTP Code</label>
<label for="code" th:text="#{form.code.label}"></label>
<div class="form-input">
<input
type="text"
Expand All @@ -34,7 +34,7 @@ <h1 style="margin-top: 0">两步验证</h1>
</div>
</div>
<div class="form-item">
<button type="submit">验证</button>
<button type="submit" th:text="#{form.submit}"></button>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title=Two-Factor Authentication
messages.invalidError=Invalid TOTP code
form.code.label=TOTP Code
form.submit=Verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title=两步验证
messages.invalidError=错误的验证码
form.code.label=验证码
form.submit=验证
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<th:block th:unless="${#lists.isEmpty(socialAuthProviders)}">
<div class="divider-wrapper">
<hr />
社交登录
<th:block th:text="#{socialLogin.label}"></th:block>
<hr />
</div>
<ul class="auth-provider-items">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
socialLogin.label=Social Login
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
socialLogin.label=社交登录
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
th:method="${authProvider.spec.method}"
>
<p style="color: red" role="alert" th:if="${param.error.size() > 0}">
<strong><span th:text="#{login.error}">Invalid Credentials</span></strong>
<strong><span th:text="#{messages.loginError}"></span></strong>
</p>
<p style="color: green" role="alert" th:if="${param.logout.size() > 0}">
<strong><span th:text="#{logout.success}">Logout successfully.</span></strong>
<strong><span th:text="#{messages.logoutSuccess}"></span></strong>
</p>
<p style="color: green" role="alert" th:if="${param.signup.size() > 0}">
<strong>
<span th:text="#{signup.success}">Congratulation! Signup successfully, please sign in now.</span>
<span th:text="#{messages.signupSuccess}"></span>
</strong>
</p>

Expand All @@ -24,19 +24,19 @@

<div th:if="${authProvider.spec.rememberMeSupport}" class="form-item-compact">
<input type="checkbox" id="remember-me" name="remember-me" value="true" />
<label for="remember-me" th:text="#{rememberMe}">保持登录会话</label>
<label for="remember-me" th:text="#{form.rememberMe.label}"></label>
</div>

<div class="form-item">
<button type="submit" th:text="#{login.button}">登录</button>
<button type="submit" th:text="#{form.submit}"></button>
</div>
</form>

<div th:remove="tag" th:fragment="formAuthProviders">
<th:block th:unless="${#lists.isEmpty(formAuthProviders)}">
<div class="divider-wrapper">
<hr />
其他登录方式
<th:block th:text="#{otherLogin.label}"></th:block>
<hr />
</div>
<ul class="auth-provider-items">
Expand All @@ -53,16 +53,16 @@
<div th:remove="tag" th:fragment="miscellaneous">
<div th:if="${globalInfo.allowRegistration}" class="signup-notice">
<div>
<th:block th:text="#{noAccount}"></th:block>
<a th:href="@{/signup}" th:text="#{signup}"></a>
<th:block th:text="#{signup.description}"></th:block>
<a th:href="@{/signup}" th:text="#{signup.link}"></a>
</div>
</div>
<div class="backtosite-notice">
<a th:href="@{/}">
<svg viewBox="0 0 24 24" width="1.2em" height="1.2em">
<path fill="currentColor" d="M21 11H6.83l3.58-3.59L9 6l-6 6l6 6l1.41-1.42L6.83 13H21z"></path>
</svg>
<span th:text="#{returnToSite}">返回到首页</span>
<span th:text="#{returnToSite}"></span>
</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
login.error=Invalid credentials.
logout.success=Logout successfully.
signup.success=Congratulations! Signup successfully, please sign in now.
rememberMe=Remember me
login.button=Sign in
returnToSite=Return to site
noAccount=Don't have an account?
signup=Sign up
retrievePassword=Retrieve password
messages.loginError=Invalid credentials.
messages.logoutSuccess=Logout successfully.
messages.signupSuccess=Congratulations! Sign up successfully, please sign in now.

form.rememberMe.label=Remember me
form.submit=Login
otherLogin.label=Other Login
signup.description=Don't have an account?
signup.link=Sign up
returnToSite=Return to site
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
login.error=无效的凭证。
logout.success=登出成功。
signup.success=恭喜!注册成功,请立即登录。
rememberMe=保持登录会话
login.button=登录
returnToSite=返回网站
noAccount=没有账号?
signup=立即注册
retrievePassword=忘记密码?
messages.loginError=无效的凭证。
messages.logoutSuccess=登出成功。
messages.signupSuccess=恭喜!注册成功,请立即登录。

form.rememberMe.label=保持登录会话
form.submit=登录
otherLogin.label=其他登录方式
signup.description=没有账号?
signup.link=立即注册
returnToSite=返回网站
5 changes: 1 addition & 4 deletions application/src/main/resources/templates/login_en.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
title=Please Sign In
otherLoginMethods=Other Login Methods
socialLogin=Social logins
miscellaneous=Miscellaneous
title=Login
22 changes: 13 additions & 9 deletions application/src/main/resources/templates/login_local.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<head th:remove="tag" th:fragment="header">
<script src="/webjars/jsencrypt/3.3.2/bin/jsencrypt.min.js" defer></script>
<script th:inline="javascript" type="text/javascript">
const publicKey = [[${publicKey}]];
const publicKey = /*[[${publicKey}]]*/ "";
// Encrypt function
function encryptPassword(password) {
Expand All @@ -10,10 +10,10 @@
return encrypt.encrypt(password);
}
document.addEventListener('DOMContentLoaded', function () {
const loginForm = document.getElementById('login-form');
loginForm.addEventListener('submit', function (event) {
const passwordInput = document.getElementById('password');
document.addEventListener("DOMContentLoaded", function () {
const loginForm = document.getElementById("login-form");
loginForm.addEventListener("submit", function (event) {
const passwordInput = document.getElementById("password");
const password = passwordInput.value;
passwordInput.value = encryptPassword(password);
});
Expand All @@ -23,7 +23,7 @@

<div th:remove="tag" th:fragment="form">
<div class="form-item">
<label for="username"> Username </label>
<label for="username" th:text="#{form.username.label}"> </label>

<div class="form-input">
<input
Expand All @@ -41,9 +41,13 @@
</div>
<div class="form-item">
<div class="form-label-group">
<label for="password"> Password </label>
<a class="form-item-extra-link" tabindex="-1" th:href="@{/forget-password}" th:text="#{retrievePassword}">
忘记密码?
<label for="password" th:text="#{form.password.label}"> </label>
<a
class="form-item-extra-link"
tabindex="-1"
th:href="@{/forget-password}"
th:text="#{form.password.forgot}"
>
</a>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
form.username.label=Username
form.password.label=Password
form.password.forgot=Fotgot your password?
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
form.username.label=用户名
form.password.label=密码
form.password.forgot=忘记密码?
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
title=登录
otherLoginMethods=其他登录方式
socialLogin=社交登录
miscellaneous=杂项
title=登录
10 changes: 5 additions & 5 deletions application/src/main/resources/templates/logout.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<!doctype html>
<!DOCTYPE html>
<html
xmlns:th="https://www.thymeleaf.org"
th:replace="~{gateway_modules/layout:: layout(title = |退出登录 - ${site.title}|, head = null, body = ~{::body})}"
th:replace="~{gateway_modules/layout:: layout(title = |#{title} - ${site.title}|, head = null, body = ~{::body})}"
>
<th:block th:fragment="body">
<div class="gateway-page-wrapper">
<div class="halo-form-wrapper">
<h1 class="form-title">Are you sure want to log out?</h1>
<h1 class="form-title" th:text="#{form.title}"></h1>
<form class="halo-form" id="logout-form" name="logout-form" th:action="@{/logout}" method="post">
<div class="form-item">
<button type="submit">Log out</button>
<button type="submit" th:text="#{form.submit}"></button>
</div>
</form>
</div>
</div>
</th:block>
</html>
</html>
3 changes: 3 additions & 0 deletions application/src/main/resources/templates/logout_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title=Logout
form.title=Are you sure want to log out?
form.submit=Logout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title=退出登录
form.title=确定要退出登录吗?
form.submit=退出登录
25 changes: 15 additions & 10 deletions application/src/main/resources/templates/signup.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html
xmlns:th="https://www.thymeleaf.org"
th:replace="~{gateway_modules/layout :: layout(title = |注册 - ${site.title}|, head = ~{::head}, body = ~{::body})}"
th:replace="~{gateway_modules/layout :: layout(title = |#{title} - ${site.title}|, head = ~{::head}, body = ~{::body})}"
>
<th:block th:fragment="head">
<style>
Expand All @@ -14,11 +14,11 @@
<div class="gateway-page-wrapper signup-page-wrapper">
<div th:replace="~{gateway_modules/common_fragments::halo_logo}"></div>
<div class="halo-form-wrapper">
<h1 class="form-title">Sign Up</h1>
<h1 class="form-title" th:text="#{title}"></h1>
<form class="halo-form" name="signup-form" id="signup-form" th:action="@{/signup}" method="post">
<div class="form-item-group">
<div class="form-item">
<label for="username">Username:</label>
<label for="username" th:text="#{form.username.label}"></label>
<div class="form-input">
<input
type="text"
Expand All @@ -35,7 +35,7 @@ <h1 class="form-title">Sign Up</h1>
</div>

<div class="form-item">
<label for="displayName">Display Name:</label>
<label for="displayName" th:text="#{form.displayName.label}"></label>
<div class="form-input">
<input
type="text"
Expand All @@ -53,7 +53,7 @@ <h1 class="form-title">Sign Up</h1>

<div class="form-item-group">
<div class="form-item">
<label for="email">Email:</label>
<label for="email" th:text="#{form.email.label}"></label>
<div class="form-input">
<input
type="email"
Expand All @@ -69,7 +69,7 @@ <h1 class="form-title">Sign Up</h1>
</div>

<div class="form-item" th:if="${globalInfo.mustVerifyEmailOnRegistration}">
<label for="emailCaptcha">Email Captcha:</label>
<label for="emailCaptcha" th:text="#{form.emailCaptcha.label}"></label>
<div class="form-input-group">
<div class="form-input">
<input
Expand All @@ -82,27 +82,32 @@ <h1 class="form-title">Sign Up</h1>
/>
</div>

<button id="emailCaptchaSendButton" type="button">Send</button>
<button
id="emailCaptchaSendButton"
type="button"
th:text="#{form.emailCaptcha.sendButton}"
>
</button>
</div>
</div>
</div>

<div class="form-item">
<label for="password">Password:</label>
<label for="password" th:text="#{form.password.label}"></label>
<th:block
th:replace="~{gateway_modules/input_fragments :: password(id = 'password', name = 'password', required = 'true', enableToggle = true)}"
></th:block>
</div>

<div class="form-item">
<label for="confirmPassword">Confirm Password:</label>
<label for="confirmPassword" th:text="#{form.confirmPassword.label}"></label>
<th:block
th:replace="~{gateway_modules/input_fragments :: password(id = 'confirmPassword', name = null, required = 'true', enableToggle = true)}"
></th:block>
</div>

<div class="form-item">
<button type="submit">注册</button>
<button type="submit" th:text="#{form.submit}"></button>
</div>
</form>

Expand Down
9 changes: 9 additions & 0 deletions application/src/main/resources/templates/signup_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title=Sign up
form.username.label=Username
form.displayName.label=Display name
form.email.label=Email
form.emailCaptcha.label=Email Captcha
form.emailCaptcha.sendButton=Send
form.password.label=Password
form.confirmPassword.label=Confirm password
form.submit=Sign up
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title=注册
form.username.label=用户名
form.displayName.label=名称
form.email.label=电子邮箱
form.emailCaptcha.label=邮箱验证码
form.emailCaptcha.sendButton=发送
form.password.label=密码
form.confirmPassword.label=确认密码
form.submit=注册

0 comments on commit 7a88f00

Please sign in to comment.