From 257b8add8c7de27c4aa0c37450cd6faaa811f75d Mon Sep 17 00:00:00 2001 From: imikod Date: Fri, 12 Apr 2024 03:35:14 +0300 Subject: [PATCH] chore: localization improvements (#3213) * localization improvements * typo fix * fix linting error --- web/src/components/ActivityCalendar.tsx | 4 +++- web/src/components/HomeSidebar/TagsSection.tsx | 6 +++--- web/src/components/Inbox/MemoCommentMessage.tsx | 2 +- web/src/components/Inbox/VersionUpdateMessage.tsx | 2 +- web/src/components/MemoActionMenu.tsx | 2 +- .../ActionButton/AddMemoRelationButton.tsx | 4 +++- .../MemoEditor/ActionButton/TagSelector.tsx | 4 +++- web/src/components/MemoView.tsx | 2 +- web/src/locales/en.json | 12 ++++++++++-- 9 files changed, 26 insertions(+), 12 deletions(-) diff --git a/web/src/components/ActivityCalendar.tsx b/web/src/components/ActivityCalendar.tsx index feb03040..3edd96ae 100644 --- a/web/src/components/ActivityCalendar.tsx +++ b/web/src/components/ActivityCalendar.tsx @@ -1,6 +1,7 @@ import { Tooltip } from "@mui/joy"; import classNames from "classnames"; import { getNormalizedDateString, getDateWithOffset } from "@/helpers/datetime"; +import { useTranslate } from "@/utils/i18n"; interface Props { // Format: 2021-1 @@ -25,6 +26,7 @@ const getCellAdditionalStyles = (count: number, maxCount: number) => { }; const ActivityCalendar = (props: Props) => { + const t = useTranslate(); const { month: monthStr, data, onClick } = props; const year = new Date(monthStr).getUTCFullYear(); const month = new Date(monthStr).getUTCMonth() + 1; @@ -52,7 +54,7 @@ const ActivityCalendar = (props: Props) => { ); const count = data[date] || 0; const isToday = new Date().toDateString() === new Date(date).toDateString(); - const tooltipText = count ? `${count} memos in ${date}` : date; + const tooltipText = count ? t("memo.count-memos-in-date", { count: count, date: date }) : date; return day ? (
{

- You can create tags by inputting `#tag`. + {t("tag.create-tags-guide")}

)} @@ -130,8 +130,8 @@ const TagItemContainer: React.FC = (props: TagItemContain const handleDeleteTag = async () => { showCommonDialog({ - title: "Delete Tag", - content: "Are you sure to delete this tag?", + title: t("tag.delete-tag"), + content: t("tag.delete-confirm"), style: "danger", dialogName: "delete-tag-dialog", onConfirm: async () => { diff --git a/web/src/components/Inbox/MemoCommentMessage.tsx b/web/src/components/Inbox/MemoCommentMessage.tsx index 759e31a7..a741738a 100644 --- a/web/src/components/Inbox/MemoCommentMessage.tsx +++ b/web/src/components/Inbox/MemoCommentMessage.tsx @@ -69,7 +69,7 @@ const MemoCommentMessage = ({ inbox }: Props) => { ["status"], ); if (!silence) { - toast.success("Archived"); + toast.success(t("message.archived-successfully")); } }; diff --git a/web/src/components/Inbox/VersionUpdateMessage.tsx b/web/src/components/Inbox/VersionUpdateMessage.tsx index f0f3d3cd..5d40a3a0 100644 --- a/web/src/components/Inbox/VersionUpdateMessage.tsx +++ b/web/src/components/Inbox/VersionUpdateMessage.tsx @@ -55,7 +55,7 @@ const VersionUpdateMessage = ({ inbox }: Props) => { ["status"], ); if (!silence) { - toast.success("Archived"); + toast.success(t("message.archived-successfully")); } }; diff --git a/web/src/components/MemoActionMenu.tsx b/web/src/components/MemoActionMenu.tsx index b728d376..9e152273 100644 --- a/web/src/components/MemoActionMenu.tsx +++ b/web/src/components/MemoActionMenu.tsx @@ -97,7 +97,7 @@ const MemoActionMenu = (props: Props) => { dialogName: "delete-memo-dialog", onConfirm: async () => { await memoStore.deleteMemo(memo.name); - toast.success("Deleted successfully"); + toast.success(t("message.deleted-successfully")); if (isInMemoDetailPage) { navigateTo("/"); } diff --git a/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx b/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx index 95b8c3b8..761696be 100644 --- a/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx +++ b/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx @@ -5,6 +5,7 @@ import toast from "react-hot-toast"; import showCreateMemoRelationDialog from "@/components/CreateMemoRelationDialog"; import Icon from "@/components/Icon"; import { MemoRelation_Type } from "@/types/proto/api/v2/memo_relation_service"; +import { useTranslate } from "@/utils/i18n"; import { EditorRefActions } from "../Editor"; import { MemoEditorContext } from "../types"; @@ -15,6 +16,7 @@ interface Props { const AddMemoRelationButton = (props: Props) => { const { editorRef } = props; const context = useContext(MemoEditorContext); + const t = useTranslate(); const handleAddMemoRelationBtnClick = () => { showCreateMemoRelationDialog({ @@ -22,7 +24,7 @@ const AddMemoRelationButton = (props: Props) => { // If embedded mode is enabled, embed the memo instead of creating a relation. if (embedded) { if (!editorRef.current) { - toast.error("Failed to embed memo"); + toast.error(t("message.failed-to-embed-memo")); return; } diff --git a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx index 186c87ea..ad1a199a 100644 --- a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx +++ b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx @@ -4,6 +4,7 @@ import useClickAway from "react-use/lib/useClickAway"; import Icon from "@/components/Icon"; import OverflowTip from "@/components/kit/OverflowTip"; import { useTagStore } from "@/store/module"; +import { useTranslate } from "@/utils/i18n"; import { EditorRefActions } from "../Editor"; interface Props { @@ -11,6 +12,7 @@ interface Props { } const TagSelector = (props: Props) => { + const t = useTranslate(); const { editorRef } = props; const tagStore = useTagStore(); const [open, setOpen] = useState(false); @@ -74,7 +76,7 @@ const TagSelector = (props: Props) => {
) : (

e.stopPropagation()}> - No tag found + {t("tag.no-tag-found")}

)} diff --git a/web/src/components/MemoView.tsx b/web/src/components/MemoView.tsx index 008c4ec5..e93e51f4 100644 --- a/web/src/components/MemoView.tsx +++ b/web/src/components/MemoView.tsx @@ -138,7 +138,7 @@ const MemoView: React.FC = (props: Props) => { )} {props.showPinned && memo.pinned && ( - + )} diff --git a/web/src/locales/en.json b/web/src/locales/en.json index fc80f145..570249b5 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -21,6 +21,7 @@ "language": "Language", "version": "Version", "pin": "Pin", + "pinned": "Pinned", "unpin": "Unpin", "edit": "Edit", "restore": "Restore", @@ -106,7 +107,8 @@ "no-comment": "No comment" }, "show-more": "Show more", - "wrapping": "Wrapping" + "wrapping": "Wrapping", + "count-memos-in-date": "{{count}} memos in {{date}}" }, "reference": { "add-references": "Add references", @@ -153,13 +155,17 @@ "tag": { "tip-text": "Input `#tag` to create", "create-tag": "Create Tag", + "delete-tag": "Delete Tag", + "delete-confirm": "Are you sure to delete this tag?", "all-tags": "All Tags", "tag-name": "TAG_NAME", "invalid-tag-name": "Invalid tag name", "tag-suggestions": "Tag suggestions", + "no-tag-found": "No tag found", "show": "Show", "hide": "Hide", - "save-all": "Save all" + "save-all": "Save all", + "create-tags-guide": "You can create tags by inputting `#tag`." }, "timeline": { "title": "Timeline" @@ -318,11 +324,13 @@ "memos-ready": "all memos are ready", "resource-ready": "all resource are ready", "archived-successfully": "Archived successfully", + "deleted-successfully": "Deleted successfully", "restored-successfully": "Restored successfully", "memo-updated-datetime": "Memo created datetime changed.", "invalid-created-datetime": "Invalid created datetime.", "change-memo-created-time": "Change memo created time", "memo-not-found": "Memo not found.", + "failed-to-embed-memo": "Failed to embed memo", "fill-all": "Please fill in all fields.", "password-not-match": "Passwords do not match.", "new-password-not-match": "New passwords do not match.",