Skip to content

Build your personal knowledge base with Trilium Notes

add translation for ribbon widgets: search_definition.js

Nriver74c4634da2a1
diff --git a/src/public/app/widgets/ribbon_widgets/search_definition.js b/src/public/app/widgets/ribbon_widgets/search_definition.js
index 5d2afec4b5..b766e69c7c 100644
--- a/src/public/app/widgets/ribbon_widgets/search_definition.js
+++ b/src/public/app/widgets/ribbon_widgets/search_definition.js
@@ -1,3 +1,4 @@
+import { t } from "../../services/i18n.js";
import server from "../../services/server.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import froca from "../../services/froca.js";
@@ -73,54 +74,54 @@ const TPL = `
<div class="search-settings">
<table class="search-setting-table">
<tr>
- <td class="title-column">Add search option:</td>
+ <td class="title-column">${t('search_definition.add_search_option')}</td>
<td colspan="2" class="add-search-option">
<button type="button" class="btn btn-sm" data-search-option-add="searchString">
<span class="bx bx-text"></span>
- search string
+ ${t('search_definition.search_string')}
</button>
<button type="button" class="btn btn-sm" data-search-option-add="searchScript">
<span class="bx bx-code"></span>
- search script
+ ${t('search_definition.search_script')}
</button>
<button type="button" class="btn btn-sm" data-search-option-add="ancestor">
<span class="bx bx-filter-alt"></span>
- ancestor
+ ${t('search_definition.ancestor')}
</button>
<button type="button" class="btn btn-sm" data-search-option-add="fastSearch"
- title="Fast search option disables full text search of note contents which might speed up searching in large databases.">
+ title="${t('search_definition.fast_search_description')}">
<span class="bx bx-run"></span>
- fast search
+ ${t('search_definition.fast_search')}
</button>
<button type="button" class="btn btn-sm" data-search-option-add="includeArchivedNotes"
- title="Archived notes are by default excluded from search results, with this option they will be included.">
+ title="${t('search_definition.include_archived_notes_description')}">
<span class="bx bx-archive"></span>
- include archived
+ ${t('search_definition.include_archived')}
</button>
<button type="button" class="btn btn-sm" data-search-option-add="orderBy">
<span class="bx bx-arrow-from-top"></span>
- order by
+ ${t('search_definition.order_by')}
</button>
- <button type="button" class="btn btn-sm" data-search-option-add="limit" title="Limit number of results">
+ <button type="button" class="btn btn-sm" data-search-option-add="limit" title="${t('search_definition.limit_description')}">
<span class="bx bx-stop"></span>
- limit
+ ${t('search_definition.limit')}
</button>
- <button type="button" class="btn btn-sm" data-search-option-add="debug" title="Debug will print extra debugging information into the console to aid in debugging complex queries">
+ <button type="button" class="btn btn-sm" data-search-option-add="debug" title="${t('search_definition.debug_description')}">
<span class="bx bx-bug"></span>
- debug
+ ${t('search_definition.debug')}
</button>
<div class="dropdown" style="display: inline-block;">
<button class="btn btn-sm dropdown-toggle action-add-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="bx bxs-zap"></span>
- action
+ ${t('search_definition.action')}
</button>
<div class="dropdown-menu action-list"></div>
</div>
@@ -134,19 +135,19 @@ const TPL = `
<div style="display: flex; justify-content: space-evenly">
<button type="button" class="btn btn-sm search-button">
<span class="bx bx-search"></span>
- Search
+ ${t('search_definition.search')}
- <kbd>enter</kbd>
+ <kbd>${t('search_definition.enter')}</kbd>
</button>
<button type="button" class="btn btn-sm search-and-execute-button">
<span class="bx bxs-zap"></span>
- Search & Execute actions
+ ${t('search_definition.search_execute')}
</button>
<button type="button" class="btn btn-sm save-to-note-button">
<span class="bx bx-save"></span>
- Save to note
+ ${t('search_definition.save_to_note')}
</button>
</div>
</td>
@@ -180,7 +181,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
return {
show: this.isEnabled(),
activate: true,
- title: 'Search Parameters',
+ title: t('search_definition.search_parameters'),
icon: 'bx bx-search'
};
}
@@ -198,7 +199,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
this.$actionList.append(
$('<a class="dropdown-item" href="#">')
.attr('data-action-add', action.actionName)
- .text(action.actionTitle)
+ .text(t(`${action.actionTitle}`))
);
}
}
@@ -211,7 +212,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
await clazz.create(this.noteId);
}
else {
- logError(`Unknown search option ${searchOptionName}`);
+ logError(t('search_definition.unknown_search_option', { searchOptionName }));
}
this.refresh();
@@ -243,8 +244,9 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
await ws.waitForMaxKnownEntityChangeId();
await appContext.tabManager.getActiveContext().setNote(notePath);
-
- toastService.showMessage(`Search note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
+ // Note the {{- notePathTitle}} in json file is not typo, it's unescaping
+ // See https://www.i18next.com/translation-function/interpolation#unescape
+ toastService.showMessage(t('search_definition.search_note_saved', { notePathTitle: await treeService.getNotePathTitle(notePath) }));
});
}
@@ -307,7 +309,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
this.triggerCommand('refreshResults');
- toastService.showMessage('Actions have been executed.', 3000);
+ toastService.showMessage(t('search_definition.actions_executed'), 3000);
}
entitiesReloadedEvent({loadResults}) {
diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json
index c1fc35339d..1daa8968a4 100644
--- a/src/public/translations/cn/translation.json
+++ b/src/public/translations/cn/translation.json
@@ -752,5 +752,29 @@
"script": "脚本",
"execute_query": "执行查询",
"execute_script": "执行脚本"
+ },
+ "search_definition": {
+ "add_search_option": "添加搜索选项:",
+ "search_string": "搜索字符串",
+ "search_script": "搜索脚本",
+ "ancestor": "祖先",
+ "fast_search": "快速搜索",
+ "fast_search_description": "快速搜索选项禁用笔记内容的全文搜索,这可能会加速大数据库中的搜索。",
+ "include_archived": "包含归档",
+ "include_archived_notes_description": "归档的笔记默认不包含在搜索结果中,使用此选项将包含它们。",
+ "order_by": "排序方式",
+ "limit": "限制",
+ "limit_description": "限制结果数量",
+ "debug": "调试",
+ "debug_description": "调试将打印额外的调试信息到控制台,以帮助调试复杂查询",
+ "action": "操作",
+ "search": "搜索",
+ "enter": "输入",
+ "search_execute": "搜索并执行操作",
+ "save_to_note": "保存到笔记",
+ "search_parameters": "搜索参数",
+ "unknown_search_option": "未知的搜索选项 {{searchOptionName}}",
+ "search_note_saved": "搜索笔记已保存到 {{- notePathTitle}}",
+ "actions_executed": "操作已执行。"
}
}
diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json
index 094a5c09ec..969e23926f 100644
--- a/src/public/translations/en/translation.json
+++ b/src/public/translations/en/translation.json
@@ -753,5 +753,29 @@
"script": "Script",
"execute_query": "Execute Query",
"execute_script": "Execute Script"
+ },
+ "search_definition": {
+ "add_search_option": "Add search option:",
+ "search_string": "search string",
+ "search_script": "search script",
+ "ancestor": "ancestor",
+ "fast_search": "fast search",
+ "fast_search_description": "Fast search option disables full text search of note contents which might speed up searching in large databases.",
+ "include_archived": "include archived",
+ "include_archived_notes_description": "Archived notes are by default excluded from search results, with this option they will be included.",
+ "order_by": "order by",
+ "limit": "limit",
+ "limit_description": "Limit number of results",
+ "debug": "debug",
+ "debug_description": "Debug will print extra debugging information into the console to aid in debugging complex queries",
+ "action": "action",
+ "search": "Search",
+ "enter": "enter",
+ "search_execute": "Search & Execute actions",
+ "save_to_note": "Save to note",
+ "search_parameters": "Search Parameters",
+ "unknown_search_option": "Unknown search option {{searchOptionName}}",
+ "search_note_saved": "Search note has been saved into {{- notePathTitle}}",
+ "actions_executed": "Actions have been executed."
}
}