add translation for bulk action of relation

This commit is contained in:
Nriver 2024-07-30 10:06:54 +08:00
parent 50434201cf
commit 3ff361495e
6 changed files with 101 additions and 33 deletions

View File

@ -1,24 +1,25 @@
import SpacedUpdate from "../../../services/spaced_update.js";
import AbstractBulkAction from "../abstract_bulk_action.js";
import noteAutocompleteService from "../../../services/note_autocomplete.js";
import { t } from "../../../services/i18n.js";
const TPL = `
<tr>
<td colspan="2">
<div style="display: flex; align-items: center">
<div style="margin-right: 10px;" class="text-nowrap">Add relation</div>
<div style="margin-right: 10px;" class="text-nowrap">${t('add_relation.add_relation')}</div>
<input type="text"
class="form-control relation-name"
placeholder="relation name"
placeholder="${t('add_relation.relation_name')}"
pattern="[\\p{L}\\p{N}_:]+"
style="flex-shrink: 3"
title="Alphanumeric characters, underscore and colon are allowed characters."/>
title="${t('add_relation.allowed_characters')}"/>
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">to</div>
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${t('add_relation.to')}</div>
<div class="input-group" style="flex-shrink: 2">
<input type="text" class="form-control target-note" placeholder="target note"/>
<input type="text" class="form-control target-note" placeholder="${t('add_relation.target_note')}"/>
</div>
</div>
</td>
@ -26,7 +27,7 @@ const TPL = `
<div class="dropdown help-dropdown">
<span class="bx bx-help-circle icon-action" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
<div class="dropdown-menu dropdown-menu-right p-4">
<p>On all matched notes create given relation.</p>
<p>${t('add_relation.create_relation_on_all_matched_notes')}</p>
</div>
</div>
@ -36,7 +37,7 @@ const TPL = `
export default class AddRelationBulkAction extends AbstractBulkAction {
static get actionName() { return "addRelation"; }
static get actionTitle() { return "Add relation"; }
static get actionTitle() { return t('add_relation.add_relation'); }
doRender() {
const $action = $(TPL);
@ -55,7 +56,7 @@ export default class AddRelationBulkAction extends AbstractBulkAction {
relationName: $relationName.val(),
targetNoteId: $targetNote.getSelectedNoteId()
});
}, 1000)
}, 1000);
$relationName.on('input', () => spacedUpdate.scheduleUpdate());
$targetNote.on('input', () => spacedUpdate.scheduleUpdate());

View File

@ -1,18 +1,19 @@
import SpacedUpdate from "../../../services/spaced_update.js";
import AbstractBulkAction from "../abstract_bulk_action.js";
import { t } from "../../../services/i18n.js";
const TPL = `
<tr>
<td>
Delete relation:
${t('delete_relation.delete_relation')}
</td>
<td>
<div style="display: flex; align-items: center">
<input type="text"
class="form-control relation-name"
pattern="[\\p{L}\\p{N}_:]+"
placeholder="relation name"
title="Alphanumeric characters, underscore and colon are allowed characters."/>
placeholder="${t('delete_relation.relation_name')}"
title="${t('delete_relation.allowed_characters')}"/>
</div>
</td>
<td class="button-column">
@ -22,7 +23,7 @@ const TPL = `
export default class DeleteRelationBulkAction extends AbstractBulkAction {
static get actionName() { return "deleteRelation"; }
static get actionTitle() { return "Delete relation"; }
static get actionTitle() { return t('delete_relation.delete_relation'); }
doRender() {
const $action = $(TPL);
@ -31,7 +32,7 @@ export default class DeleteRelationBulkAction extends AbstractBulkAction {
const spacedUpdate = new SpacedUpdate(async () => {
await this.saveAction({ relationName: $relationName.val() });
}, 1000)
}, 1000);
$relationName.on('input', () => spacedUpdate.scheduleUpdate());

View File

@ -1,25 +1,26 @@
import SpacedUpdate from "../../../services/spaced_update.js";
import AbstractBulkAction from "../abstract_bulk_action.js";
import { t } from "../../../services/i18n.js";
const TPL = `
<tr>
<td colspan="2">
<div style="display: flex; align-items: center">
<div style="margin-right: 10px; flex-shrink: 0;">Rename relation from:</div>
<div style="margin-right: 10px; flex-shrink: 0;">${t('rename_relation.rename_relation_from')}</div>
<input type="text"
class="form-control old-relation-name"
placeholder="old name"
placeholder="${t('rename_relation.old_name')}"
pattern="[\\p{L}\\p{N}_:]+"
title="Alphanumeric characters, underscore and colon are allowed characters."/>
title="${t('rename_relation.allowed_characters')}"/>
<div style="margin-right: 10px; margin-left: 10px;">To:</div>
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${t('rename_relation.to')}</div>
<input type="text"
class="form-control new-relation-name"
placeholder="new name"
placeholder="${t('rename_relation.new_name')}"
pattern="[\\p{L}\\p{N}_:]+"
title="Alphanumeric characters, underscore and colon are allowed characters."/>
title="${t('rename_relation.allowed_characters')}"/>
</div>
</td>
<td class="button-column">
@ -29,7 +30,7 @@ const TPL = `
export default class RenameRelationBulkAction extends AbstractBulkAction {
static get actionName() { return "renameRelation"; }
static get actionTitle() { return "Rename relation"; }
static get actionTitle() { return t('rename_relation.rename_relation'); }
doRender() {
const $action = $(TPL);
@ -45,7 +46,7 @@ export default class RenameRelationBulkAction extends AbstractBulkAction {
oldRelationName: $oldRelationName.val(),
newRelationName: $newRelationName.val()
});
}, 1000)
}, 1000);
$oldRelationName.on('input', () => spacedUpdate.scheduleUpdate());
$newRelationName.on('input', () => spacedUpdate.scheduleUpdate());

View File

@ -1,24 +1,25 @@
import SpacedUpdate from "../../../services/spaced_update.js";
import AbstractBulkAction from "../abstract_bulk_action.js";
import noteAutocompleteService from "../../../services/note_autocomplete.js";
import { t } from "../../../services/i18n.js";
const TPL = `
<tr>
<td colspan="2">
<div style="display: flex; align-items: center">
<div style="margin-right: 10px;" class="text-nowrap">Update relation</div>
<div style="margin-right: 10px;" class="text-nowrap">${t('update_relation_target.update_relation')}</div>
<input type="text"
class="form-control relation-name"
placeholder="relation name"
placeholder="${t('update_relation_target.relation_name')}"
pattern="[\\p{L}\\p{N}_:]+"
style="flex-shrink: 3"
title="Alphanumeric characters, underscore and colon are allowed characters."/>
title="${t('update_relation_target.allowed_characters')}"/>
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">to</div>
<div style="margin-right: 10px; margin-left: 10px;" class="text-nowrap">${t('update_relation_target.to')}</div>
<div class="input-group" style="flex-shrink: 2">
<input type="text" class="form-control target-note" placeholder="target note"/>
<input type="text" class="form-control target-note" placeholder="${t('update_relation_target.target_note')}"/>
</div>
</div>
</td>
@ -26,11 +27,11 @@ const TPL = `
<div class="dropdown help-dropdown">
<span class="bx bx-help-circle icon-action" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
<div class="dropdown-menu dropdown-menu-right p-4">
<p>On all matched notes:</p>
<p>${t('update_relation_target.on_all_matched_notes')}:</p>
<ul>
<li>create given relation if note doesn't have one yet</li>
<li>or change target note of the existing relation</li>
<li>${t('update_relation_target.create_given_relation')}</li>
<li>${t('update_relation_target.change_target_note')}</li>
</ul>
</div>
</div>
@ -41,7 +42,7 @@ const TPL = `
export default class UpdateRelationTargetBulkAction extends AbstractBulkAction {
static get actionName() { return "updateRelationTarget"; }
static get actionTitle() { return "Update relation target"; }
static get actionTitle() { return t('update_relation_target.update_relation_target'); }
doRender() {
const $action = $(TPL);
@ -60,7 +61,7 @@ export default class UpdateRelationTargetBulkAction extends AbstractBulkAction {
relationName: $relationName.val(),
targetNoteId: $targetNote.getSelectedNoteId()
});
}, 1000)
}, 1000);
$relationName.on('input', () => spacedUpdate.scheduleUpdate());
$targetNote.on('input', () => spacedUpdate.scheduleUpdate());

