From 40f74656f381d74213fae225e7a3137764fa14c4 Mon Sep 17 00:00:00 2001
From: Nriver <6752679+Nriver@users.noreply.github.com>
Date: Wed, 7 Aug 2024 10:16:27 +0800
Subject: [PATCH] add translation for all 9 search option files
---
.../search_options/abstract_search_option.js | 5 +-
.../app/widgets/search_options/ancestor.js | 63 ++++++++--------
.../app/widgets/search_options/debug.js | 10 +--
.../app/widgets/search_options/fast_search.js | 7 +-
.../search_options/include_archived_notes.js | 4 +-
.../app/widgets/search_options/limit.js | 6 +-
.../app/widgets/search_options/order_by.js | 36 ++++-----
.../widgets/search_options/search_script.js | 25 +++----
.../widgets/search_options/search_string.js | 23 +++---
src/public/translations/cn/translation.json | 75 ++++++++++++++++++-
src/public/translations/en/translation.json | 73 ++++++++++++++++++
11 files changed, 233 insertions(+), 94 deletions(-)
diff --git a/src/public/app/widgets/search_options/abstract_search_option.js b/src/public/app/widgets/search_options/abstract_search_option.js
index e46299d1a..17b6873bb 100644
--- a/src/public/app/widgets/search_options/abstract_search_option.js
+++ b/src/public/app/widgets/search_options/abstract_search_option.js
@@ -2,6 +2,7 @@ import server from "../../services/server.js";
import ws from "../../services/ws.js";
import Component from "../../components/component.js";
import utils from "../../services/utils.js";
+import { t } from "../../services/i18n.js"; // 新增的导入
export default class AbstractSearchOption extends Component {
constructor(attribute, note) {
@@ -27,14 +28,14 @@ export default class AbstractSearchOption extends Component {
$rendered.find('.search-option-del')
.on('click', () => this.deleteOption())
- .attr('title', 'Remove this search option');
+ .attr('title', t('abstract_search_option.remove_this_search_option')); // 使用 t 函数处理 i18n 字符串
utils.initHelpDropdown($rendered);
return $rendered;
}
catch (e) {
- logError(`Failed rendering search option: ${JSON.stringify(this.attribute.dto)} with error: ${e.message} ${e.stack}`);
+ logError(t('abstract_search_option.failed_rendering', { dto: JSON.stringify(this.attribute.dto), error: e.message, stack: e.stack })); // 使用 t 函数处理 i18n 字符串
return null;
}
}
diff --git a/src/public/app/widgets/search_options/ancestor.js b/src/public/app/widgets/search_options/ancestor.js
index d2a252882..49aa75faf 100644
--- a/src/public/app/widgets/search_options/ancestor.js
+++ b/src/public/app/widgets/search_options/ancestor.js
@@ -1,46 +1,47 @@
import AbstractSearchOption from "./abstract_search_option.js";
import noteAutocompleteService from "../../services/note_autocomplete.js";
+import { t } from "../../services/i18n.js";
const TPL = `
- Search string: |
+ ${t('search_string.title_column')} |
-
+
|
@@ -76,7 +77,7 @@ export default class SearchString extends AbstractSearchOption {
showSearchErrorEvent({error}) {
this.$searchString.tooltip({
trigger: 'manual',
- title: `Search error: ${error}`,
+ title: `${t('search_string.error', {error})}`,
placement: 'bottom'
});
diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json
index 9155f92ea..6e73be290 100644
--- a/src/public/translations/cn/translation.json
+++ b/src/public/translations/cn/translation.json
@@ -712,7 +712,7 @@
"modified": "修改时间",
"type": "类型",
"note_size": "笔记大小",
- "note_size_info": "笔记大小提供了该笔记存储需求的粗略估计。它考虑了笔记的内容及其笔记修订的内容。",
+ "note_size_info": "笔记大小提供了该笔记存储需求的粗略估计。它考虑了笔记的内容及其笔记历史的内容。",
"calculate": "计算",
"subtree_size": "(子树大小: {{size}}, 共计 {{count}} 个笔记)",
"title": "笔记信息"
@@ -780,5 +780,78 @@
"similar_notes": {
"title": "相似笔记",
"no_similar_notes_found": "未找到相似的笔记。"
+ },
+ "abstract_search_option": {
+ "remove_this_search_option": "删除此搜索选项",
+ "failed_rendering": "渲染搜索选项失败:{{dto}},错误信息:{{error}},堆栈:{{stack}}"
+ },
+ "ancestor": {
+ "label": "祖先",
+ "placeholder": "按名称搜索笔记",
+ "depth_label": "深度",
+ "depth_doesnt_matter": "任意",
+ "depth_eq": "正好是 {{count}}",
+ "direct_children": "直接子代",
+ "depth_gt": "大于 {{count}}",
+ "depth_lt": "小于 {{count}}"
+ },
+ "debug": {
+ "debug": "调试",
+ "debug_info": "调试将打印额外的调试信息到控制台,以帮助调试复杂的查询。",
+ "access_info": "要访问调试信息,请执行查询并点击左上角的“显示后端日志”。"
+ },
+ "fast_search": {
+ "fast_search": "快速搜索",
+ "description": "快速搜索选项禁用笔记内容的全文搜索,这可能会加快在大型数据库中的搜索速度。"
+ },
+ "include_archived_notes": {
+ "include_archived_notes": "包括已归档的笔记"
+ },
+ "limit": {
+ "limit": "限制",
+ "take_first_x_results": "仅取前X个指定结果。"
+ },
+ "order_by": {
+ "order_by": "排序依据",
+ "relevancy": "相关性(默认)",
+ "title": "标题",
+ "date_created": "创建日期",
+ "date_modified": "最后修改日期",
+ "content_size": "笔记内容大小",
+ "content_and_attachments_size": "笔记内容大小(包括附件)",
+ "content_and_attachments_and_revisions_size": "笔记内容大小(包括附件和笔记历史)",
+ "revision_count": "历史数量",
+ "children_count": "子笔记数量",
+ "parent_count": "克隆数量",
+ "owned_label_count": "标签数量",
+ "owned_relation_count": "关系数量",
+ "target_relation_count": "指向笔记的关系数量",
+ "random": "随机顺序",
+ "asc": "升序(默认)",
+ "desc": "降序"
+ },
+ "search_script": {
+ "title": "搜索脚本:",
+ "placeholder": "按名称搜索笔记",
+ "description1": "搜索脚本允许通过运行脚本来定义搜索结果。这在标准搜索不足时提供了最大的灵活性。",
+ "description2": "搜索脚本必须是类型为\"代码\"和子类型为\"JavaScript后端\"。脚本需要返回一个noteIds或notes数组。",
+ "example_title": "请看这个例子:",
+ "example_code": "// 1. 使用标准搜索进行预过滤\nconst candidateNotes = api.searchForNotes(\"#journal\"); \n\n// 2. 应用自定义搜索条件\nconst matchedNotes = candidateNotes\n .filter(note => note.title.match(/[0-9]{1,2}\\. ?[0-9]{1,2}\\. ?[0-9]{4}/));\n\nreturn matchedNotes;",
+ "note": "注意,搜索脚本和搜索字符串不能相互结合使用。"
+ },
+ "search_string": {
+ "title_column": "搜索字符串:",
+ "placeholder": "全文关键词,#标签 = 值 ...",
+ "search_syntax": "搜索语法",
+ "also_see": "另见",
+ "complete_help": "完整的搜索语法帮助",
+ "full_text_search": "只需输入任何文本进行全文搜索",
+ "label_abc": "返回带有标签abc的笔记",
+ "label_year": "匹配带有标签年份且值为2019的笔记",
+ "label_rock_pop": "匹配同时具有rock和pop标签的笔记",
+ "label_rock_or_pop": "只需一个标签存在即可",
+ "label_year_comparison": "数字比较(也包括>,>=,<)。",
+ "label_date_created": "上个月创建的笔记",
+ "error": "搜索错误:{{error}}"
}
}
diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json
index 329f2aa41..67a753820 100644
--- a/src/public/translations/en/translation.json
+++ b/src/public/translations/en/translation.json
@@ -781,5 +781,78 @@
"similar_notes": {
"title": "Similar Notes",
"no_similar_notes_found": "No similar notes found."
+ },
+ "abstract_search_option": {
+ "remove_this_search_option": "Remove this search option",
+ "failed_rendering": "Failed rendering search option: {{dto}} with error: {{error}} {{stack}}"
+ },
+ "ancestor": {
+ "label": "Ancestor",
+ "placeholder": "search for note by its name",
+ "depth_label": "depth",
+ "depth_doesnt_matter": "doesn't matter",
+ "depth_eq": "is exactly {{count}}",
+ "direct_children": "direct children",
+ "depth_gt": "is greater than {{count}}",
+ "depth_lt": "is less than {{count}}"
+ },
+ "debug": {
+ "debug": "Debug",
+ "debug_info": "Debug will print extra debugging information into the console to aid in debugging complex queries.",
+ "access_info": "To access the debug information, execute query and click on \"Show backend log\" in top left corner."
+ },
+ "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_notes": {
+ "include_archived_notes": "Include archived notes"
+ },
+ "limit": {
+ "limit": "Limit",
+ "take_first_x_results": "Take only first X specified results."
+ },
+ "order_by": {
+ "order_by": "Order by",
+ "relevancy": "Relevancy (default)",
+ "title": "Title",
+ "date_created": "Date created",
+ "date_modified": "Date of last modification",
+ "content_size": "Note content size",
+ "content_and_attachments_size": "Note content size including attachments",
+ "content_and_attachments_and_revisions_size": "Note content size including attachments and revisions",
+ "revision_count": "Number of revisions",
+ "children_count": "Number of children notes",
+ "parent_count": "Number of clones",
+ "owned_label_count": "Number of labels",
+ "owned_relation_count": "Number of relations",
+ "target_relation_count": "Number of relations targeting the note",
+ "random": "Random order",
+ "asc": "Ascending (default)",
+ "desc": "Descending"
+ },
+ "search_script": {
+ "title": "Search script:",
+ "placeholder": "search for note by its name",
+ "description1": "Search script allows to define search results by running a script. This provides maximal flexibility when standard search doesn't suffice.",
+ "description2": "Search script must be of type \"code\" and subtype \"JavaScript backend\". The script needs to return an array of noteIds or notes.",
+ "example_title": "See this example:",
+ "example_code": "// 1. prefiltering using standard search\nconst candidateNotes = api.searchForNotes(\"#journal\"); \n\n// 2. applying custom search criteria\nconst matchedNotes = candidateNotes\n .filter(note => note.title.match(/[0-9]{1,2}\\. ?[0-9]{1,2}\\. ?[0-9]{4}/));\n\nreturn matchedNotes;",
+ "note": "Note that search script and search string can't be combined with each other."
+ },
+ "search_string": {
+ "title_column": "Search string:",
+ "placeholder": "fulltext keywords, #tag = value ...",
+ "search_syntax": "Search syntax",
+ "also_see": "also see",
+ "complete_help": "complete help on search syntax",
+ "full_text_search": "Just enter any text for full text search",
+ "label_abc": "returns notes with label abc",
+ "label_year": "matches notes with label year having value 2019",
+ "label_rock_pop": "matches notes which have both rock and pop labels",
+ "label_rock_or_pop": "only one of the labels must be present",
+ "label_year_comparison": "numerical comparison (also >, >=, <).",
+ "label_date_created": "notes created in the last month",
+ "error": "Search error: {{error}}"
}
}
|