mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update en locale (#2109)
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { getDateString } from "@/helpers/datetime";
|
import { getDateString } from "@/helpers/datetime";
|
||||||
import { getTextWithMemoType } from "@/helpers/filter";
|
|
||||||
import { useFilterStore } from "@/store/module";
|
import { useFilterStore } from "@/store/module";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
@ -12,8 +11,8 @@ const MemoFilter = () => {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const filterStore = useFilterStore();
|
const filterStore = useFilterStore();
|
||||||
const filter = filterStore.state;
|
const filter = filterStore.state;
|
||||||
const { tag: tagQuery, duration, type: memoType, text: textQuery, visibility } = filter;
|
const { tag: tagQuery, duration, text: textQuery, visibility } = filter;
|
||||||
const showFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || memoType || textQuery || visibility);
|
const showFilter = Boolean(tagQuery || (duration && duration.from < duration.to) || textQuery || visibility);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
filterStore.clearFilter();
|
filterStore.clearFilter();
|
||||||
@ -31,16 +30,6 @@ const MemoFilter = () => {
|
|||||||
<Icon.Tag className="icon-text" /> {tagQuery}
|
<Icon.Tag className="icon-text" /> {tagQuery}
|
||||||
<Icon.X className="w-4 h-auto ml-1 opacity-40" />
|
<Icon.X className="w-4 h-auto ml-1 opacity-40" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
className={"filter-item-container " + (memoType ? "" : "!hidden")}
|
|
||||||
onClick={() => {
|
|
||||||
filterStore.setMemoTypeFilter(undefined);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon.Box className="icon-text" />{" "}
|
|
||||||
{t(getTextWithMemoType(memoType as MemoSpecType) as Exclude<ReturnType<typeof getTextWithMemoType>, "">)}
|
|
||||||
<Icon.X className="w-4 h-auto ml-1 opacity-40" />
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
className={"filter-item-container " + (visibility ? "" : "!hidden")}
|
className={"filter-item-container " + (visibility ? "" : "!hidden")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -1,219 +0,0 @@
|
|||||||
import { LINK_REG, PLAIN_LINK_REG, TAG_REG } from "@/labs/marked/parser";
|
|
||||||
import { getUnixTimeMillis } from "./datetime";
|
|
||||||
|
|
||||||
export const relationConsts = [
|
|
||||||
{ text: "filter.and", value: "AND" },
|
|
||||||
{ text: "filter.or", value: "OR" },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const filterConsts = {
|
|
||||||
TAG: {
|
|
||||||
text: "filter.type.tag",
|
|
||||||
value: "TAG",
|
|
||||||
operators: [
|
|
||||||
{
|
|
||||||
text: "filter.operator.contains",
|
|
||||||
value: "CONTAIN",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.operator.not-contains",
|
|
||||||
value: "NOT_CONTAIN",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
TYPE: {
|
|
||||||
text: "filter.type.type",
|
|
||||||
value: "TYPE",
|
|
||||||
operators: [
|
|
||||||
{
|
|
||||||
text: "filter.operator.is",
|
|
||||||
value: "IS",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.operator.is-not",
|
|
||||||
value: "IS_NOT",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
values: [
|
|
||||||
{
|
|
||||||
text: "filter.value.not-tagged",
|
|
||||||
value: "NOT_TAGGED",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.value.linked",
|
|
||||||
value: "LINKED",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.value.has-attachment",
|
|
||||||
value: "HAS_ATTACHMENT",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
TEXT: {
|
|
||||||
text: "filter.type.text",
|
|
||||||
value: "TEXT",
|
|
||||||
operators: [
|
|
||||||
{
|
|
||||||
text: "filter.operator.contains",
|
|
||||||
value: "CONTAIN",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.operator.not-contains",
|
|
||||||
value: "NOT_CONTAIN",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
DISPLAY_TIME: {
|
|
||||||
text: "filter.type.display-time",
|
|
||||||
value: "DISPLAY_TIME",
|
|
||||||
operators: [
|
|
||||||
{
|
|
||||||
text: "filter.operator.before",
|
|
||||||
value: "BEFORE",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.operator.after",
|
|
||||||
value: "AFTER",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VISIBILITY: {
|
|
||||||
text: "filter.type.visibility",
|
|
||||||
value: "VISIBILITY",
|
|
||||||
operators: [
|
|
||||||
{
|
|
||||||
text: "filter.operator.is",
|
|
||||||
value: "IS",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "filter.operator.is-not",
|
|
||||||
value: "IS_NOT",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
values: [
|
|
||||||
{
|
|
||||||
text: "memo.visibility.public",
|
|
||||||
value: "PUBLIC",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "memo.visibility.protected",
|
|
||||||
value: "PROTECTED",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "memo.visibility.private",
|
|
||||||
value: "PRIVATE",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export const memoSpecialTypes = filterConsts["TYPE"].values;
|
|
||||||
|
|
||||||
export const getTextWithMemoType = (type: string) => {
|
|
||||||
for (const t of memoSpecialTypes) {
|
|
||||||
if (t.value === type) {
|
|
||||||
return t.text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getDefaultFilter = (): BaseFilter => {
|
|
||||||
return {
|
|
||||||
type: "TAG",
|
|
||||||
value: {
|
|
||||||
operator: "CONTAIN",
|
|
||||||
value: "",
|
|
||||||
},
|
|
||||||
relation: "AND",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const checkShouldShowMemoWithFilters = (memo: Memo, filters: Filter[]) => {
|
|
||||||
let shouldShow = true;
|
|
||||||
|
|
||||||
for (const f of filters) {
|
|
||||||
const { relation } = f;
|
|
||||||
const r = checkShouldShowMemo(memo, f);
|
|
||||||
if (relation === "OR") {
|
|
||||||
shouldShow = shouldShow || r;
|
|
||||||
} else {
|
|
||||||
shouldShow = shouldShow && r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldShow;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const checkShouldShowMemo = (memo: Memo, filter: Filter) => {
|
|
||||||
const {
|
|
||||||
type,
|
|
||||||
value: { operator, value },
|
|
||||||
} = filter;
|
|
||||||
|
|
||||||
if (value === "") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let shouldShow = true;
|
|
||||||
|
|
||||||
if (type === "TAG") {
|
|
||||||
let contained = true;
|
|
||||||
const tagsSet = new Set<string>();
|
|
||||||
for (const t of Array.from(memo.content.match(new RegExp(TAG_REG, "g")) ?? [])) {
|
|
||||||
const tag = t.replace(TAG_REG, "$1").trim();
|
|
||||||
const items = tag.split("/");
|
|
||||||
let temp = "";
|
|
||||||
for (const i of items) {
|
|
||||||
temp += i;
|
|
||||||
tagsSet.add(temp);
|
|
||||||
temp += "/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tagsSet.has(value)) {
|
|
||||||
contained = false;
|
|
||||||
}
|
|
||||||
if (operator === "NOT_CONTAIN") {
|
|
||||||
contained = !contained;
|
|
||||||
}
|
|
||||||
shouldShow = contained;
|
|
||||||
} else if (type === "TYPE") {
|
|
||||||
let matched = false;
|
|
||||||
if (value === "NOT_TAGGED" && memo.content.match(TAG_REG) === null) {
|
|
||||||
matched = true;
|
|
||||||
} else if (value === "LINKED" && (memo.content.match(LINK_REG) !== null || memo.content.match(PLAIN_LINK_REG)) !== null) {
|
|
||||||
matched = true;
|
|
||||||
} else if (value === "HAS_ATTACHMENT" && memo.resourceList.length > 0) {
|
|
||||||
matched = true;
|
|
||||||
}
|
|
||||||
if (operator === "IS_NOT") {
|
|
||||||
matched = !matched;
|
|
||||||
}
|
|
||||||
shouldShow = matched;
|
|
||||||
} else if (type === "TEXT") {
|
|
||||||
if (value.startsWith("^")) {
|
|
||||||
const reg = new RegExp(value.slice(1));
|
|
||||||
shouldShow = operator === "NOT_CONTAIN" ? !reg.test(memo.content) : reg.test(memo.content);
|
|
||||||
} else {
|
|
||||||
let contained = memo.content.toLowerCase().includes(value.toLowerCase());
|
|
||||||
if (operator === "NOT_CONTAIN") {
|
|
||||||
contained = !contained;
|
|
||||||
}
|
|
||||||
shouldShow = contained;
|
|
||||||
}
|
|
||||||
} else if (type === "DISPLAY_TIME") {
|
|
||||||
if (operator === "BEFORE") {
|
|
||||||
return memo.displayTs < getUnixTimeMillis(value);
|
|
||||||
} else {
|
|
||||||
return memo.displayTs >= getUnixTimeMillis(value);
|
|
||||||
}
|
|
||||||
} else if (type === "VISIBILITY") {
|
|
||||||
let matched = memo.visibility === value;
|
|
||||||
if (operator === "IS_NOT") {
|
|
||||||
matched = !matched;
|
|
||||||
}
|
|
||||||
shouldShow = matched;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldShow;
|
|
||||||
};
|
|
@ -75,7 +75,7 @@
|
|||||||
"auth": {
|
"auth": {
|
||||||
"signup-as-host": "Sign up as Host",
|
"signup-as-host": "Sign up as Host",
|
||||||
"host-tip": "You are registering as the Site Host.",
|
"host-tip": "You are registering as the Site Host.",
|
||||||
"not-host-tip": "If you don’t have an account, please contact the site host.",
|
"not-host-tip": "If you don't have an account, please contact the site host.",
|
||||||
"new-password": "New password",
|
"new-password": "New password",
|
||||||
"repeat-new-password": "Repeat the new password"
|
"repeat-new-password": "Repeat the new password"
|
||||||
},
|
},
|
||||||
@ -164,7 +164,6 @@
|
|||||||
"member": "Member",
|
"member": "Member",
|
||||||
"member-list": "Member list",
|
"member-list": "Member list",
|
||||||
"system": "System",
|
"system": "System",
|
||||||
"openai": "OpenAI",
|
|
||||||
"storage": "Storage",
|
"storage": "Storage",
|
||||||
"sso": "SSO",
|
"sso": "SSO",
|
||||||
"account-section": {
|
"account-section": {
|
||||||
@ -265,11 +264,6 @@
|
|||||||
"telegram-bot-token": "Telegram Bot Token",
|
"telegram-bot-token": "Telegram Bot Token",
|
||||||
"telegram-bot-token-description": "Telegram Bot Token or API Proxy like `http.../bot<token>`",
|
"telegram-bot-token-description": "Telegram Bot Token or API Proxy like `http.../bot<token>`",
|
||||||
"telegram-bot-token-placeholder": "Your Telegram Bot token",
|
"telegram-bot-token-placeholder": "Your Telegram Bot token",
|
||||||
"openai-api-key": "OpenAI: API Key",
|
|
||||||
"openai-api-key-description": "Get API key",
|
|
||||||
"openai-api-key-placeholder": "Your OpenAI API Key",
|
|
||||||
"openai-api-host": "OpenAI: API Host",
|
|
||||||
"openai-api-host-placeholder": "Default: https://api.openai.com/",
|
|
||||||
"display-with-updated-time": "Display with updated time"
|
"display-with-updated-time": "Display with updated time"
|
||||||
},
|
},
|
||||||
"appearance-option": {
|
"appearance-option": {
|
||||||
@ -300,32 +294,6 @@
|
|||||||
"disabled-password-login-warning": "Password-login is disabled, be extra careful when removing identity providers❗"
|
"disabled-password-login-warning": "Password-login is disabled, be extra careful when removing identity providers❗"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filter": {
|
|
||||||
"new-filter": "New Filter",
|
|
||||||
"type": {
|
|
||||||
"tag": "Tag",
|
|
||||||
"type": "Type",
|
|
||||||
"text": "Text",
|
|
||||||
"display-time": "Display Time",
|
|
||||||
"visibility": "Visibility"
|
|
||||||
},
|
|
||||||
"operator": {
|
|
||||||
"contains": "Contains",
|
|
||||||
"not-contains": "Does not contain",
|
|
||||||
"is": "Is",
|
|
||||||
"is-not": "Is Not",
|
|
||||||
"before": "Before",
|
|
||||||
"after": "After"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"not-tagged": "No tags",
|
|
||||||
"linked": "Has links",
|
|
||||||
"has-attachment": "Has attachments"
|
|
||||||
},
|
|
||||||
"text-placeholder": "Starts with ^ to use regex",
|
|
||||||
"and": "And",
|
|
||||||
"or": "Or"
|
|
||||||
},
|
|
||||||
"amount-text": {
|
"amount-text": {
|
||||||
"memo_one": "MEMO",
|
"memo_one": "MEMO",
|
||||||
"memo_other": "MEMOS",
|
"memo_other": "MEMOS",
|
||||||
@ -334,6 +302,36 @@
|
|||||||
"day_one": "TAG",
|
"day_one": "TAG",
|
||||||
"day_other": "TAGE"
|
"day_other": "TAGE"
|
||||||
},
|
},
|
||||||
|
"days": {
|
||||||
|
"mon": "Mon",
|
||||||
|
"tue": "Tue",
|
||||||
|
"wed": "Wed",
|
||||||
|
"thu": "Thu",
|
||||||
|
"fri": "Fri",
|
||||||
|
"sat": "Sat",
|
||||||
|
"sun": "Sun"
|
||||||
|
},
|
||||||
|
"embed-memo": {
|
||||||
|
"title": "Embed Memo",
|
||||||
|
"text": "Copy and paste the below code into your blog or website.",
|
||||||
|
"only-public-supported": "* Only public memos can be embedded.",
|
||||||
|
"copy": "Copy"
|
||||||
|
},
|
||||||
|
"heatmap": {
|
||||||
|
"memo-in": "memo in {{period}}",
|
||||||
|
"memos-in": "memos in {{period}}",
|
||||||
|
"memo-on": "{{amount}} memo on {{date}}",
|
||||||
|
"memos-on": "{{amount}} memos on {{date}}",
|
||||||
|
"day": "day",
|
||||||
|
"days": "days"
|
||||||
|
},
|
||||||
|
"about": {
|
||||||
|
"about-memos": "About Memos",
|
||||||
|
"memos-description": "Memos is a web-based note-taking application that you can use to write, organize, and share notes.",
|
||||||
|
"no-server-description": "No description configured for this server.",
|
||||||
|
"powered-by": "Powered by",
|
||||||
|
"other-projects": "Other Projects"
|
||||||
|
},
|
||||||
"message": {
|
"message": {
|
||||||
"no-data": "Maybe no data was found, or maybe it should be another option.",
|
"no-data": "Maybe no data was found, or maybe it should be another option.",
|
||||||
"memos-ready": "all memos are ready 🎉",
|
"memos-ready": "all memos are ready 🎉",
|
||||||
@ -380,36 +378,6 @@
|
|||||||
"maximum-upload-size-is": "Maximum allowed upload size is {{size}} MiB",
|
"maximum-upload-size-is": "Maximum allowed upload size is {{size}} MiB",
|
||||||
"file-exceeds-upload-limit-of": "File {{file}} exceeds upload limit of {{size}} MiB",
|
"file-exceeds-upload-limit-of": "File {{file}} exceeds upload limit of {{size}} MiB",
|
||||||
"updating-setting-failed": "Updating setting failed",
|
"updating-setting-failed": "Updating setting failed",
|
||||||
"password-login-disabled": "Can’t remove last identity provider when password login is disabled"
|
"password-login-disabled": "Can't remove last identity provider when password login is disabled"
|
||||||
},
|
|
||||||
"days": {
|
|
||||||
"mon": "Mon",
|
|
||||||
"tue": "Tue",
|
|
||||||
"wed": "Wed",
|
|
||||||
"thu": "Thu",
|
|
||||||
"fri": "Fri",
|
|
||||||
"sat": "Sat",
|
|
||||||
"sun": "Sun"
|
|
||||||
},
|
|
||||||
"embed-memo": {
|
|
||||||
"title": "Embed Memo",
|
|
||||||
"text": "Copy and paste the below code into your blog or website.",
|
|
||||||
"only-public-supported": "* Only public memos can be embedded.",
|
|
||||||
"copy": "Copy"
|
|
||||||
},
|
|
||||||
"heatmap": {
|
|
||||||
"memo-in": "memo in {{period}}",
|
|
||||||
"memos-in": "memos in {{period}}",
|
|
||||||
"memo-on": "{{amount}} memo on {{date}}",
|
|
||||||
"memos-on": "{{amount}} memos on {{date}}",
|
|
||||||
"day": "day",
|
|
||||||
"days": "days"
|
|
||||||
},
|
|
||||||
"about": {
|
|
||||||
"about-memos": "About Memos",
|
|
||||||
"memos-description": "Memos is a web-based note-taking application that you can use to write, organize, and share notes.",
|
|
||||||
"no-server-description": "No description configured for this server.",
|
|
||||||
"powered-by": "Powered by",
|
|
||||||
"other-projects": "Other Projects"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user