diff --git a/src/public/app/components/app_context.js b/src/public/app/components/app_context.js index 04c11e8b7..6e571d50a 100644 --- a/src/public/app/components/app_context.js +++ b/src/public/app/components/app_context.js @@ -13,7 +13,7 @@ import MobileScreenSwitcherExecutor from "./mobile_screen_switcher.js"; import MainTreeExecutors from "./main_tree_executors.js"; import toast from "../services/toast.js"; import ShortcutComponent from "./shortcut_component.js"; -import { initLocale } from "../services/i18n.js"; +import { t, initLocale } from "../services/i18n.js"; class AppContext extends Component { constructor(isMainWindow) { @@ -33,11 +33,11 @@ class AppContext extends Component { await initLocale(); } - setLayout(layout) { + setLayout(layout) { this.layout = layout; } - async start() { + async start() { this.initComponents(); this.renderWidgets(); @@ -151,7 +151,7 @@ $(window).on('beforeunload', () => { if (!component.beforeUnloadEvent()) { console.log(`Component ${component.componentId} is not finished saving its state.`); - toast.showMessage("Please wait for a couple of seconds for the save to finish, then you can try again.", 10000); + toast.showMessage(t("app_context.please_wait_for_save"), 10000); allSaved = false; } diff --git a/src/public/app/menus/tree_context_menu.js b/src/public/app/menus/tree_context_menu.js index 684b31c99..caa572816 100644 --- a/src/public/app/menus/tree_context_menu.js +++ b/src/public/app/menus/tree_context_menu.js @@ -62,8 +62,8 @@ export default class TreeContextMenu { { title: "----" }, { title: `${t("tree-context-menu.search-in-subtree")} `, command: "searchInSubtree", uiIcon: "bx bx-search", enabled: notSearch && noSelectedNotes }, - isHoisted ? null : { title: 'Hoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, - !isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, + isHoisted ? null : { title: `${t("tree-context-menu.hoist-note")} `, command: "toggleNoteHoisting", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, + !isHoisted || !isNotRoot ? null : { title: `${t("tree-context-menu.unhoist-note")} `, command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, { title: `${t("tree-context-menu.edit-branch-prefix")} `, command: "editBranchPrefix", uiIcon: "bx bx-empty", enabled: isNotRoot && parentNotSearch && noSelectedNotes && notOptions }, { title: t("tree-context-menu.advanced"), uiIcon: "bx bx-empty", enabled: true, items: [ diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index e47a1ee33..395dd51d5 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -1,3 +1,4 @@ +import { t } from "../services/i18n.js"; import BasicWidget from "./basic_widget.js"; import contextMenu from "../menus/context_menu.js"; import utils from "../services/utils.js"; @@ -37,11 +38,11 @@ const TAB_TPL = `
-
+
`; -const NEW_TAB_BUTTON_TPL = `
+
`; +const NEW_TAB_BUTTON_TPL = `
+
`; const FILLER_TPL = `
`; const TAB_ROW_TPL = ` @@ -258,10 +259,10 @@ export default class TabRowWidget extends BasicWidget { x: e.pageX, y: e.pageY, items: [ - {title: "Close", command: "closeTab", uiIcon: "bx bx-x"}, - {title: "Close other tabs", command: "closeOtherTabs", uiIcon: "bx bx-x"}, - {title: "Close all tabs", command: "closeAllTabs", uiIcon: "bx bx-x"}, - {title: "Move this tab to a new window", command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"} + {title: t('tab_row.close'), command: "closeTab", uiIcon: "bx bx-x"}, + {title: t('tab_row.close_other_tabs'), command: "closeOtherTabs", uiIcon: "bx bx-x"}, + {title: t('tab_row.close_all_tabs'), command: "closeAllTabs", uiIcon: "bx bx-x"}, + {title: t('tab_row.move_tab_to_new_window'), command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"} ], selectMenuItemHandler: ({command}) => { this.triggerCommand(command, {ntxId}); @@ -387,7 +388,7 @@ export default class TabRowWidget extends BasicWidget { this.$newTab.before($tab); this.setVisibility(); this.setTabCloseEvent($tab); - this.updateTitle($tab, 'New tab'); + this.updateTitle($tab, t('tab_row.new_tab')); this.cleanUpPreviouslyDraggedTabs(); this.layoutTabs(); this.setupDraggabilly(); @@ -672,7 +673,7 @@ export default class TabRowWidget extends BasicWidget { const {note} = noteContext; if (!note) { - this.updateTitle($tab, 'New tab'); + this.updateTitle($tab, t('tab_row.new_tab')); return; } diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js index e4b4a036b..3968c1164 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.js @@ -13,7 +13,7 @@ * to the wrong heading (although what "right" means in those cases is not * clear), but it won't crash. */ - +import { t } from "../services/i18n.js"; import attributeService from "../services/attributes.js"; import RightPanelWidget from "./right_panel_widget.js"; import options from "../services/options.js"; @@ -55,14 +55,14 @@ const TPL = `
export default class TocWidget extends RightPanelWidget { get widgetTitle() { - return "Table of Contents"; + return t("toc.table_of_contents"); } get widgetButtons() { return [ new OnClickButtonWidget() .icon("bx-cog") - .title("Options") + .title(t("toc.options")) .titlePlacement("left") .onClick(() => appContext.tabManager.openContextWithNote('_optionsTextNotes', {activate: true})) .class("icon-action"), @@ -125,18 +125,18 @@ export default class TocWidget extends RightPanelWidget { * * @param {string} html Note's html content * @returns {string} The HTML content with mathematical formulas rendered by KaTeX. - */ + */ async replaceMathTextWithKatax(html) { const mathTextRegex = /\\\(([\s\S]*?)\\\)<\/span>/g; var matches = [...html.matchAll(mathTextRegex)]; let modifiedText = html; - + if (matches.length > 0) { // Process all matches asynchronously for (const match of matches) { let latexCode = match[1]; let rendered; - + try { rendered = katex.renderToString(latexCode, { throwOnError: false @@ -158,7 +158,7 @@ export default class TocWidget extends RightPanelWidget { rendered = match[0]; // Fall back to original on error } } - + // Replace the matched formula in the modified text modifiedText = modifiedText.replace(match[0], rendered); } diff --git a/src/public/app/widgets/watched_file_update_status.js b/src/public/app/widgets/watched_file_update_status.js index 05e5567e7..1747723d5 100644 --- a/src/public/app/widgets/watched_file_update_status.js +++ b/src/public/app/widgets/watched_file_update_status.js @@ -1,3 +1,4 @@ +import { t } from "../services/i18n.js"; import NoteContextAwareWidget from "./note_context_aware_widget.js"; import server from "../services/server.js"; import fileWatcher from "../services/file_watcher.js"; @@ -11,12 +12,12 @@ const TPL = ` } -

File has been last modified on .

+

${t("watched_file_update_status.file_last_modified", { count: '' })}

- + - +
`; diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 99b082f34..ecad19c86 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -247,6 +247,9 @@ "revisions_deleted": "笔记历史版本已删除。", "revision_restored": "笔记历史版本已恢复。", "revision_deleted": "笔记历史版本已删除。", + "snapshot_interval": "笔记快照保存间隔: {{seconds}}秒。", + "maximum_revisions": "当前笔记的最历史数量: {{number}}。", + "settings": "笔记历史设置", "download_button": "下载", "mime": "MIME类型:", "file_size": "文件大小:", @@ -1090,6 +1093,13 @@ "note_revisions_snapshot_description": "笔记修改快照时间间隔是指经过多少秒后会为笔记创建新的修改历史。更多信息请参见wiki。", "snapshot_time_interval_label": "笔记修改快照时间间隔(单位:秒)" }, + "revisions_snapshot_limit": { + "note_revisions_snapshot_limit_title": "笔记历史快照限制", + "note_revisions_snapshot_limit_description": "笔记历史快照数限制指的是每个笔记可以保存的最大历史记录数量。其中 -1 表示没有限制,0 表示删除所有历史记录。你可以通过 #versioningLimit 标签设置单个笔记的最大历史记录数量。", + "snapshot_number_limit_label": "笔记历史快照数量限制:", + "erase_excess_revision_snapshots": "立即删除多余的历史快照", + "erase_excess_revision_snapshots_prompt": "多余的历史快照已被删除。" + }, "search_engine": { "title": "搜索引擎", "custom_search_engine_info": "自定义搜索引擎需要设置名称和URL。如果这两者之一未设置,将默认使用DuckDuckGo作为搜索引擎。", @@ -1280,6 +1290,8 @@ "insert-child-note": "插入子笔记", "delete": "删除", "search-in-subtree": "在子树中搜索", + "hoist-note": "提升笔记", + "unhoist-note": "取消提升笔记", "edit-branch-prefix": "编辑分支前缀", "advanced": "高级", "expand-subtree": "展开子树", @@ -1391,5 +1403,26 @@ }, "sql_table_schemas": { "tables": "表" + }, + "tab_row": { + "close_tab": "关闭标签页", + "add_new_tab": "添加新标签页", + "close": "关闭", + "close_other_tabs": "关闭其他标签页", + "close_all_tabs": "关闭所有标签页", + "move_tab_to_new_window": "将此标签页移动到新窗口", + "new_tab": "新标签页" + }, + "toc": { + "table_of_contents": "目录", + "options": "选项" + }, + "watched_file_update_status": { + "file_last_modified": "文件 最后修改时间为 。", + "upload_modified_file": "上传修改的文件", + "ignore_this_change": "忽略此更改" + }, + "app_context": { + "please_wait_for_save": "请等待几秒钟以完成保存,然后您可以尝试再操作一次。" } } diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 965f0d2f5..4255a1f5d 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1290,6 +1290,8 @@ "insert-child-note": "Insert child note", "delete": "Delete", "search-in-subtree": "Search in subtree", + "hoist-note": "Hoist note", + "unhoist-note": "Unhoist note", "edit-branch-prefix": "Edit branch prefix", "advanced": "Advanced", "expand-subtree": "Expand subtree", @@ -1401,5 +1403,26 @@ }, "sql_table_schemas": { "tables": "Tables" + }, + "tab_row": { + "close_tab": "Close tab", + "add_new_tab": "Add new tab", + "close": "Close", + "close_other_tabs": "Close other tabs", + "close_all_tabs": "Close all tabs", + "move_tab_to_new_window": "Move this tab to a new window", + "new_tab": "New tab" + }, + "toc": { + "table_of_contents": "Table of Contents", + "options": "Options" + }, + "watched_file_update_status": { + "file_last_modified": "File has been last modified on .", + "upload_modified_file": "Upload modified file", + "ignore_this_change": "Ignore this change" + }, + "app_context": { + "please_wait_for_save": "Please wait for a couple of seconds for the save to finish, then you can try again." } }