mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 12:06:48 +02:00
feat(search): some error messages were not translated (closes #8850)
This commit is contained in:
@@ -445,5 +445,15 @@
|
||||
},
|
||||
"desktop": {
|
||||
"instance_already_running": "There's already an instance running, focusing that instance instead."
|
||||
},
|
||||
"search": {
|
||||
"error": {
|
||||
"in-context": "Error in {{- context}}: {{- message}}",
|
||||
"reserved-keyword": "\"{{- token}}\" is a reserved keyword. To search for a literal value, use quotes: \"{{- token}}\"",
|
||||
"cannot-compare-with": "cannot compare with \"{{- token}}\". To search for a literal value, use quotes: \"{{- token}}\"",
|
||||
"misplaced-expression": "Misplaced or incomplete expression \"{{- token}}\"",
|
||||
"fulltext-after-expression": "\"{{- token}}\" is not a valid expression. To search for text, place it before attribute filters (e.g., \"{{- token}} #label\" instead of \"#label {{- token}}\").",
|
||||
"unrecognized-expression": "Unrecognized expression \"{{- token}}\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { dayjs } from "@triliumnext/commons";
|
||||
import { t } from "i18next";
|
||||
|
||||
import { removeDiacritic } from "../../utils.js";
|
||||
import AncestorExp from "../expressions/ancestor.js";
|
||||
@@ -97,9 +98,9 @@ function getExpression(tokens: TokenData[], searchContext: SearchContext, level
|
||||
|
||||
if (!operand.inQuotes && (operand.token.startsWith("#") || operand.token.startsWith("~") || operand.token === "note")) {
|
||||
const hint = operand.token === "note"
|
||||
? `"${operand.token}" is a reserved keyword. To search for a literal value, use quotes: "${operand.token}"`
|
||||
: `cannot compare with "${operand.token}". To search for a literal value, use quotes: "${operand.token}"`;
|
||||
searchContext.addError(`Error in ${context(i)}: ${hint}`);
|
||||
? t("search.error.reserved-keyword", { token: operand.token })
|
||||
: t("search.error.cannot-compare-with", { token: operand.token });
|
||||
searchContext.addError(t("search.error.in-context", { context: context(i), message: hint }));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -437,14 +438,14 @@ function getExpression(tokens: TokenData[], searchContext: SearchContext, level
|
||||
searchContext.addError("Mixed usage of AND/OR - always use parenthesis to group AND/OR expressions.");
|
||||
}
|
||||
} else if (isOperator({ token })) {
|
||||
searchContext.addError(`Misplaced or incomplete expression "${token}"`);
|
||||
searchContext.addError(t("search.error.misplaced-expression", { token }));
|
||||
} else {
|
||||
// Check if this looks like a fulltext search term placed after attribute filters
|
||||
const looksLikeFulltext = !token.startsWith("#") && !token.startsWith("~") && !token.startsWith("note.");
|
||||
if (looksLikeFulltext) {
|
||||
searchContext.addError(`"${token}" is not a valid expression. If you want to search for text, place it before attribute filters (e.g., "${token} #label" instead of "#label ${token}").`);
|
||||
searchContext.addError(t("search.error.fulltext-after-expression", { token }));
|
||||
} else {
|
||||
searchContext.addError(`Unrecognized expression "${token}"`);
|
||||
searchContext.addError(t("search.error.unrecognized-expression", { token }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user