diff --git a/src/public/app/widgets/type_widgets/relation_map.js b/src/public/app/widgets/type_widgets/relation_map.js index beb16ff07..c1511f8bd 100644 --- a/src/public/app/widgets/type_widgets/relation_map.js +++ b/src/public/app/widgets/type_widgets/relation_map.js @@ -9,6 +9,7 @@ import appContext from "../../components/app_context.js"; import utils from "../../services/utils.js"; import froca from "../../services/froca.js"; import dialogService from "../../services/dialog.js"; +import { t } from "../../services/i18n.js"; const uniDirectionalOverlays = [ [ "Arrow", { @@ -113,9 +114,9 @@ export default class RelationMapTypeWidget extends TypeWidget { x: e.pageX, y: e.pageY, items: [ - {title: "Open in new tab", command: "openInNewTab", uiIcon: "bx bx-empty"}, - {title: "Remove note", command: "remove", uiIcon: "bx bx-trash"}, - {title: "Edit title", command: "editTitle", uiIcon: "bx bx-pencil"}, + { title: t("relation_map.open_in_new_tab"), command: "openInNewTab", uiIcon: "bx bx-empty" }, + { title: t("relation_map.remove_note"), command: "remove", uiIcon: "bx bx-trash" }, + { title: t("relation_map.edit_title"), command: "editTitle", uiIcon: "bx bx-pencil" } ], selectMenuItemHandler: ({command}) => this.contextMenuHandler(command, e.target) }); @@ -168,8 +169,8 @@ export default class RelationMapTypeWidget extends TypeWidget { } else if (command === "editTitle") { const title = await dialogService.prompt({ - title: "Rename note", - message: "Enter new note title:", + title: t("relation_map.rename_note"), + message: t("relation_map.enter_new_title"), defaultValue: $title.text() }); @@ -392,10 +393,10 @@ export default class RelationMapTypeWidget extends TypeWidget { contextMenu.show({ x: event.pageX, y: event.pageY, - items: [ {title: "Remove relation", command: "remove", uiIcon: "bx bx-trash"} ], + items: [{title: t("relation_map.remove_relation"), command: "remove", uiIcon: "bx bx-trash"}], selectMenuItemHandler: async ({command}) => { if (command === 'remove') { - if (!await dialogService.confirm("Are you sure you want to remove the relation?")) { + if (!await dialogService.confirm(t("relation_map.confirm_remove_relation"))) { return; } @@ -418,7 +419,7 @@ export default class RelationMapTypeWidget extends TypeWidget { } let name = await dialogService.prompt({ - message: "Specify new relation name (allowed characters: alphanumeric, colon and underscore):", + message: t("relation_map.specify_new_relation_name"), shown: ({ $answer }) => { $answer.on('keyup', () => { // invalid characters are simply ignored (from user perspective they are not even entered) @@ -452,7 +453,7 @@ export default class RelationMapTypeWidget extends TypeWidget { && rel.name === name); if (relationExists) { - await dialogService.info(`Connection '${name}' between these notes already exists.`); + await dialogService.info(t("relation_map.connection_exists", {name})); this.jsPlumbInstance.deleteConnection(connection); @@ -479,7 +480,7 @@ export default class RelationMapTypeWidget extends TypeWidget { .addClass(note.getCssClass()) .prop("id", this.noteIdToId(noteId)) .append($("").addClass("title").append($link)) - .append($("
").addClass("endpoint").attr("title", "Start dragging relations from here and drop them on another note.")) + .append($("
").addClass("endpoint").attr("title", t("relation_map.start_dragging_relations"))) .css("left", `${x}px`) .css("top", `${y}px`); @@ -494,7 +495,7 @@ export default class RelationMapTypeWidget extends TypeWidget { const note = this.mapData.notes.find(note => note.noteId === noteId); if (!note) { - logError(`Note ${noteId} not found!`); + logError(t("relation_map.note_not_found", {noteId})); return; } @@ -533,7 +534,7 @@ export default class RelationMapTypeWidget extends TypeWidget { const matches = transform.match(matrixRegex); if (!matches) { - throw new Error(`Cannot match transform: ${transform}`); + throw new Error(t("relation_map.cannot_match_transform", {transform})); } return matches[1]; @@ -550,8 +551,7 @@ export default class RelationMapTypeWidget extends TypeWidget { const exists = this.mapData.notes.some(n => n.noteId === note.noteId); if (exists) { - toastService.showError(`Note "${note.title}" is already in the diagram.`); - + toastService.showError(t("relation_map.note_already_in_diagram", {title: note.title})); continue; } @@ -593,7 +593,7 @@ export default class RelationMapTypeWidget extends TypeWidget { return; } - const title = await dialogService.prompt({ message: "Enter title of new note", defaultValue: "new note" }); + const title = await dialogService.prompt({ message: t("relation_map.enter_title_of_new_note"), defaultValue: t("relation_map.default_new_note_title") }); if (!title.trim()) { return; @@ -605,7 +605,7 @@ export default class RelationMapTypeWidget extends TypeWidget { type: 'text' }); - toastService.showMessage("Click on canvas to place new note"); + toastService.showMessage(t("relation_map.click_on_canvas_to_place_new_note")); this.clipboard = { noteId: note.noteId, title }; } diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 2f2ecd695..efeec1783 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -887,5 +887,23 @@ "protected_session": { "enter_password_instruction": "显示受保护的笔记需要输入您的密码:", "start_session_button": "开始受保护的会话" + }, + "relation_map": { + "open_in_new_tab": "在新标签页中打开", + "remove_note": "删除笔记", + "edit_title": "编辑标题", + "rename_note": "重命名笔记", + "enter_new_title": "输入新的笔记标题:", + "remove_relation": "删除关系", + "confirm_remove_relation": "你确定要删除这个关系吗?", + "specify_new_relation_name": "指定新的关系名称(允许的字符:字母数字、冒号和下划线):", + "connection_exists": "笔记之间的连接 '{{name}}' 已经存在。", + "start_dragging_relations": "从这里开始拖动关系,并将其放置到另一个笔记上。", + "note_not_found": "笔记 {{noteId}} 未找到!", + "cannot_match_transform": "无法匹配变换:{{transform}}", + "note_already_in_diagram": "笔记 \"{{title}}\" 已经在图中。", + "enter_title_of_new_note": "输入新笔记的标题", + "default_new_note_title": "新笔记", + "click_on_canvas_to_place_new_note": "点击画布以放置新笔记" } } diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 9ec0a91ad..089da509c 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -888,5 +888,23 @@ "protected_session": { "enter_password_instruction": "Showing protected note requires entering your password:", "start_session_button": "Start protected session" + }, + "relation_map": { + "open_in_new_tab": "Open in new tab", + "remove_note": "Remove note", + "edit_title": "Edit title", + "rename_note": "Rename note", + "enter_new_title": "Enter new note title:", + "remove_relation": "Remove relation", + "confirm_remove_relation": "Are you sure you want to remove the relation?", + "specify_new_relation_name": "Specify new relation name (allowed characters: alphanumeric, colon and underscore):", + "connection_exists": "Connection '{{name}}' between these notes already exists.", + "start_dragging_relations": "Start dragging relations from here and drop them on another note.", + "note_not_found": "Note {{noteId}} not found!", + "cannot_match_transform": "Cannot match transform: {{transform}}", + "note_already_in_diagram": "Note \"{{title}}\" is already in the diagram.", + "enter_title_of_new_note": "Enter title of new note", + "default_new_note_title": "new note", + "click_on_canvas_to_place_new_note": "Click on canvas to place new note" } }