add translation for 3 option files

This commit is contained in:
Nriver 2024-08-14 11:31:00 +08:00
parent b231905981
commit 68733cf0c2
5 changed files with 141 additions and 41 deletions

View File

@ -1,3 +1,4 @@
import { t } from "../../../services/i18n.js";
import server from "../../../services/server.js";
import dialogService from "../../../services/dialog.js";
import toastService from "../../../services/toast.js";
@ -5,24 +6,24 @@ import OptionsWidget from "./options_widget.js";
const TPL = `
<div class="options-section">
<h4>ETAPI</h4>
<h4>${t("etapi.title")}</h4>
<p>ETAPI is a REST API used to access Trilium instance programmatically, without UI. <br/>
See more details on <a href="https://triliumnext.github.io/Docs/Wiki/etapi.html">wiki</a> and <a onclick="window.open('etapi/etapi.openapi.yaml')" href="etapi/etapi.openapi.yaml">ETAPI OpenAPI spec</a>.</p>
<p>${t("etapi.description")} <br/>
${t("etapi.see_more")} <a href="https://triliumnext.github.io/Docs/Wiki/etapi.html">${t("etapi.wiki")}</a> ${t("etapi.and")} <a onclick="window.open('etapi/etapi.openapi.yaml')" href="etapi/etapi.openapi.yaml">${t("etapi.openapi_spec")}</a>.</p>
<button type="button" class="create-etapi-token btn btn-sm">Create new ETAPI token</button>
<button type="button" class="create-etapi-token btn btn-sm">${t("etapi.create_token")}</button>
<h5>Existing tokens</h5>
<h5>${t("etapi.existing_tokens")}</h5>
<div class="no-tokens-yet">There are no tokens yet. Click on the button above to create one.</div>
<div class="no-tokens-yet">${t("etapi.no_tokens_yet")}</div>
<div style="overflow: auto; height: 500px;">
<table class="tokens-table table table-stripped">
<thead>
<tr>
<th>Token name</th>
<th>Created</th>
<th>Actions</th>
<th>${t("etapi.token_name")}</th>
<th>${t("etapi.created")}</th>
<th>${t("etapi.actions")}</th>
</tr>
</thead>
<tbody></tbody>
@ -52,21 +53,21 @@ export default class EtapiOptions extends OptionsWidget {
this.$widget.find(".create-etapi-token").on("click", async () => {
const tokenName = await dialogService.prompt({
title: "New ETAPI token",
message: "Please enter new token's name",
defaultValue: "new token"
title: t("etapi.new_token_title"),
message: t("etapi.new_token_message"),
defaultValue: t("etapi.default_token_name")
});
if (!tokenName.trim()) {
toastService.showError("Token name can't be empty");
toastService.showError(t("etapi.error_empty_name"));
return;
}
const {authToken} = await server.post('etapi-tokens', {tokenName});
await dialogService.prompt({
title: "ETAPI token created",
message: 'Copy the created token into clipboard. Trilium stores the token hashed and this is the last time you see it.',
title: t("etapi.token_created_title"),
message: t("etapi.token_created_message"),
defaultValue: authToken
});
@ -94,9 +95,9 @@ export default class EtapiOptions extends OptionsWidget {
.append($("<td>").text(token.name))
.append($("<td>").text(token.utcDateCreated))
.append($("<td>").append(
$('<span class="bx bx-pen token-table-button" title="Rename this token"></span>')
$('<span class="bx bx-pen token-table-button" title="${t("etapi.rename_token")}"></span>')
.on("click", () => this.renameToken(token.etapiTokenId, token.name)),
$('<span class="bx bx-trash token-table-button" title="Delete / deactivate this token"></span>')
$('<span class="bx bx-trash token-table-button" title="${t("etapi.delete_token")}"></span>')
.on("click", () => this.deleteToken(token.etapiTokenId, token.name))
))
);
@ -105,8 +106,8 @@ export default class EtapiOptions extends OptionsWidget {
async renameToken(etapiTokenId, oldName) {
const tokenName = await dialogService.prompt({
title: "Rename token",
message: "Please enter new token's name",
title: t("etapi.rename_token_title"),
message: t("etapi.rename_token_message"),
defaultValue: oldName
});
@ -120,7 +121,7 @@ export default class EtapiOptions extends OptionsWidget {
}
async deleteToken(etapiTokenId, name) {
if (!await dialogService.confirm(`Are you sure you want to delete ETAPI token "${name}"?`)) {
if (!await dialogService.confirm(t("etapi.delete_token_confirmation", { name }))) {
return;
}

View File

@ -1,3 +1,4 @@
import { t } from "../../../services/i18n.js";
import server from "../../../services/server.js";
import toastService from "../../../services/toast.js";
import NoteContextAwareWidget from "../../note_context_aware_widget.js";
@ -24,8 +25,8 @@ export default class OptionsWidget extends NoteContextAwareWidget {
showUpdateNotification() {
toastService.showPersistent({
id: "options-change-saved",
title: "Options status",
message: "Options change have been saved.",
title: t("options_widget.options_status"),
message: t("options_widget.options_change_saved"),
icon: "slider",
closeAfter: 2000
});

View File

@ -1,3 +1,4 @@
import { t } from "../../../services/i18n.js";
import server from "../../../services/server.js";
import protectedSessionHolder from "../../../services/protected_session_holder.js";
import toastService from "../../../services/toast.js";
@ -5,42 +6,39 @@ import OptionsWidget from "./options_widget.js";
const TPL = `
<div class="options-section">
<h4 class="password-heading"></h4>
<h4 class="password-heading">${t("password.heading")}</h4>
<div class="alert alert-warning" role="alert" style="font-weight: bold; color: red !important;">
Please take care to remember your new password. Password is used for logging into the web interface and
to encrypt protected notes. If you forget your password, then all your protected notes are forever lost.
In case you did forget your password, <a class="reset-password-button" href="javascript:">click here to reset it</a>.
${t("password.alert_message")} <a class="reset-password-button" href="javascript:">${t("password.reset_link")}</a>
</div>
<form class="change-password-form">
<div class="old-password-form-group form-group">
<label>Old password</label>
<label>${t("password.old_password")}</label>
<input class="old-password form-control" type="password">
</div>
<div class="form-group">
<label>New password</label>
<label>${t("password.new_password")}</label>
<input class="new-password1 form-control" type="password">
</div>
<div class="form-group">
<label>New password confirmation</label>
<label>${t("password.new_password_confirmation")}</label>
<input class="new-password2 form-control" type="password">
</div>
<button class="save-password-button btn btn-primary">Change password</button>
<button class="save-password-button btn btn-primary">${t("password.change_password")}</button>
</form>
</div>
<div class="options-section">
<h4>Protected Session Timeout</h4>
<h4>${t("password.protected_session_timeout")}</h4>
<p>Protected session timeout is a time period after which the protected session is wiped from
the browser's memory. This is measured from the last interaction with protected notes. See <a href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html" class="external">wiki</a> for more info.</p>
<p>${t("password.protected_session_timeout_description")} <a href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html" class="external">${t("password.wiki")}</a> ${t("password.for_more_info")}</p>
<div class="form-group">
<label>Protected session timeout (in seconds)</label>
<label>${t("password.protected_session_timeout_label")}</label>
<input class="protected-session-timeout-in-seconds form-control options-number-input" type="number" min="60">
</div>
</div>`;
@ -58,13 +56,13 @@ export default class PasswordOptions extends OptionsWidget {
this.$resetPasswordButton = this.$widget.find(".reset-password-button");
this.$resetPasswordButton.on("click", async () => {
if (confirm("By resetting the password you will forever lose access to all your existing protected notes. Do you really want to reset the password?")) {
if (confirm(t("password.reset_confirmation"))) {
await server.post("password/reset?really=yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes");
const options = await server.get('options');
this.optionsLoaded(options);
toastService.showError("Password has been reset. Please set new password");
toastService.showError(t("password.reset_success_message"));
}
});
@ -79,8 +77,8 @@ export default class PasswordOptions extends OptionsWidget {
const isPasswordSet = options.isPasswordSet === 'true';
this.$widget.find(".old-password-form-group").toggle(isPasswordSet);
this.$passwordHeading.text(isPasswordSet ? 'Change Password' : 'Set Password');
this.$savePasswordButton.text(isPasswordSet ? 'Change Password' : 'Set Password');
this.$passwordHeading.text(isPasswordSet ? t("password.change_password_heading") : t("password.set_password_heading"));
this.$savePasswordButton.text(isPasswordSet ? t("password.change_password") : t("password.set_password"));
this.$protectedSessionTimeout.val(options.protectedSessionTimeout);
}
@ -94,7 +92,7 @@ export default class PasswordOptions extends OptionsWidget {
this.$newPassword2.val('');
if (newPassword1 !== newPassword2) {
toastService.showError("New passwords are not the same.");
toastService.showError(t("password.password_mismatch"));
return false;
}
@ -103,7 +101,7 @@ export default class PasswordOptions extends OptionsWidget {
'new_password': newPassword1
}).then(result => {
if (result.success) {
toastService.showError("Password has been changed. Trilium will be reloaded after you press OK.");
toastService.showError(t("password.password_changed_success"));
// password changed so current protected session is invalid and needs to be cleared
protectedSessionHolder.resetProtectedSession();

View File

@ -1128,8 +1128,58 @@
"backup_recommendation": "建议打开备份功能,但这可能会使大型数据库和/或慢速存储设备的应用程序启动变慢。",
"backup_now": "立即备份",
"backup_database_now": "立即备份数据库",
"existing_backups": "有备份",
"existing_backups": "有备份",
"database_backed_up_to": "数据库已备份到",
"no_backup_yet": "尚无备份"
},
"etapi": {
"title": "ETAPI",
"description": "ETAPI 是一个 REST API用于以编程方式访问 Trilium 实例,而无需 UI。",
"see_more": "更多详情见",
"wiki": "维基",
"and": "和",
"openapi_spec": "ETAPI OpenAPI 规范",
"create_token": "创建新的 ETAPI 令牌",
"existing_tokens": "现有令牌",
"no_tokens_yet": "目前还没有令牌。点击上面的按钮创建一个。",
"token_name": "令牌名称",
"created": "创建时间",
"actions": "操作",
"new_token_title": "新 ETAPI 令牌",
"new_token_message": "请输入新的令牌名称",
"default_token_name": "新令牌",
"error_empty_name": "令牌名称不能为空",
"token_created_title": "ETAPI 令牌已创建",
"token_created_message": "将创建的令牌复制到剪贴板。Trilium 存储了令牌的哈希值,这是你最后一次看到它。",
"rename_token": "重命名此令牌",
"delete_token": "删除/停用此令牌",
"rename_token_title": "重命名令牌",
"rename_token_message": "请输入新的令牌名称",
"delete_token_confirmation": "你确定要删除 ETAPI 令牌 \"{{name}}\" 吗?"
},
"options_widget": {
"options_status": "选项状态",
"options_change_saved": "选项更改已保存。"
},
"password": {
"heading": "密码",
"alert_message": "请务必记住您的新密码。密码用于登录 Web 界面和加密保护的笔记。如果您忘记了密码,所有保护的笔记将永久丢失。",
"reset_link": "点击这里重置。",
"old_password": "旧密码",
"new_password": "新密码",
"new_password_confirmation": "新密码确认",
"change_password": "更改密码",
"protected_session_timeout": "保护会话超时",
"protected_session_timeout_description": "保护会话超时是一个时间段,超时后保护会话会从浏览器内存中清除。这是从最后一次与保护笔记的交互开始计时的。更多信息请见",
"wiki": "维基",
"for_more_info": "更多信息。",
"protected_session_timeout_label": "保护会话超时(秒)",
"reset_confirmation": "重置密码将永久丧失对所有现受保护笔记的访问。您真的要重置密码吗?",
"reset_success_message": "密码已重置。请设置新密码",
"change_password_heading": "更改密码",
"set_password_heading": "设置密码",
"set_password": "设置密码",
"password_mismatch": "新密码不一致。",
"password_changed_success": "密码已更改。按 OK 后 Trilium 将重新加载。"
}
}

View File

@ -1132,5 +1132,55 @@
"existing_backups": "Existing backups",
"database_backed_up_to": "Database has been backed up to",
"no_backup_yet": "no backup yet"
},
"etapi": {
"title": "ETAPI",
"description": "ETAPI is a REST API used to access Trilium instance programmatically, without UI.",
"see_more": "See more details on",
"wiki": "wiki",
"and": "and",
"openapi_spec": "ETAPI OpenAPI spec",
"create_token": "Create new ETAPI token",
"existing_tokens": "Existing tokens",
"no_tokens_yet": "There are no tokens yet. Click on the button above to create one.",
"token_name": "Token name",
"created": "Created",
"actions": "Actions",
"new_token_title": "New ETAPI token",
"new_token_message": "Please enter new token's name",
"default_token_name": "new token",
"error_empty_name": "Token name can't be empty",
"token_created_title": "ETAPI token created",
"token_created_message": "Copy the created token into clipboard. Trilium stores the token hashed and this is the last time you see it.",
"rename_token": "Rename this token",
"delete_token": "Delete / deactivate this token",
"rename_token_title": "Rename token",
"rename_token_message": "Please enter new token's name",
"delete_token_confirmation": "Are you sure you want to delete ETAPI token \"{{name}}\"?"
},
"options_widget": {
"options_status": "Options status",
"options_change_saved": "Options change have been saved."
},
"password": {
"heading": "Password",
"alert_message": "Please take care to remember your new password. Password is used for logging into the web interface and to encrypt protected notes. If you forget your password, then all your protected notes are forever lost.",
"reset_link": "click here to reset it.",
"old_password": "Old password",
"new_password": "New password",
"new_password_confirmation": "New password confirmation",
"change_password": "Change password",
"protected_session_timeout": "Protected Session Timeout",
"protected_session_timeout_description": "Protected session timeout is a time period after which the protected session is wiped from the browser's memory. This is measured from the last interaction with protected notes. See",
"wiki": "wiki",
"for_more_info": "for more info.",
"protected_session_timeout_label": "Protected session timeout (in seconds)",
"reset_confirmation": "By resetting the password you will forever lose access to all your existing protected notes. Do you really want to reset the password?",
"reset_success_message": "Password has been reset. Please set new password",
"change_password_heading": "Change Password",
"set_password_heading": "Set Password",
"set_password": "Set Password",
"password_mismatch": "New passwords are not the same.",
"password_changed_success": "Password has been changed. Trilium will be reloaded after you press OK."
}
}