add translation for all floating buttons

This commit is contained in:
Nriver 2024-08-05 09:49:52 +08:00
parent d93a94322e
commit 71c09b1d67
8 changed files with 75 additions and 15 deletions

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import server from "../../services/server.js";
import ws from "../../services/ws.js";
import appContext from "../../components/app_context.js";
@ -15,15 +16,15 @@ const TPL = `
}
</style>
<button data-trigger-command="runActiveNote" class="execute-button floating-button btn" title="Execute script">
<button data-trigger-command="runActiveNote" class="execute-button floating-button btn" title="${t('code_buttons.execute_button_title')}">
<span class="bx bx-run"></span>
</button>
<button class="trilium-api-docs-button floating-button btn" title="Open Trilium API docs">
<button class="trilium-api-docs-button floating-button btn" title="${t('code_buttons.trilium_api_docs_button_title')}">
<span class="bx bx-help-circle"></span>
</button>
<button class="save-to-note-button floating-button btn">
<button class="save-to-note-button floating-button btn" title="${t('code_buttons.save_to_note_button_title')}">
<span class="bx bx-save"></span>
</button>
</div>`;
@ -39,7 +40,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {
this.$widget = $(TPL);
this.$openTriliumApiDocsButton = this.$widget.find(".trilium-api-docs-button");
this.$openTriliumApiDocsButton.on("click", () => {
toastService.showMessage("Opening API docs...");
toastService.showMessage(t('code_buttons.opening_api_docs_message'));
if (this.note.mime.endsWith("frontend")) {
window.open("https://zadam.github.io/trilium/frontend_api/FrontendScriptApi.html", "_blank");
@ -58,7 +59,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {
await appContext.tabManager.getActiveContext().setNote(notePath);
toastService.showMessage(`SQL Console note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
toastService.showMessage(t('code_buttons.sql_console_saved_message', { notePath: await treeService.getNotePathTitle(notePath) }));
});
keyboardActionService.updateDisplayedShortcuts(this.$widget);

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import utils from "../../services/utils.js";
import imageService from "../../services/image.js";
@ -5,7 +6,7 @@ import imageService from "../../services/image.js";
const TPL = `
<button type="button"
class="copy-image-reference-button"
title="Copy image reference to the clipboard, can be pasted into a text note.">
title="${t('copy_image_reference_button.button_title')}">
<span class="bx bx-copy"></span>
<div class="hidden-image-copy"></div>

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
const TPL = `
@ -27,7 +28,7 @@ const TPL = `
<button type="button"
class="close-floating-buttons-button btn bx bx-x"
title="Hide buttons"></button>
title="${t('hide_floating_buttons_button.button_title')}"></button>
</div>
`;

View File

@ -1,9 +1,10 @@
import { t } from "../../services/i18n.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
const TPL = `
<button type="button"
class="export-mermaid-button"
title="Export Mermaid diagram as SVG">
title="${t('mermaid_export_button.button_title')}">
<span class="bx bx-export"></span>
</button>
`;

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
const TPL = `
@ -11,20 +12,20 @@ const TPL = `
<button type="button"
class="relation-map-create-child-note floating-button btn bx bx-folder-plus"
title="Create new child note and add it into this relation map"></button>
title="${t('relation_map_buttons.create_child_note_title')}"></button>
<button type="button"
class="relation-map-reset-pan-zoom floating-button btn bx bx-crop"
title="Reset pan & zoom to initial coordinates and magnification"></button>
title="${t('relation_map_buttons.reset_pan_zoom_title')}"></button>
<div class="btn-group">
<button type="button"
class="relation-map-zoom-in floating-button btn bx bx-zoom-in"
title="Zoom In"></button>
title="${t('relation_map_buttons.zoom_in_title')}"></button>
<button type="button"
class="relation-map-zoom-out floating-button btn bx bx-zoom-out"
title="Zoom Out"></button>
title="${t('relation_map_buttons.zoom_out_title')}"></button>
</div>
</div>`;

View File

@ -2,6 +2,7 @@
* !!! Filename is intentionally mangled, because some adblockers don't like the word "backlinks".
*/
import { t } from "../../services/i18n.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import linkService from "../../services/link.js";
import server from "../../services/server.js";
@ -100,8 +101,8 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
this.toggle(true);
this.$count.text(
`${resp.count} backlink`
+ (resp.count === 1 ? '' : 's')
// i18next plural
`${t('zpetne_odkazy.backlink', {count: resp.count})}`
);
}
@ -138,7 +139,7 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
}));
if (backlink.relationName) {
$item.append($("<p>").text(`relation: ${backlink.relationName}`));
$item.append($("<p>").text(`${t('zpetne_odkazy.relation')}: ${backlink.relationName}`));
}
else {
$item.append(...backlink.excerpts);

View File

@ -623,5 +623,32 @@
},
"note_launcher": {
"this_launcher_doesnt_define_target_note": "此启动器未定义目标笔记。"
},
"code_buttons": {
"execute_button_title": "执行脚本",
"trilium_api_docs_button_title": "打开 Trilium API 文档",
"save_to_note_button_title": "保存到笔记",
"opening_api_docs_message": "正在打开 API 文档...",
"sql_console_saved_message": "SQL 控制台已保存到 {{note_path}}"
},
"copy_image_reference_button": {
"button_title": "复制图片引用到剪贴板,可粘贴到文本笔记中。"
},
"hide_floating_buttons_button": {
"button_title": "隐藏按钮"
},
"mermaid_export_button": {
"button_title": "导出Mermaid图表为SVG"
},
"relation_map_buttons": {
"create_child_note_title": "创建新的子笔记并添加到关系图",
"reset_pan_zoom_title": "重置平移和缩放到初始坐标和放大倍率",
"zoom_in_title": "放大",
"zoom_out_title": "缩小"
},
"zpetne_odkazy": {
"backlink": "{{count}} 个反链",
"backlinks": "{{count}} 个反链",
"relation": "关系"
}
}

View File

@ -624,5 +624,32 @@
},
"note_launcher": {
"this_launcher_doesnt_define_target_note": "This launcher doesn't define target note."
},
"code_buttons": {
"execute_button_title": "Execute script",
"trilium_api_docs_button_title": "Open Trilium API docs",
"save_to_note_button_title": "Save to note",
"opening_api_docs_message": "Opening API docs...",
"sql_console_saved_message": "SQL Console note has been saved into {{note_path}}"
},
"copy_image_reference_button": {
"button_title": "Copy image reference to the clipboard, can be pasted into a text note."
},
"hide_floating_buttons_button": {
"button_title": "Hide buttons"
},
"mermaid_export_button": {
"button_title": "Export Mermaid diagram as SVG"
},
"relation_map_buttons": {
"create_child_note_title": "Create new child note and add it into this relation map",
"reset_pan_zoom_title": "Reset pan & zoom to initial coordinates and magnification",
"zoom_in_title": "Zoom In",
"zoom_out_title": "Zoom Out"
},
"zpetne_odkazy": {
"backlink": "{{count}} Backlink",
"backlinks": "{{count}} Backlinks",
"relation": "relation"
}
}