From 7f8a577bd2984880ad302364aaa4bfec3e028dba Mon Sep 17 00:00:00 2001 From: JimmFly Date: Mon, 9 Jan 2023 12:07:17 +0800 Subject: [PATCH] chore: update i18n keys --- .../src/components/create-workspace/index.tsx | 11 +- .../src/components/edgeless-toolbar/index.tsx | 124 +++++++++--------- .../app/src/components/file-upload/index.tsx | 4 +- .../header-right-items/trash-button-group.tsx | 14 +- packages/app/src/libs/i18n/resources/en.json | 18 ++- 5 files changed, 95 insertions(+), 76 deletions(-) diff --git a/packages/app/src/components/create-workspace/index.tsx b/packages/app/src/components/create-workspace/index.tsx index d2decdfe4e..05c37f9900 100644 --- a/packages/app/src/components/create-workspace/index.tsx +++ b/packages/app/src/components/create-workspace/index.tsx @@ -5,6 +5,7 @@ import { useState } from 'react'; import Input from '@/ui/input'; import { useTemporaryHelper } from '@/providers/temporary-helper-provider'; import { KeyboardEvent } from 'react'; +import { useTranslation } from 'react-i18next'; interface ICloseParams { workspaceId?: string; } @@ -27,12 +28,13 @@ export const CreateWorkspaceModal = ({ open, onClose }: ModalProps) => { handleCreateWorkspace(); } }; + const { t } = useTranslation(); return (
- New Workspace + {t('New Workspace')} { />
-

- Workspace is your virtual space to capture, create and plan as - just one person or together as a team. -

+

{t('Workspace description')}

{ @@ -57,7 +56,7 @@ export const CreateWorkspaceModal = ({ open, onClose }: ModalProps) => { handleCreateWorkspace(); }} > - Create + {t('Create')}
diff --git a/packages/app/src/components/edgeless-toolbar/index.tsx b/packages/app/src/components/edgeless-toolbar/index.tsx index c44f6396ca..697c5a6261 100644 --- a/packages/app/src/components/edgeless-toolbar/index.tsx +++ b/packages/app/src/components/edgeless-toolbar/index.tsx @@ -19,73 +19,77 @@ import Slide from '@mui/material/Slide'; import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import { useAppState } from '@/providers/app-state-provider'; import useHistoryUpdated from '@/hooks/use-history-update'; +import { useTranslation } from 'react-i18next'; -const toolbarList1 = [ - { - flavor: 'select', - icon: , - toolTip: 'Select', - disable: false, - callback: () => { - window.dispatchEvent( - new CustomEvent('affine.switch-mouse-mode', { - detail: { - type: 'default', - }, - }) - ); +const useToolbarList1 = () => { + const { t } = useTranslation(); + return [ + { + flavor: 'select', + icon: , + toolTip: t('Select'), + disable: false, + callback: () => { + window.dispatchEvent( + new CustomEvent('affine.switch-mouse-mode', { + detail: { + type: 'default', + }, + }) + ); + }, }, - }, - { - flavor: 'text', - icon: , - toolTip: 'Text (coming soon)', - disable: true, - }, - { - flavor: 'shape', - icon: , - toolTip: 'Shape', - disable: false, - callback: () => { - window.dispatchEvent( - new CustomEvent('affine.switch-mouse-mode', { - detail: { - type: 'shape', - color: 'black', - shape: 'rectangle', - }, - }) - ); + { + flavor: 'text', + icon: , + toolTip: t('Text'), + disable: true, + }, + { + flavor: 'shape', + icon: , + toolTip: t('Shape'), + disable: false, + callback: () => { + window.dispatchEvent( + new CustomEvent('affine.switch-mouse-mode', { + detail: { + type: 'shape', + color: 'black', + shape: 'rectangle', + }, + }) + ); + }, + }, + { + flavor: 'sticky', + icon: , + toolTip: t('Sticky'), + disable: true, + }, + { + flavor: 'pen', + icon: , + toolTip: t('Pen'), + disable: true, }, - }, - { - flavor: 'sticky', - icon: , - toolTip: 'Sticky (coming soon)', - disable: true, - }, - { - flavor: 'pen', - icon: , - toolTip: 'Pen (coming soon)', - disable: true, - }, - { - flavor: 'connector', - icon: , - toolTip: 'Connector (coming soon)', - disable: true, - }, -]; + { + flavor: 'connector', + icon: , + toolTip: t('Connector'), + disable: true, + }, + ]; +}; const UndoRedo = () => { const [canUndo, setCanUndo] = useState(false); const [canRedo, setCanRedo] = useState(false); const { currentPage } = useAppState(); const onHistoryUpdated = useHistoryUpdated(); - + const { t } = useTranslation(); useEffect(() => { onHistoryUpdated(page => { setCanUndo(page.canUndo); @@ -95,7 +99,7 @@ const UndoRedo = () => { return ( - + { @@ -105,7 +109,7 @@ const UndoRedo = () => { - + { @@ -131,7 +135,7 @@ export const EdgelessToolbar = () => { > - {toolbarList1.map( + {useToolbarList1().map( ({ icon, toolTip, flavor, disable, callback }, index) => { return ( diff --git a/packages/app/src/components/file-upload/index.tsx b/packages/app/src/components/file-upload/index.tsx index 25d91fb06d..090d628b22 100644 --- a/packages/app/src/components/file-upload/index.tsx +++ b/packages/app/src/components/file-upload/index.tsx @@ -1,6 +1,7 @@ import { Button } from '@/ui/button'; import { FC, useRef, ChangeEvent, ReactElement } from 'react'; import { styled } from '@/styles'; +import { useTranslation } from 'react-i18next'; interface Props { uploadType?: string; children?: ReactElement; @@ -9,6 +10,7 @@ interface Props { } export const Upload: FC = props => { const { fileChange, accept } = props; + const { t } = useTranslation(); const input_ref = useRef(null); const _chooseFile = () => { if (input_ref.current) { @@ -28,7 +30,7 @@ export const Upload: FC = props => { }; return ( - {props.children ?? } + {props.children ?? } { const { permanentlyDeletePage } = usePageHelper(); @@ -12,7 +13,7 @@ export const TrashButtonGroup = () => { const { confirm } = useConfirm(); const router = useRouter(); const { id = '' } = useCurrentPageMeta() || {}; - + const { t } = useTranslation(); return ( <> ); diff --git a/packages/app/src/libs/i18n/resources/en.json b/packages/app/src/libs/i18n/resources/en.json index 9ce5282e71..a4be5ecf05 100644 --- a/packages/app/src/libs/i18n/resources/en.json +++ b/packages/app/src/libs/i18n/resources/en.json @@ -34,7 +34,7 @@ "Delete page?": "Delete page?", "Delete permanently?": "Delete permanently?", "will be moved to Trash": "{{title}} will be moved to Trash", - "Once deleted, you can't undo this action.": "Once deleted,you can't undo this action.", + "Once deleted, you can't undo this action.": "Once deleted, you can't undo this action.", "Moved to Trash": "Moved to Trash", "Permanently deleted": "Permanently deleted", "restored": "{{title}} restored", @@ -61,5 +61,19 @@ "Reduce indent": "Reduce indent", "Markdown Syntax": "Markdown Syntax", "Divider": "Divider", - "404 - Page Not Found": "404 - Page Not Found" + "404 - Page Not Found": "404 - Page Not Found", + "New Workspace": "New Workspace", + "Workspace description": "Workspace is your virtual space to capture, create and plan as just one person or together as a team.", + "Create": "Create", + "Select": "Select", + "Text": "Text (coming soon)", + "Shape": "Shape", + "Sticky": "Sticky (coming soon)", + "Pen": "Pen (coming soon)", + "Connector": "Connector (coming soon)", + "Upload": "Upload", + "Restore it": "Restore it", + "TrashButtonGroupTitle": "Permanently delete", + "TrashButtonGroupDescription": "Once deleted, you can't undo this action. Do you confirm?", + "Delete permanently": "Delete permanently" }