View File

@ -428,6 +428,7 @@
"label_name_title": "允许使用字母、数字、下划线和冒号。"
},
"rename_label": {
"rename_label": "重命名标签",
"rename_label_from": "重命名标签从",
"old_name_placeholder": "旧名称",
"to": "改为",
@ -463,7 +464,7 @@
"nothing_will_happen": "如果笔记无法移动到目标笔记(即这会创建一个树循环),则不会发生任何事情"
},
"rename_note": {
"rename_note_title_to": "重命名笔记标题为",
"rename_note_title_to": "重命名笔记标题为",
"new_note_title": "新笔记标题",
"click_help_icon": "点击右侧的帮助图标查看所有选项",
"evaluated_as_js_string": "给定的值被评估为JavaScript字符串因此可以通过注入的<code>note</code>变量(正在重命名的笔记)丰富动态内容。 例如:",
@ -471,5 +472,36 @@
"example_new_title": "<code>NEW: ${note.title}</code> - 匹配的笔记标题以“NEW: ”为前缀",
"example_date_prefix": "<code>${note.dateCreatedObj.format('MM-DD:')}: ${note.title}</code> - 匹配的笔记以笔记的创建月份-日期为前缀",
"api_docs": "有关详细信息,请参阅<a href='https://zadam.github.io/trilium/backend_api/Note.html'>笔记</a>及其<a href='https://day.js.org/docs/en/display/format'>dateCreatedObj / utcDateCreatedObj 属性</a>的API文档。"
},
"add_relation": {
"add_relation": "添加关系",
"relation_name": "关系名称",
"allowed_characters": "允许的字符为字母数字、下划线和冒号。",
"to": "到",
"target_note": "目标笔记",
"create_relation_on_all_matched_notes": "在所有匹配的笔记上创建指定的关系。"
},
"delete_relation": {
"delete_relation": "删除关系",
"relation_name": "关系名称",
"allowed_characters": "允许的字符为字母数字、下划线和冒号。"
},
"rename_relation": {
"rename_relation_from": "重命名关系,从",
"old_name": "旧名称",
"to": "改为",
"new_name": "新名称",
"allowed_characters": "允许的字符为字母数字、下划线和冒号。"
},
"update_relation_target": {
"update_relation": "更新关系",
"relation_name": "关系名称",
"allowed_characters": "允许的字符为字母数字、下划线和冒号。",
"to": "到",
"target_note": "目标笔记",
"on_all_matched_notes": "在所有匹配的笔记上",
"create_given_relation": "如果笔记还没有关系,则创建给定关系",
"change_target_note": "或更改现有关系的目标笔记",
"update_relation_target": "更新关系目标"
}
}

