chore: update i18n keys

This commit is contained in:
JimmFly
2023-01-10 14:29:18 +08:00
parent bc6cf648f6
commit 9fe4b066f9
23 changed files with 210 additions and 102 deletions

View File

@@ -7,7 +7,7 @@ import {
StyledCloseButton, StyledCloseButton,
} from './styles'; } from './styles';
import CloseIcon from '@mui/icons-material/Close'; import CloseIcon from '@mui/icons-material/Close';
import { getWarningMessage, shouldShowWarning } from './utils'; import { useWarningMessage, shouldShowWarning } from './utils';
import EditorOptionMenu from './header-right-items/EditorOptionMenu'; import EditorOptionMenu from './header-right-items/EditorOptionMenu';
import TrashButtonGroup from './header-right-items/TrashButtonGroup'; import TrashButtonGroup from './header-right-items/TrashButtonGroup';
import ThemeModeSwitch from './header-right-items/theme-mode-switch'; import ThemeModeSwitch from './header-right-items/theme-mode-switch';
@@ -22,7 +22,7 @@ const BrowserWarning = ({
}) => { }) => {
return ( return (
<StyledBrowserWarning show={show}> <StyledBrowserWarning show={show}>
{getWarningMessage()} {useWarningMessage()}
<StyledCloseButton onClick={onClose}> <StyledCloseButton onClick={onClose}>
<CloseIcon /> <CloseIcon />
</StyledCloseButton> </StyledCloseButton>

View File

@@ -1,4 +1,5 @@
import getIsMobile from '@/utils/get-is-mobile'; import getIsMobile from '@/utils/get-is-mobile';
import { Trans, useTranslation } from 'react-i18next';
// Inspire by https://stackoverflow.com/a/4900484/8415727 // Inspire by https://stackoverflow.com/a/4900484/8415727
const getChromeVersion = () => { const getChromeVersion = () => {
const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
@@ -19,20 +20,20 @@ export const shouldShowWarning = () => {
); );
}; };
export const getWarningMessage = () => { export const useWarningMessage = () => {
const { t } = useTranslation();
if (!getIsChrome()) { if (!getIsChrome()) {
return ( return (
<span> <span>
We recommend the <strong>Chrome</strong> browser for optimal experience. <Trans i18nKey="recommendBrowser">
We recommend the <strong>Chrome</strong> browser for optimal
experience.
</Trans>
</span> </span>
); );
} }
if (getChromeVersion() < minimumChromeVersion) { if (getChromeVersion() < minimumChromeVersion) {
return ( return <span>{t('upgradeBrowser')}</span>;
<span>
Please upgrade to the latest version of Chrome for the best experience.
</span>
);
} }
return ''; return '';
}; };

View File

@@ -7,6 +7,7 @@ import { useState } from 'react';
// import { getDataCenter } from '@affine/datacenter'; // import { getDataCenter } from '@affine/datacenter';
import { Avatar } from '@mui/material'; import { Avatar } from '@mui/material';
import { setMember } from '@/hooks/mock-data/mock'; import { setMember } from '@/hooks/mock-data/mock';
import { useTranslation } from 'react-i18next';
interface LoginModalProps { interface LoginModalProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -54,6 +55,7 @@ export const InviteMembers = ({
const [showTip, setShowTip] = useState<boolean>(false); const [showTip, setShowTip] = useState<boolean>(false);
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const [userData, setUserData] = useState<any>({}); const [userData, setUserData] = useState<any>({});
const { t } = useTranslation();
const inputChange = (value: string) => { const inputChange = (value: string) => {
setShowMember(true); setShowMember(true);
if (gmailReg.test(value)) { if (gmailReg.test(value)) {
@@ -101,7 +103,7 @@ export const InviteMembers = ({
/> />
</Header> </Header>
<Content> <Content>
<ContentTitle>Invite members</ContentTitle> <ContentTitle>{t('Invite Members')}</ContentTitle>
<InviteBox> <InviteBox>
<Input <Input
width={360} width={360}
@@ -110,12 +112,12 @@ export const InviteMembers = ({
onBlur={() => { onBlur={() => {
setShowMember(false); setShowMember(false);
}} }}
placeholder="Search mail (Gmail support only)" placeholder={t('Invite placeholder')}
></Input> ></Input>
{showMember ? ( {showMember ? (
<Members> <Members>
{showTip ? ( {showTip ? (
<NoFind>Non-Gmail is not supported</NoFind> <NoFind>{t('Non-Gmail is not supported')}</NoFind>
) : ( ) : (
<Member> <Member>
{userData?.avatar_url ? ( {userData?.avatar_url ? (
@@ -154,7 +156,7 @@ export const InviteMembers = ({
// }); // });
}} }}
> >
Invite {t('Invite')}
</Button> </Button>
</Footer> </Footer>
</ModalWrapper> </ModalWrapper>

View File

@@ -1,5 +1,6 @@
import { styled } from '@/styles'; import { styled } from '@/styles';
import Loading from './Loading'; import Loading from './Loading';
import { useTranslation } from 'react-i18next';
// Used for the full page loading // Used for the full page loading
const StyledLoadingContainer = styled('div')(() => { const StyledLoadingContainer = styled('div')(() => {
@@ -17,12 +18,13 @@ const StyledLoadingContainer = styled('div')(() => {
}; };
}); });
export const PageLoading = ({ text = 'Loading...' }: { text?: string }) => { export const PageLoading = ({ text }: { text?: string }) => {
const { t } = useTranslation();
return ( return (
<StyledLoadingContainer> <StyledLoadingContainer>
<div className="wrapper"> <div className="wrapper">
<Loading /> <Loading />
<h1>{text}</h1> <h1>{text ? text : t('Loading')}</h1>
</div> </div>
</StyledLoadingContainer> </StyledLoadingContainer>
); );

View File

@@ -3,9 +3,10 @@ import { styled } from '@/styles';
import { Button } from '@/ui/button'; import { Button } from '@/ui/button';
// import { useModal } from '@/providers/GlobalModalProvider'; // import { useModal } from '@/providers/GlobalModalProvider';
import { GoogleIcon, StayLogOutIcon } from './Icons'; import { GoogleIcon, StayLogOutIcon } from './Icons';
import { useTranslation } from 'react-i18next';
export const GoogleLoginButton = () => { export const GoogleLoginButton = () => {
// const { triggerLoginModal } = useModal(); // const { triggerLoginModal } = useModal();
const { t } = useTranslation();
return ( return (
<StyledGoogleButton <StyledGoogleButton
onClick={() => { onClick={() => {
@@ -24,8 +25,10 @@ export const GoogleLoginButton = () => {
<GoogleIcon /> <GoogleIcon />
</IconWrapper> </IconWrapper>
<TextWrapper> <TextWrapper>
<Title>Continue with Google</Title> <Title>{t('Continue with Google')}</Title>
<Description>Set up an AFFiNE account to sync data</Description> <Description>
{t('Set up an AFFiNE account to sync data')}
</Description>
</TextWrapper> </TextWrapper>
</ButtonWrapper> </ButtonWrapper>
</StyledGoogleButton> </StyledGoogleButton>
@@ -33,6 +36,7 @@ export const GoogleLoginButton = () => {
}; };
export const StayLogOutButton = () => { export const StayLogOutButton = () => {
const { t } = useTranslation();
return ( return (
<StyledStayLogOutButton> <StyledStayLogOutButton>
<ButtonWrapper> <ButtonWrapper>
@@ -40,8 +44,8 @@ export const StayLogOutButton = () => {
<StayLogOutIcon /> <StayLogOutIcon />
</IconWrapper> </IconWrapper>
<TextWrapper> <TextWrapper>
<Title>Stay logged out</Title> <Title>{t('Stay logged out')}</Title>
<Description>All changes are saved locally</Description> <Description>{t('All changes are saved locally')}</Description>
</TextWrapper> </TextWrapper>
</ButtonWrapper> </ButtonWrapper>
</StyledStayLogOutButton> </StyledStayLogOutButton>

View File

@@ -3,13 +3,14 @@ import { styled } from '@/styles';
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal'; import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { TextButton } from '@/ui/button'; import { TextButton } from '@/ui/button';
import { GoogleLoginButton, StayLogOutButton } from './LoginOptionButton'; import { GoogleLoginButton, StayLogOutButton } from './LoginOptionButton';
import { useTranslation } from 'react-i18next';
interface LoginModalProps { interface LoginModalProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
} }
export const LoginModal = ({ open, onClose }: LoginModalProps) => { export const LoginModal = ({ open, onClose }: LoginModalProps) => {
const { t } = useTranslation();
return ( return (
<Modal open={open} onClose={onClose} data-testid="login-modal"> <Modal open={open} onClose={onClose} data-testid="login-modal">
<ModalWrapper width={620} height={334}> <ModalWrapper width={620} height={334}>
@@ -23,12 +24,12 @@ export const LoginModal = ({ open, onClose }: LoginModalProps) => {
/> />
</Header> </Header>
<Content> <Content>
<ContentTitle>Currently not logged in</ContentTitle> <ContentTitle>{t('NotLoggedIn')}</ContentTitle>
<GoogleLoginButton /> <GoogleLoginButton />
<StayLogOutButton /> <StayLogOutButton />
</Content> </Content>
<Footer> <Footer>
<TextButton icon={<StyledResetIcon />}>Clear local data</TextButton> <TextButton icon={<StyledResetIcon />}>{t('ClearData')}</TextButton>
</Footer> </Footer>
</ModalWrapper> </ModalWrapper>
</Modal> </Modal>

View File

@@ -3,8 +3,10 @@ import Modal, { ModalCloseButton, ModalWrapper } from '@/ui/modal';
import getIsMobile from '@/utils/get-is-mobile'; import getIsMobile from '@/utils/get-is-mobile';
import { StyledButton, StyledContent, StyledTitle } from './styles'; import { StyledButton, StyledContent, StyledTitle } from './styles';
import bg from './bg.png'; import bg from './bg.png';
import { useTranslation } from 'react-i18next';
export const MobileModal = () => { export const MobileModal = () => {
const [showModal, setShowModal] = useState(getIsMobile()); const [showModal, setShowModal] = useState(getIsMobile());
const { t } = useTranslation();
return ( return (
<Modal <Modal
open={showModal} open={showModal}
@@ -25,20 +27,17 @@ export const MobileModal = () => {
}} }}
/> />
<StyledTitle>Ooops!</StyledTitle> <StyledTitle>{t('Ooops!')}</StyledTitle>
<StyledContent> <StyledContent>
<p>Looks like you are browsing on a mobile device.</p> <p>{t('mobile device')}</p>
<p> <p>{t('mobile device description')}</p>
We are still working on mobile support and recommend you use a
desktop device.
</p>
</StyledContent> </StyledContent>
<StyledButton <StyledButton
onClick={() => { onClick={() => {
setShowModal(false); setShowModal(false);
}} }}
> >
Got it {t('Got it')}
</StyledButton> </StyledButton>
</ModalWrapper> </ModalWrapper>
</Modal> </Modal>

View File

@@ -1,6 +1,9 @@
import React from 'react'; import React from 'react';
import { Empty } from '@/ui/empty'; import { Empty } from '@/ui/empty';
export const PageListEmpty = () => { import { useTranslation } from 'react-i18next';
export const PageListEmpty = (props: { listType: string }) => {
const { listType } = props;
const { t } = useTranslation();
return ( return (
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: 'center' }}>
<Empty <Empty
@@ -8,8 +11,10 @@ export const PageListEmpty = () => {
height={300} height={300}
sx={{ marginTop: '100px', marginBottom: '30px' }} sx={{ marginTop: '100px', marginBottom: '30px' }}
/> />
<p>Tips: Click Add to Favourites/Trash and the page will appear here.</p> {listType === 'all' && <p>{t('emptyAllPages')}</p>}
<p>(Designer is grappling with designing)</p> {listType === 'favorite' && <p>{t('emptyFavourite')}</p>}
{listType === 'trash' && <p>{t('emptyTrash')}</p>}
<p>{t('still designed')}</p>
</div> </div>
); );
}; };

View File

@@ -67,16 +67,18 @@ export const PageList = ({
pageList, pageList,
showFavoriteTag = false, showFavoriteTag = false,
isTrash = false, isTrash = false,
listType,
}: { }: {
pageList: PageMeta[]; pageList: PageMeta[];
showFavoriteTag?: boolean; showFavoriteTag?: boolean;
isTrash?: boolean; isTrash?: boolean;
listType?: 'all' | 'trash' | 'favorite';
}) => { }) => {
const router = useRouter(); const router = useRouter();
const { currentWorkspaceId } = useAppState(); const { currentWorkspaceId } = useAppState();
const { t } = useTranslation(); const { t } = useTranslation();
if (pageList.length === 0) { if (pageList.length === 0) {
return <Empty />; return <Empty listType={listType} />;
} }
return ( return (

View File

@@ -9,6 +9,7 @@ import { SearchIcon } from '@blocksuite/icons';
import { StyledInputContent, StyledLabel } from './style'; import { StyledInputContent, StyledLabel } from './style';
import { Command } from 'cmdk'; import { Command } from 'cmdk';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import { useTranslation } from 'react-i18next';
export const Input = (props: { export const Input = (props: {
query: string; query: string;
setQuery: Dispatch<SetStateAction<string>>; setQuery: Dispatch<SetStateAction<string>>;
@@ -17,6 +18,7 @@ export const Input = (props: {
const [isComposition, setIsComposition] = useState(false); const [isComposition, setIsComposition] = useState(false);
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const { t } = useTranslation();
const { currentWorkspaceId, workspaceList, currentWorkspace } = useAppState(); const { currentWorkspaceId, workspaceList, currentWorkspace } = useAppState();
const isPublish = workspaceList.find( const isPublish = workspaceList.find(
meta => String(meta.id) === String(currentWorkspaceId) meta => String(meta.id) === String(currentWorkspaceId)
@@ -80,8 +82,10 @@ export const Input = (props: {
}} }}
placeholder={ placeholder={
isPublish isPublish
? `Search in ${currentWorkspace?.meta.name}` ? t('Quick search placeholder2', {
: 'Quick Search...' workspace = currentWorkspace?.meta.name,
})
: t('Quick search placeholder')
} }
/> />
</StyledInputContent> </StyledInputContent>

View File

@@ -16,7 +16,7 @@ import { WorkspaceAvatar } from '@/components/workspace-avatar';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useUserHelper } from '@/hooks/use-user-helper'; import { useUserHelper } from '@/hooks/use-user-helper';
import { useTranslation } from 'react-i18next';
interface WorkspaceModalProps { interface WorkspaceModalProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -28,6 +28,7 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
const { workspaceList, currentWorkspace } = useAppState(); const { workspaceList, currentWorkspace } = useAppState();
const { login, user } = useUserHelper(); const { login, user } = useUserHelper();
const router = useRouter(); const router = useRouter();
const { t } = useTranslation();
return ( return (
<div> <div>
<Modal open={open} onClose={onClose}> <Modal open={open} onClose={onClose}>
@@ -36,7 +37,7 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
style={{ padding: '10px', display: 'flex', flexDirection: 'column' }} style={{ padding: '10px', display: 'flex', flexDirection: 'column' }}
> >
<Header> <Header>
<ContentTitle>My Workspaces</ContentTitle> <ContentTitle>{t('My Workspaces')}</ContentTitle>
{/* <LanguageMenu /> */} {/* <LanguageMenu /> */}
<ModalCloseButton <ModalCloseButton
top={6} top={6}
@@ -121,13 +122,13 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
marginRight: '10px', marginRight: '10px',
}} }}
/> />
Create Or Import {t('Create Or Import')}
</Button> </Button>
</li> </li>
</WorkspaceList> </WorkspaceList>
<p style={{ fontSize: '14px', color: '#ccc', margin: '12px 0' }}> <p style={{ fontSize: '14px', color: '#ccc', margin: '12px 0' }}>
Tips:Workspace is your virtual space to capture, create and plan {t('Tips')}
as just one person or together as a team. {t('Workspace description')}
</p> </p>
</Content> </Content>
<Footer> <Footer>
@@ -135,10 +136,10 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
<Button <Button
onClick={() => { onClick={() => {
login(); login();
toast('login success'); toast(t('login success'));
}} }}
> >
Sign in AFFiNE Cloud {t('Sign in')}
</Button> </Button>
) : ( ) : (
<Button <Button
@@ -146,7 +147,7 @@ export const WorkspaceModal = ({ open, onClose }: WorkspaceModalProps) => {
SignOut(); SignOut();
}} }}
> >
Sign out of AFFiNE Cloud {t('Sign out')}
</Button> </Button>
)} )}
</Footer> </Footer>

View File

@@ -1,6 +1,6 @@
import { styled } from '@/styles'; import { styled } from '@/styles';
import { Workspace } from '@affine/datacenter'; import { Workspace } from '@affine/datacenter';
import { Trans } from 'react-i18next';
export const ExportPageTitleContainer = styled('div')(() => { export const ExportPageTitleContainer = styled('div')(() => {
return { return {
display: 'flex', display: 'flex',
@@ -12,8 +12,13 @@ export const ExportPageTitleContainer = styled('div')(() => {
export const ExportPage = ({ workspace }: { workspace: Workspace }) => { export const ExportPage = ({ workspace }: { workspace: Workspace }) => {
return ( return (
<ExportPageTitleContainer> <ExportPageTitleContainer>
Export Workspace{' '} <Trans i18nKey="Export Workspace">
<code style={{ margin: '0 10px' }}>{workspace.name}</code> Is Comming Export Workspace
<code style={{ margin: '0 10px' }}>
{{ workspace: workspace.name }}
</code>
Is Comming
</Trans>
</ExportPageTitleContainer> </ExportPageTitleContainer>
); );
}; };

View File

@@ -27,6 +27,7 @@ import { Workspace } from '@affine/datacenter';
import { useTemporaryHelper } from '@/providers/temporary-helper-provider'; import { useTemporaryHelper } from '@/providers/temporary-helper-provider';
import { StyledMemberWarp } from './general/style'; import { StyledMemberWarp } from './general/style';
import { useConfirm } from '@/providers/ConfirmProvider'; import { useConfirm } from '@/providers/ConfirmProvider';
import { useTranslation } from 'react-i18next';
// import { useAppState } from '@/providers/app-state-provider'; // import { useAppState } from '@/providers/app-state-provider';
export const MembersPage = ({ workspace }: { workspace: Workspace }) => { export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
@@ -36,6 +37,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
]); ]);
const { user, login, updateWorkspaceMeta } = useTemporaryHelper(); const { user, login, updateWorkspaceMeta } = useTemporaryHelper();
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const { t } = useTranslation();
// const refreshMembers = useCallback(() => { // const refreshMembers = useCallback(() => {
// getDataCenter() // getDataCenter()
// .then(dc => // .then(dc =>
@@ -66,9 +68,11 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
<> <>
<StyledMemberTitleContainer> <StyledMemberTitleContainer>
<StyledMemberNameContainer> <StyledMemberNameContainer>
Users({members.length}) {t('Users')} ({members.length})
</StyledMemberNameContainer> </StyledMemberNameContainer>
<StyledMemberRoleContainer>Access level</StyledMemberRoleContainer> <StyledMemberRoleContainer>
{t('Access level')}
</StyledMemberRoleContainer>
</StyledMemberTitleContainer> </StyledMemberTitleContainer>
<StyledMemberListContainer> <StyledMemberListContainer>
{members.length ? ( {members.length ? (
@@ -92,7 +96,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
? 'Member' ? 'Member'
: 'Workspace Owner' : 'Workspace Owner'
: 'Pending'} */} : 'Pending'} */}
Pending {t('Pending')}
</StyledMemberRoleContainer> </StyledMemberRoleContainer>
<StyledMoreVerticalButton> <StyledMoreVerticalButton>
<Menu <Menu
@@ -123,7 +127,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
}} }}
icon={<TrashIcon />} icon={<TrashIcon />}
> >
Delete {t('Delete')}
</MenuItem> </MenuItem>
</> </>
} }
@@ -154,7 +158,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
type="primary" type="primary"
shape="circle" shape="circle"
> >
Invite Members {t('Invite Members')}
</Button> </Button>
<InviteMembers <InviteMembers
onClose={() => { onClose={() => {
@@ -172,19 +176,17 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
</> </>
) : ( ) : (
<StyledMemberWarp> <StyledMemberWarp>
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>{t('Collaboration Description')}</div>
Collaborating with other members requires AFFiNE Cloud service.
</div>
<div style={{ height: '40px' }}> <div style={{ height: '40px' }}>
<Button <Button
type="primary" type="primary"
shape="circle" shape="circle"
onClick={() => { onClick={() => {
confirm({ confirm({
title: 'Enable AFFiNE Cloud?', title: `${t('Enable AFFiNE Cloud')}?`,
content: `If enabled, the data in this workspace will be backed up and synchronized via AFFiNE Cloud.`, content: t('Enable AFFiNE Cloud Description'),
confirmText: user ? 'Enable' : 'Sign in and Enable', confirmText: user ? t('Enable') : t('Sign in and Enable'),
cancelText: 'Skip', cancelText: t('Skip'),
}).then(confirm => { }).then(confirm => {
if (confirm) { if (confirm) {
if (user) { if (user) {
@@ -197,7 +199,7 @@ export const MembersPage = ({ workspace }: { workspace: Workspace }) => {
}); });
}} }}
> >
Enable AFFiNE Cloud {t('Enable AFFiNE Cloud')}
</Button> </Button>
</div> </div>
</StyledMemberWarp> </StyledMemberWarp>

View File

@@ -13,12 +13,13 @@ import { useConfirm } from '@/providers/ConfirmProvider';
// import { useAppState } from '@/providers/app-state-provider3'; // import { useAppState } from '@/providers/app-state-provider3';
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper'; import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
import { Workspace } from '@affine/datacenter'; import { Workspace } from '@affine/datacenter';
import { useTranslation } from 'react-i18next';
export const PublishPage = ({ workspace }: { workspace: Workspace }) => { export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
const shareUrl = const shareUrl =
window.location.host + '/workspace/' + workspace.id + '?share=true'; window.location.host + '/workspace/' + workspace.id + '?share=true';
const { publishWorkspace } = useWorkspaceHelper(); const { publishWorkspace } = useWorkspaceHelper();
const { t } = useTranslation();
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const togglePublic = (flag: boolean) => { const togglePublic = (flag: boolean) => {
@@ -32,11 +33,11 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
const enableAffineCloud = () => { const enableAffineCloud = () => {
confirm({ confirm({
title: 'Enable AFFiNE Cloud?', title: `${t('Enable AFFiNE Cloud')}?`,
content: `If enabled, the data in this workspace will be backed up and synchronized via AFFiNE Cloud.`, content: t('Enable AFFiNE Cloud Description'),
confirmText: confirmText:
workspace.provider === 'local' ? 'Enable' : 'Sign in and Enable', workspace.provider === 'local' ? t('Enable') : t('Sign in and Enable'),
cancelText: 'Skip', cancelText: t('Skip'),
}).then(confirm => { }).then(confirm => {
if (confirm) { if (confirm) {
// if (user) { // if (user) {
@@ -56,22 +57,21 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
{workspace?.isPublish ? ( {workspace?.isPublish ? (
<> <>
<StyledPublishExplanation> <StyledPublishExplanation>
Publishing to web requires AFFiNE Cloud service . {t('Publishing')}
</StyledPublishExplanation> </StyledPublishExplanation>
<StyledSettingH2>Share with link</StyledSettingH2> <StyledSettingH2>{t('Share with link')}</StyledSettingH2>
<StyledPublishCopyContainer> <StyledPublishCopyContainer>
<Input width={500} value={shareUrl} disabled={true}></Input> <Input width={500} value={shareUrl} disabled={true}></Input>
<StyledCopyButtonContainer> <StyledCopyButtonContainer>
<Button onClick={copyUrl} type="primary" shape="circle"> <Button onClick={copyUrl} type="primary" shape="circle">
Copy Link {t('Copy Link')}
</Button> </Button>
</StyledCopyButtonContainer> </StyledCopyButtonContainer>
</StyledPublishCopyContainer> </StyledPublishCopyContainer>
</> </>
) : ( ) : (
<StyledPublishExplanation> <StyledPublishExplanation>
After publishing to the web, everyone can view the content of {'Publishing Description'}
this workspace through the link.
</StyledPublishExplanation> </StyledPublishExplanation>
)} )}
</StyledPublishContent> </StyledPublishContent>
@@ -83,7 +83,7 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
type="primary" type="primary"
shape="circle" shape="circle"
> >
Stop publishing {t('Stop publishing')}
</Button> </Button>
) : ( ) : (
<Button <Button
@@ -93,7 +93,7 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
type="primary" type="primary"
shape="circle" shape="circle"
> >
Publish to web {t('Publish to web')}
</Button> </Button>
)} )}
</div> </div>
@@ -101,7 +101,7 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
<StyledPublishContent> <StyledPublishContent>
<> <>
<StyledPublishExplanation> <StyledPublishExplanation>
Publishing to web requires AFFiNE Cloud service. {t('Publishing')}
</StyledPublishExplanation> </StyledPublishExplanation>
<StyledPublishCopyContainer> <StyledPublishCopyContainer>
@@ -112,7 +112,7 @@ export const PublishPage = ({ workspace }: { workspace: Workspace }) => {
type="primary" type="primary"
shape="circle" shape="circle"
> >
Enable AFFiNE Cloud {t('Enable AFFiNE Cloud')}
</Button> </Button>
</StyledPublishCopyContainer> </StyledPublishCopyContainer>
</> </>

View File

@@ -8,9 +8,11 @@ import { Button } from '@/ui/button';
import { Menu, MenuItem } from '@/ui/menu'; import { Menu, MenuItem } from '@/ui/menu';
import { useTemporaryHelper } from '@/providers/temporary-helper-provider'; import { useTemporaryHelper } from '@/providers/temporary-helper-provider';
import { Workspace } from '@affine/datacenter'; import { Workspace } from '@affine/datacenter';
import { Trans, useTranslation } from 'react-i18next';
export const SyncPage = ({ workspace }: { workspace: Workspace }) => { export const SyncPage = ({ workspace }: { workspace: Workspace }) => {
console.log('workspace: ', workspace); console.log('workspace: ', workspace);
const { currentWorkspace, updateWorkspaceMeta } = useTemporaryHelper(); const { currentWorkspace, updateWorkspaceMeta } = useTemporaryHelper();
const { t } = useTranslation();
return ( return (
<div> <div>

View File

@@ -17,6 +17,7 @@ import { Upload } from '@/components/file-upload';
import { WorkspaceAvatar } from '@/components/workspace-avatar'; import { WorkspaceAvatar } from '@/components/workspace-avatar';
import { useTemporaryHelper } from '@/providers/temporary-helper-provider'; import { useTemporaryHelper } from '@/providers/temporary-helper-provider';
import { Workspace } from '@affine/datacenter'; import { Workspace } from '@affine/datacenter';
import { useTranslation } from 'react-i18next';
export const GeneralPage = ({ workspace }: { workspace: Workspace }) => { export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
// const { refreshWorkspacesMeta } = useAppState(); // const { refreshWorkspacesMeta } = useAppState();
const { updateWorkspaceMeta } = useTemporaryHelper(); const { updateWorkspaceMeta } = useTemporaryHelper();
@@ -24,6 +25,7 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
const [showLeave, setShowLeave] = useState<boolean>(false); const [showLeave, setShowLeave] = useState<boolean>(false);
const [uploading, setUploading] = useState<boolean>(false); const [uploading, setUploading] = useState<boolean>(false);
const [workspaceName, setWorkspaceName] = useState<string>(''); const [workspaceName, setWorkspaceName] = useState<string>('');
const { t } = useTranslation();
// const debouncedRefreshWorkspacesMeta = debounce(() => { // const debouncedRefreshWorkspacesMeta = debounce(() => {
// refreshWorkspacesMeta(); // refreshWorkspacesMeta();
// }, 100); // }, 100);
@@ -68,7 +70,7 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
return workspace ? ( return workspace ? (
<div> <div>
<StyledSettingH2 marginTop={56}>Workspace Icon</StyledSettingH2> <StyledSettingH2 marginTop={56}>{t('Workspace Icon')}</StyledSettingH2>
<StyledSettingAvatarContent> <StyledSettingAvatarContent>
<div <div
style={{ style={{
@@ -83,16 +85,16 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"
fileChange={fileChange} fileChange={fileChange}
> >
<Button loading={uploading}>Upload</Button> <Button loading={uploading}>{t('Upload')}</Button>
</Upload> </Upload>
{/* TODO: add upload logic */} {/* TODO: add upload logic */}
</StyledSettingAvatarContent> </StyledSettingAvatarContent>
<StyledSettingH2 marginTop={20}>Workspace Name</StyledSettingH2> <StyledSettingH2 marginTop={20}>{t('Workspace Name')}</StyledSettingH2>
<StyledSettingInputContainer> <StyledSettingInputContainer>
<Input <Input
width={327} width={327}
value={workspaceName} value={workspaceName}
placeholder="Workspace Name" placeholder={t('Workspace Name')}
maxLength={14} maxLength={14}
minLength={1} minLength={1}
onChange={handleChangeWorkSpaceName} onChange={handleChangeWorkSpaceName}
@@ -122,7 +124,7 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
'' ''
)} */} )} */}
<StyledSettingH2 marginTop={20}>Workspace Type</StyledSettingH2> <StyledSettingH2 marginTop={20}>{t('Workspace Type')}</StyledSettingH2>
<StyledSettingInputContainer> <StyledSettingInputContainer>
<code>{workspace.provider} </code> <code>{workspace.provider} </code>
</StyledSettingInputContainer> </StyledSettingInputContainer>
@@ -130,7 +132,7 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
{isOwner ? ( {isOwner ? (
<> <>
<Button type="danger" shape="circle" onClick={handleClickDelete}> <Button type="danger" shape="circle" onClick={handleClickDelete}>
Delete Workspace {t('Delete Workspace')}
</Button> </Button>
<WorkspaceDelete <WorkspaceDelete
open={showDelete} open={showDelete}
@@ -141,7 +143,7 @@ export const GeneralPage = ({ workspace }: { workspace: Workspace }) => {
) : ( ) : (
<> <>
<Button type="danger" shape="circle" onClick={handleClickLeave}> <Button type="danger" shape="circle" onClick={handleClickLeave}>
Leave Workspace {t('Leave Workspace')}
</Button> </Button>
<WorkspaceLeave <WorkspaceLeave
open={showLeave} open={showLeave}

View File

@@ -18,7 +18,7 @@ import {
// Workspace, // Workspace,
} from '@/hooks/mock-data/mock'; } from '@/hooks/mock-data/mock';
import { Workspace } from '@affine/datacenter'; import { Workspace } from '@affine/datacenter';
import { Trans, useTranslation } from 'react-i18next';
interface WorkspaceDeleteProps { interface WorkspaceDeleteProps {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -31,6 +31,7 @@ export const WorkspaceDelete = ({
workspace, workspace,
}: WorkspaceDeleteProps) => { }: WorkspaceDeleteProps) => {
const [deleteStr, setDeleteStr] = useState<string>(''); const [deleteStr, setDeleteStr] = useState<string>('');
const { t } = useTranslation();
const router = useRouter(); const router = useRouter();
const handlerInputChange = (workspaceName: string) => { const handlerInputChange = (workspaceName: string) => {
@@ -55,31 +56,40 @@ export const WorkspaceDelete = ({
<Modal open={open} onClose={onClose}> <Modal open={open} onClose={onClose}>
<StyledModalWrapper> <StyledModalWrapper>
<ModalCloseButton onClick={onClose} /> <ModalCloseButton onClick={onClose} />
<StyledModalHeader>Delete Workspace</StyledModalHeader> <StyledModalHeader>{t('Delete Workspace')}</StyledModalHeader>
{workspace.provider === 'local' ? ( {workspace.provider === 'local' ? (
<StyledTextContent> <StyledTextContent>
Deleting ( <Trans i18nKey="Delete Workspace Description">
<StyledWorkspaceName>{workspace.name}</StyledWorkspaceName>) cannot Deleting (
be undone, please proceed with caution. along with all its content. <StyledWorkspaceName>
{{ workspace: workspace.name }}
</StyledWorkspaceName>
) cannot be undone, please proceed with caution. along with all
its content.
</Trans>
</StyledTextContent> </StyledTextContent>
) : ( ) : (
<StyledTextContent> <StyledTextContent>
Deleting ( <Trans i18nKey="Delete Workspace Description2">
<StyledWorkspaceName>{workspace.name}</StyledWorkspaceName>) will Deleting (
delete both local and cloud data, this operation cannot be undone, <StyledWorkspaceName>
please proceed with caution. {{ workspace: workspace.name }}
</StyledWorkspaceName>
) will delete both local and cloud data, this operation cannot be
undone, please proceed with caution.
</Trans>
</StyledTextContent> </StyledTextContent>
)} )}
<StyledInputContent> <StyledInputContent>
<Input <Input
onChange={handlerInputChange} onChange={handlerInputChange}
placeholder="Please type “Delete” to confirm" placeholder={t('Delete Workspace placeholder')}
value={deleteStr} value={deleteStr}
></Input> ></Input>
</StyledInputContent> </StyledInputContent>
<StyledButtonContent> <StyledButtonContent>
<Button shape="circle" onClick={onClose}> <Button shape="circle" onClick={onClose}>
Cancel {t('Cancel')}
</Button> </Button>
<Button <Button
disabled={deleteStr.toLowerCase() !== 'delete'} disabled={deleteStr.toLowerCase() !== 'delete'}
@@ -88,7 +98,7 @@ export const WorkspaceDelete = ({
shape="circle" shape="circle"
style={{ marginLeft: '24px' }} style={{ marginLeft: '24px' }}
> >
Delete {t('Delete')}
</Button> </Button>
</StyledButtonContent> </StyledButtonContent>
</StyledModalWrapper> </StyledModalWrapper>

View File

@@ -7,6 +7,7 @@ import {
} from './style'; } from './style';
import { ModalCloseButton } from '@/ui/modal'; import { ModalCloseButton } from '@/ui/modal';
import { Button } from '@/ui/button'; import { Button } from '@/ui/button';
import { useTranslation } from 'react-i18next';
// import { getDataCenter } from '@affine/datacenter'; // import { getDataCenter } from '@affine/datacenter';
// import { useAppState } from '@/providers/app-state-provider'; // import { useAppState } from '@/providers/app-state-provider';
@@ -22,6 +23,7 @@ export const WorkspaceLeave = ({
onClose, onClose,
workspaceId, workspaceId,
}: WorkspaceDeleteProps) => { }: WorkspaceDeleteProps) => {
const { t } = useTranslation();
console.log('workspaceId: ', workspaceId); console.log('workspaceId: ', workspaceId);
// const router = useRouter(); // const router = useRouter();
// const { refreshWorkspacesMeta } = useAppState(); // const { refreshWorkspacesMeta } = useAppState();
@@ -37,14 +39,13 @@ export const WorkspaceLeave = ({
<Modal open={open} onClose={onClose}> <Modal open={open} onClose={onClose}>
<StyledModalWrapper> <StyledModalWrapper>
<ModalCloseButton onClick={onClose} /> <ModalCloseButton onClick={onClose} />
<StyledModalHeader>Leave Workspace</StyledModalHeader> <StyledModalHeader>{t('Leave Workspace')}</StyledModalHeader>
<StyledTextContent> <StyledTextContent>
After you leave, you will not be able to access all the contents of {t('Leave Workspace Description')}
this workspace.
</StyledTextContent> </StyledTextContent>
<StyledButtonContent> <StyledButtonContent>
<Button shape="circle" onClick={onClose}> <Button shape="circle" onClick={onClose}>
Cancel {t('Cancel')}
</Button> </Button>
<Button <Button
onClick={handleLeave} onClick={handleLeave}
@@ -52,7 +53,7 @@ export const WorkspaceLeave = ({
shape="circle" shape="circle"
style={{ marginLeft: '24px' }} style={{ marginLeft: '24px' }}
> >
Leave {t('Leave')}
</Button> </Button>
</StyledButtonContent> </StyledButtonContent>
</StyledModalWrapper> </StyledModalWrapper>

View File

@@ -157,7 +157,7 @@ export const WorkSpaceSliderBar = () => {
setShowWorkspaceSetting(true); setShowWorkspaceSetting(true);
}} }}
> >
<SettingsIcon /> Setting <SettingsIcon /> {t('Settings')}
</StyledListItem> </StyledListItem>
<WorkspaceSetting <WorkspaceSetting

View File

@@ -1,8 +1,11 @@
{ {
"Quick search": "Quick search", "Quick search": "Quick search",
"Quick search placeholder": "Quick Search...",
"Quick search placeholder2": "Search in {{workspace}}",
"All pages": "All pages", "All pages": "All pages",
"Favourites": "Favourites", "Favourites": "Favourites",
"No item": "No item", "No item": "No item",
"Settings": "Settings",
"Import": "Import", "Import": "Import",
"Trash": "Trash", "Trash": "Trash",
"New Page": "New Page", "New Page": "New Page",
@@ -75,5 +78,59 @@
"Restore it": "Restore it", "Restore it": "Restore it",
"TrashButtonGroupTitle": "Permanently delete", "TrashButtonGroupTitle": "Permanently delete",
"TrashButtonGroupDescription": "Once deleted, you can't undo this action. Do you confirm?", "TrashButtonGroupDescription": "Once deleted, you can't undo this action. Do you confirm?",
"Delete permanently": "Delete permanently" "Delete permanently": "Delete permanently",
"recommendBrowser": " We recommend the <1>Chrome</1> browser for optimal experience.",
"upgradeBrowser": "Please upgrade to the latest version of Chrome for the best experience.",
"Invite Members": "Invite Members",
"Invite placeholder": "Search mail (Gmail support only)",
"Non-Gmail": "Non-Gmail is not supported",
"Invite": "Invite",
"Loading": "Loading...",
"NotLoggedIn": "Currently not logged in",
"ClearData": "Clear local data",
"Continue with Google": "Continue with Google",
"Set up an AFFiNE account to sync data": "Set up an AFFiNE account to sync data",
"Stay logged out": "Stay logged out",
"All changes are saved locally": "All changes are saved locally",
"Ooops!": "Ooops!",
"mobile device": "Looks like you are browsing on a mobile device.",
"mobile device description": "We are still working on mobile support and recommend you use a desktop device.",
"Got it": "Got it",
"emptyAllPages": "This workspace is empty. Create a new page to begin editing.",
"emptyFavourite": "Click Add to Favourites and the page will appear here.",
"emptyTrash": "Click Add to Trash and the page will appear here.",
"still designed": "(This page is still being designed.)",
"My Workspaces": "My Workspaces",
"Create Or Import": "Create Or Import",
"Tips": "Tips: ",
"login success": "Login success",
"Sign in": "Sign in AFFiNE Cloud",
"Sign out": "Sign out of AFFiNE Cloud",
"Delete Workspace": "Delete Workspace",
"Delete Workspace Description": "Deleting (<1>{{workspace}}</1>) cannot be undone, please proceed with caution. along with all its content.",
"Delete Workspace Description2": "Deleting (<1>{{workspace}}</1>) will delete both local and cloud data, this operation cannot be undone, please proceed with caution.",
"Delete Workspace placeholder": "Please type “Delete” to confirm",
"Leave Workspace": "Leave Workspace",
"Leave Workspace Description": "After you leave, you will not be able to access all the contents of this workspace.",
"Leave": "Leave",
"Workspace Icon": "Workspace Icon",
"Workspace Name": "Workspace Name",
"Workspace Type": "Workspace Type",
"Export Workspace": "Export Workspace <1>{{workspace}}</1> Is Coming",
"Users": "Users",
"Access level": "Access level",
"Pending": "Pending",
"Collaboration Description": "Collaborating with other members requires AFFiNE Cloud service.",
"Enable AFFiNE Cloud": "Enable AFFiNE Cloud",
"Enable AFFiNE Cloud Description": "If enabled, the data in this workspace will be backed up and synchronised via AFFiNE Cloud.",
"Enable": "Enable",
"Sign in and Enable": "Sign in and Enable",
"Skip": "Skip",
"Publishing": "Publishing to web requires AFFiNE Cloud service.",
"Share with link": "Share with link",
"Copy Link": "Copy Link",
"Publishing Description": "After publishing to the web, everyone can view the content of this workspace through the link.",
"Stop publishing": "Stop publishing",
"Publish to web": "Publish to web",
"Sync Description": "{{workspaceName}} is Local Workspace. All data is stored on the current device. You can enable AFFiNE Cloud for this workspace to keep data in sync with the cloud."
} }

View File

@@ -14,6 +14,7 @@ const All = () => {
<PageList <PageList
pageList={pageMetaList.filter(p => !p.trash)} pageList={pageMetaList.filter(p => !p.trash)}
showFavoriteTag={true} showFavoriteTag={true}
listType="all"
/> />
</> </>
); );

View File

@@ -13,7 +13,10 @@ export const Favorite = () => {
<PageListHeader icon={<FavouritesIcon />}> <PageListHeader icon={<FavouritesIcon />}>
{t('Favourites')} {t('Favourites')}
</PageListHeader> </PageListHeader>
<PageList pageList={pageMetaList.filter(p => p.favorite && !p.trash)} /> <PageList
pageList={pageMetaList.filter(p => p.favorite && !p.trash)}
listType="favorite"
/>
</> </>
); );
}; };

View File

@@ -11,7 +11,11 @@ export const Trash = () => {
return ( return (
<> <>
<PageListHeader icon={<TrashIcon />}>{t('Trash')}</PageListHeader> <PageListHeader icon={<TrashIcon />}>{t('Trash')}</PageListHeader>
<PageList pageList={pageMetaList.filter(p => p.trash)} isTrash={true} /> <PageList
pageList={pageMetaList.filter(p => p.trash)}
isTrash={true}
listType="trash"
/>
</> </>
); );
}; };