View File

@ -428,6 +428,7 @@
"label_name_title": "Alphanumeric characters, underscore and colon are allowed characters."
},
"rename_label": {
"rename_label": "Rename label",
"rename_label_from": "Rename label from",
"old_name_placeholder": "old name",
"to": "To",
@ -463,7 +464,7 @@
"nothing_will_happen": "nothing will happen if note cannot be moved to the target note (i.e. this would create a tree cycle)"
},
"rename_note": {
"rename_note_title_to": "Rename note title to:",
"rename_note_title_to": "Rename note title to",
"new_note_title": "new note title",
"click_help_icon": "Click help icon on the right to see all the options",
"evaluated_as_js_string": "The given value is evaluated as JavaScript string and thus can be enriched with dynamic content via the injected <code>note</code> variable (note being renamed). Examples:",
@ -471,5 +472,36 @@
"example_new_title": "<code>NEW: ${note.title}</code> - matched notes titles are prefixed with 'NEW: '",
"example_date_prefix": "<code>${note.dateCreatedObj.format('MM-DD:')}: ${note.title}</code> - matched notes are prefixed with note's creation month-date",
"api_docs": "See API docs for <a href='https://zadam.github.io/trilium/backend_api/Note.html'>note</a> and its <a href='https://day.js.org/docs/en/display/format'>dateCreatedObj / utcDateCreatedObj properties</a> for details."
},
"add_relation": {
"add_relation": "Add relation",
"relation_name": "relation name",
"allowed_characters": "Alphanumeric characters, underscore and colon are allowed characters.",
"to": "to",
"target_note": "target note",
"create_relation_on_all_matched_notes": "On all matched notes create given relation."
},
"delete_relation": {
"delete_relation": "Delete relation",
"relation_name": "relation name",
"allowed_characters": "Alphanumeric characters, underscore and colon are allowed characters."
},
"rename_relation": {
"rename_relation_from": "Rename relation from",
"old_name": "old name",
"to": "To",
"new_name": "new name",
"allowed_characters": "Alphanumeric characters, underscore and colon are allowed characters."
},
"update_relation_target": {
"update_relation": "Update relation",
"relation_name": "relation name",
"allowed_characters": "Alphanumeric characters, underscore and colon are allowed characters.",
"to": "to",
"target_note": "target note",
"on_all_matched_notes": "On all matched notes",
"create_given_relation": "create given relation if note doesn't have one yet",
"change_target_note": "or change target note of the existing relation",
"update_relation_target": "Update relation target"
}
}