Merge pull request #667 from toeverything/feat/add-i18n

feat:add i18n support
This commit is contained in:
DarkSky
2023-01-04 20:22:41 +08:00
committed by GitHub
21 changed files with 284 additions and 194 deletions

View File

@@ -1,9 +1,10 @@
import { NotFoundTitle, PageContainer } from './styles'; import { NotFoundTitle, PageContainer } from './styles';
import { useTranslation } from 'react-i18next';
export const NotfoundPage = () => { export const NotfoundPage = () => {
const { t } = useTranslation();
return ( return (
<PageContainer> <PageContainer>
<NotFoundTitle>404 - Page Not Found</NotFoundTitle> <NotFoundTitle>{t('404 - Page Not Found')}</NotFoundTitle>
</PageContainer> </PageContainer>
); );
}; };

View File

@@ -23,7 +23,7 @@ import {
StyledModalFooter, StyledModalFooter,
} from './style'; } from './style';
import bg from '@/components/contact-modal/bg.png'; import bg from '@/components/contact-modal/bg.png';
import { useTranslation } from 'react-i18next';
const linkList = [ const linkList = [
{ {
icon: <GithubIcon />, icon: <GithubIcon />,
@@ -51,20 +51,6 @@ const linkList = [
link: 'https://discord.gg/Arn7TqJBvG', link: 'https://discord.gg/Arn7TqJBvG',
}, },
]; ];
const rightLinkList = [
{
icon: <LogoIcon />,
title: 'Official Website ',
subTitle: 'AFFiNE.pro',
link: 'https://affine.pro',
},
{
icon: <DocIcon />,
title: 'AFFiNE Community',
subTitle: 'community.affine.pro',
link: 'https://community.affine.pro',
},
];
type TransitionsModalProps = { type TransitionsModalProps = {
open: boolean; open: boolean;
@@ -72,6 +58,21 @@ type TransitionsModalProps = {
}; };
export const ContactModal = ({ open, onClose }: TransitionsModalProps) => { export const ContactModal = ({ open, onClose }: TransitionsModalProps) => {
const { t } = useTranslation();
const rightLinkList = [
{
icon: <LogoIcon />,
title: t('Official Website'),
subTitle: 'AFFiNE.pro',
link: 'https://affine.pro',
},
{
icon: <DocIcon />,
title: t('AFFiNE Community'),
subTitle: 'community.affine.pro',
link: 'https://community.affine.pro',
},
];
return ( return (
<Modal open={open} onClose={onClose} data-testid="contact-us-modal-content"> <Modal open={open} onClose={onClose} data-testid="contact-us-modal-content">
<ModalWrapper <ModalWrapper
@@ -109,7 +110,7 @@ export const ContactModal = ({ open, onClose }: TransitionsModalProps) => {
})} })}
</StyledLeftContainer> </StyledLeftContainer>
<StyledRightContainer> <StyledRightContainer>
<StyledSubTitle>Get in touch!</StyledSubTitle> <StyledSubTitle>{t('Get in touch!')}</StyledSubTitle>
{linkList.map(({ icon, title, link }) => { {linkList.map(({ icon, title, link }) => {
return ( return (
<StyledSmallLink key={title} href={link} target="_blank"> <StyledSmallLink key={title} href={link} target="_blank">
@@ -128,7 +129,7 @@ export const ContactModal = ({ open, onClose }: TransitionsModalProps) => {
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >
How is AFFiNE Alpha different? {t('How is AFFiNE Alpha different?')}
</a> </a>
</p> </p>
<p>Copyright &copy; 2022 Toeverything</p> <p>Copyright &copy; 2022 Toeverything</p>

View File

@@ -15,7 +15,7 @@ import { useTheme } from '@/providers/themeProvider';
import { EdgelessIcon, PaperIcon } from './icons'; import { EdgelessIcon, PaperIcon } from './icons';
import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useTranslation } from 'react-i18next';
const PaperItem = ({ active }: { active?: boolean }) => { const PaperItem = ({ active }: { active?: boolean }) => {
const { const {
theme: { theme: {
@@ -96,7 +96,7 @@ export const EditorModeSwitch = ({
setRadioItemStatus(modifyRadioItemStatus()); setRadioItemStatus(modifyRadioItemStatus());
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isHover, mode]); }, [isHover, mode]);
const { t } = useTranslation();
return ( return (
<StyledAnimateRadioContainer <StyledAnimateRadioContainer
data-testid="editor-mode-switcher" data-testid="editor-mode-switcher"
@@ -106,7 +106,7 @@ export const EditorModeSwitch = ({
> >
<AnimateRadioItem <AnimateRadioItem
isLeft={true} isLeft={true}
label="Paper" label={t('Paper')}
icon={<PaperItem />} icon={<PaperItem />}
active={mode === 'page'} active={mode === 'page'}
status={radioItemStatus.left} status={radioItemStatus.left}
@@ -126,7 +126,7 @@ export const EditorModeSwitch = ({
<StyledMiddleLine hidden={!isHover} dark={themeMode === 'dark'} /> <StyledMiddleLine hidden={!isHover} dark={themeMode === 'dark'} />
<AnimateRadioItem <AnimateRadioItem
isLeft={false} isLeft={false}
label="Edgeless" label={t('Edgeless')}
data-testid="switch-edgeless-item" data-testid="switch-edgeless-item"
icon={<EdgelessItem />} icon={<EdgelessItem />}
active={mode === 'edgeless'} active={mode === 'edgeless'}

View File

@@ -16,12 +16,13 @@ import { usePageHelper } from '@/hooks/use-page-helper';
import { useConfirm } from '@/providers/confirm-provider'; import { useConfirm } from '@/providers/confirm-provider';
import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { toast } from '@/ui/toast'; import { toast } from '@/ui/toast';
import { useTranslation } from 'react-i18next';
const PopoverContent = () => { const PopoverContent = () => {
const { editor } = useAppState(); const { editor } = useAppState();
const { toggleFavoritePage, toggleDeletePage } = usePageHelper(); const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
const { changePageMode } = usePageHelper(); const { changePageMode } = usePageHelper();
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const { t } = useTranslation();
const { const {
mode = 'page', mode = 'page',
id = '', id = '',
@@ -35,11 +36,13 @@ const PopoverContent = () => {
data-testid="editor-option-menu-favorite" data-testid="editor-option-menu-favorite"
onClick={() => { onClick={() => {
toggleFavoritePage(id); toggleFavoritePage(id);
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites'); toast(
!favorite ? t('Removed to Favourites') : t('Added to Favourites')
);
}} }}
icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />} icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />}
> >
{favorite ? 'Remove' : 'Add'} to favourites {favorite ? t('Remove to favourites') : t('Add to favourites')}
</MenuItem> </MenuItem>
<MenuItem <MenuItem
icon={mode === 'page' ? <EdgelessIcon /> : <PaperIcon />} icon={mode === 'page' ? <EdgelessIcon /> : <PaperIcon />}
@@ -48,7 +51,8 @@ const PopoverContent = () => {
changePageMode(id, mode === 'page' ? 'edgeless' : 'page'); changePageMode(id, mode === 'page' ? 'edgeless' : 'page');
}} }}
> >
Convert to {mode === 'page' ? 'Edgeless' : 'Page'} {t('Convert to ')}
{mode === 'page' ? t('Edgeless') : t('Page')}
</MenuItem> </MenuItem>
<Menu <Menu
placement="left-start" placement="left-start"
@@ -60,7 +64,7 @@ const PopoverContent = () => {
}} }}
icon={<ExportToHtmlIcon />} icon={<ExportToHtmlIcon />}
> >
Export to HTML {t('Export to HTML')}
</MenuItem> </MenuItem>
<MenuItem <MenuItem
onClick={() => { onClick={() => {
@@ -68,31 +72,33 @@ const PopoverContent = () => {
}} }}
icon={<ExportToMarkdownIcon />} icon={<ExportToMarkdownIcon />}
> >
Export to Markdown {t('Export to Markdown')}
</MenuItem> </MenuItem>
</> </>
} }
> >
<MenuItem icon={<ExportIcon />} isDir={true}> <MenuItem icon={<ExportIcon />} isDir={true}>
Export {t('Export')}
</MenuItem> </MenuItem>
</Menu> </Menu>
<MenuItem <MenuItem
data-testid="editor-option-menu-delete" data-testid="editor-option-menu-delete"
onClick={() => { onClick={() => {
confirm({ confirm({
title: 'Delete page?', title: t('Delete page?'),
content: `${title || 'Untitled'} will be moved to Trash`, content: t('will be moved to Trash', {
confirmText: 'Delete', title: title || 'Untitled',
}),
confirmText: t('Delete'),
confirmType: 'danger', confirmType: 'danger',
}).then(confirm => { }).then(confirm => {
confirm && toggleDeletePage(id); confirm && toggleDeletePage(id);
confirm && toast('Moved to Trash'); confirm && toast(t('Moved to Trash'));
}); });
}} }}
icon={<TrashIcon />} icon={<TrashIcon />}
> >
Delete {t('Delete')}
</MenuItem> </MenuItem>
</> </>
); );

View File

@@ -3,15 +3,15 @@ import { IconButton, IconButtonProps } from '@/ui/button';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import { ArrowDownIcon } from '@blocksuite/icons'; import { ArrowDownIcon } from '@blocksuite/icons';
import { useModal } from '@/providers/global-modal-provider'; import { useModal } from '@/providers/global-modal-provider';
import { useTranslation } from 'react-i18next';
export const QuickSearchButton = ({ export const QuickSearchButton = ({
onClick, onClick,
...props ...props
}: Omit<IconButtonProps, 'children'>) => { }: Omit<IconButtonProps, 'children'>) => {
const { triggerQuickSearchModal } = useModal(); const { triggerQuickSearchModal } = useModal();
const { t } = useTranslation();
return ( return (
<Tooltip content="Switch to" placement="bottom"> <Tooltip content={t('Switch to')} placement="bottom">
<IconButton <IconButton
data-testid="header-quickSearchButton" data-testid="header-quickSearchButton"
{...props} {...props}

View File

@@ -8,6 +8,7 @@ import {
import { CloseIcon, ContactIcon, HelpIcon, KeyboardIcon } from './icons'; import { CloseIcon, ContactIcon, HelpIcon, KeyboardIcon } from './icons';
import Grow from '@mui/material/Grow'; import Grow from '@mui/material/Grow';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import { useTranslation } from 'react-i18next';
import { useModal } from '@/providers/global-modal-provider'; import { useModal } from '@/providers/global-modal-provider';
import { useTheme } from '@/providers/themeProvider'; import { useTheme } from '@/providers/themeProvider';
import useCurrentPageMeta from '@/hooks/use-current-page-meta'; import useCurrentPageMeta from '@/hooks/use-current-page-meta';
@@ -22,7 +23,7 @@ export const HelpIsland = ({
const { mode: editorMode } = useCurrentPageMeta() || {}; const { mode: editorMode } = useCurrentPageMeta() || {};
const { triggerShortcutsModal, triggerContactModal } = useModal(); const { triggerShortcutsModal, triggerContactModal } = useModal();
const isEdgelessDark = mode === 'dark' && editorMode === 'edgeless'; const isEdgelessDark = mode === 'dark' && editorMode === 'edgeless';
const { t } = useTranslation();
return ( return (
<> <>
<StyledIsland <StyledIsland
@@ -37,7 +38,7 @@ export const HelpIsland = ({
<Grow in={showContent}> <Grow in={showContent}>
<StyledIslandWrapper> <StyledIslandWrapper>
{showList.includes('contact') && ( {showList.includes('contact') && (
<Tooltip content="Contact Us" placement="left-end"> <Tooltip content={t('Contact Us')} placement="left-end">
<StyledIconWrapper <StyledIconWrapper
data-testid="right-bottom-contact-us-icon" data-testid="right-bottom-contact-us-icon"
isEdgelessDark={isEdgelessDark} isEdgelessDark={isEdgelessDark}
@@ -51,7 +52,7 @@ export const HelpIsland = ({
</Tooltip> </Tooltip>
)} )}
{showList.includes('shortcuts') && ( {showList.includes('shortcuts') && (
<Tooltip content="Keyboard Shortcuts" placement="left-end"> <Tooltip content={t('Keyboard Shortcuts')} placement="left-end">
<StyledIconWrapper <StyledIconWrapper
data-testid="shortcuts-icon" data-testid="shortcuts-icon"
isEdgelessDark={isEdgelessDark} isEdgelessDark={isEdgelessDark}

View File

@@ -6,6 +6,7 @@ import Loading from '@/components/loading';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useAppState } from '@/providers/app-state-provider/context'; import { useAppState } from '@/providers/app-state-provider/context';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
// import { Tooltip } from '@/ui/tooltip'; // import { Tooltip } from '@/ui/tooltip';
type ImportModalProps = { type ImportModalProps = {
open: boolean; open: boolean;
@@ -19,6 +20,7 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
const [status, setStatus] = useState<'unImported' | 'importing'>('importing'); const [status, setStatus] = useState<'unImported' | 'importing'>('importing');
const { openPage, createPage } = usePageHelper(); const { openPage, createPage } = usePageHelper();
const { currentWorkspace } = useAppState(); const { currentWorkspace } = useAppState();
const { t } = useTranslation();
const _applyTemplate = function (pageId: string, template: Template) { const _applyTemplate = function (pageId: string, template: Template) {
const page = currentWorkspace?.getPage(pageId); const page = currentWorkspace?.getPage(pageId);
@@ -84,7 +86,7 @@ export const ImportModal = ({ open, onClose }: ImportModalProps) => {
<Modal open={open} onClose={onClose}> <Modal open={open} onClose={onClose}>
<ModalWrapper width={460} minHeight={240}> <ModalWrapper width={460} minHeight={240}>
<ModalCloseButton onClick={onClose} /> <ModalCloseButton onClick={onClose} />
<StyledTitle>Import</StyledTitle> <StyledTitle>{t('Import')}</StyledTitle>
{status === 'unImported' && ( {status === 'unImported' && (
<StyledButtonWrapper> <StyledButtonWrapper>

View File

@@ -24,7 +24,7 @@ import { useAppState } from '@/providers/app-state-provider/context';
import { toast } from '@/ui/toast'; import { toast } from '@/ui/toast';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useTheme } from '@/providers/themeProvider'; import { useTheme } from '@/providers/themeProvider';
import { useTranslation } from 'react-i18next';
const FavoriteTag = ({ const FavoriteTag = ({
pageMeta: { favorite, id }, pageMeta: { favorite, id },
}: { }: {
@@ -32,9 +32,10 @@ const FavoriteTag = ({
}) => { }) => {
const { toggleFavoritePage } = usePageHelper(); const { toggleFavoritePage } = usePageHelper();
const { theme } = useTheme(); const { theme } = useTheme();
const { t } = useTranslation();
return ( return (
<Tooltip <Tooltip
content={favorite ? 'Favourited' : 'Favourite'} content={favorite ? t('Favourited') : t('Favourite')}
placement="top-start" placement="top-start"
> >
<IconButton <IconButton
@@ -43,7 +44,9 @@ const FavoriteTag = ({
onClick={e => { onClick={e => {
e.stopPropagation(); e.stopPropagation();
toggleFavoritePage(id); toggleFavoritePage(id);
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites'); toast(
!favorite ? t('Removed to Favourites') : t('Added to Favourites')
);
}} }}
style={{ style={{
color: favorite ? theme.colors.primaryColor : theme.colors.iconColor, color: favorite ? theme.colors.primaryColor : theme.colors.iconColor,
@@ -71,6 +74,7 @@ export const PageList = ({
}) => { }) => {
const router = useRouter(); const router = useRouter();
const { currentWorkspaceId } = useAppState(); const { currentWorkspaceId } = useAppState();
const { t } = useTranslation();
if (pageList.length === 0) { if (pageList.length === 0) {
return <Empty />; return <Empty />;
} }
@@ -80,10 +84,10 @@ export const PageList = ({
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell proportion={0.5}>Title</TableCell> <TableCell proportion={0.5}>{t('Title')}</TableCell>
<TableCell proportion={0.2}>Created</TableCell> <TableCell proportion={0.2}>{t('Created')}</TableCell>
<TableCell proportion={0.2}> <TableCell proportion={0.2}>
{isTrash ? 'Moved to Trash' : 'Updated'} {isTrash ? t('Moved to Trash') : t('Updated')}
</TableCell> </TableCell>
<TableCell proportion={0.1}></TableCell> <TableCell proportion={0.1}></TableCell>
</TableRow> </TableRow>
@@ -108,7 +112,7 @@ export const PageList = ({
<PaperIcon /> <PaperIcon />
)} )}
<Content ellipsis={true} color="inherit"> <Content ellipsis={true} color="inherit">
{pageMeta.title || 'Untitled'} {pageMeta.title || t('Untitled')}
</Content> </Content>
</StyledTitleLink> </StyledTitleLink>
{showFavoriteTag && <FavoriteTag pageMeta={pageMeta} />} {showFavoriteTag && <FavoriteTag pageMeta={pageMeta} />}

View File

@@ -14,23 +14,25 @@ import {
} from '@blocksuite/icons'; } from '@blocksuite/icons';
import { toast } from '@/ui/toast'; import { toast } from '@/ui/toast';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useTranslation } from 'react-i18next';
export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => { export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
const { id, favorite } = pageMeta; const { id, favorite } = pageMeta;
const { openPage } = usePageHelper(); const { openPage } = usePageHelper();
const { toggleFavoritePage, toggleDeletePage } = usePageHelper(); const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const { t } = useTranslation();
const OperationMenu = ( const OperationMenu = (
<> <>
<MenuItem <MenuItem
onClick={() => { onClick={() => {
toggleFavoritePage(id); toggleFavoritePage(id);
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites'); toast(
!favorite ? t('Removed to Favourites') : t('Added to Favourites')
);
}} }}
icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />} icon={favorite ? <FavouritedIcon /> : <FavouritesIcon />}
> >
{favorite ? 'Remove' : 'Add'} to favourites {favorite ? t('Remove to favourites') : t('Add to favourites')}
</MenuItem> </MenuItem>
<MenuItem <MenuItem
onClick={() => { onClick={() => {
@@ -38,23 +40,25 @@ export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
}} }}
icon={<OpenInNewIcon />} icon={<OpenInNewIcon />}
> >
Open in new tab {t('Open in new tab')}
</MenuItem> </MenuItem>
<MenuItem <MenuItem
onClick={() => { onClick={() => {
confirm({ confirm({
title: 'Delete page?', title: t('Delete page?'),
content: `${pageMeta.title || 'Untitled'} will be moved to Trash`, content: t('will be moved to Trash', {
confirmText: 'Delete', title: pageMeta.title || 'Untitled',
}),
confirmText: t('Delete'),
confirmType: 'danger', confirmType: 'danger',
}).then(confirm => { }).then(confirm => {
confirm && toggleDeletePage(id); confirm && toggleDeletePage(id);
toast('Moved to Trash'); toast(t('Moved to Trash'));
}); });
}} }}
icon={<TrashIcon />} icon={<TrashIcon />}
> >
Delete {t('Delete')}
</MenuItem> </MenuItem>
</> </>
); );
@@ -74,7 +78,7 @@ export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
const { openPage, getPageMeta } = usePageHelper(); const { openPage, getPageMeta } = usePageHelper();
const { toggleDeletePage, permanentlyDeletePage } = usePageHelper(); const { toggleDeletePage, permanentlyDeletePage } = usePageHelper();
const { confirm } = useConfirm(); const { confirm } = useConfirm();
const { t } = useTranslation();
return ( return (
<Wrapper> <Wrapper>
<IconButton <IconButton
@@ -82,7 +86,7 @@ export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
style={{ marginRight: '12px' }} style={{ marginRight: '12px' }}
onClick={() => { onClick={() => {
toggleDeletePage(id); toggleDeletePage(id);
toast(`${getPageMeta(id)?.title || 'Untitled'} restored`); toast(t('restored', { title: getPageMeta(id)?.title || 'Untitled' }));
openPage(id); openPage(id);
}} }}
> >
@@ -92,13 +96,13 @@ export const TrashOperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
darker={true} darker={true}
onClick={() => { onClick={() => {
confirm({ confirm({
title: 'Delete permanently?', title: t('Delete permanently?'),
content: "Once deleted, you can't undo this action.", content: t("Once deleted, you can't undo this action."),
confirmText: 'Delete', confirmText: t('Delete'),
confirmType: 'danger', confirmType: 'danger',
}).then(confirm => { }).then(confirm => {
confirm && permanentlyDeletePage(id); confirm && permanentlyDeletePage(id);
toast('Permanently deleted'); toast(t('Permanently deleted'));
}); });
}} }}
> >

View File

@@ -1,21 +1,22 @@
import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons'; import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons';
import { useTranslation } from 'react-i18next';
export const config = (currentWorkspaceId: string) => { export const useSwitchToConfig = (currentWorkspaceId: string) => {
const { t } = useTranslation();
const List = [ const List = [
{ {
title: 'All pages', title: t('All pages'),
href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '', href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
icon: AllPagesIcon, icon: AllPagesIcon,
}, },
{ {
title: 'Favourites', title: t('Favourites'),
href: currentWorkspaceId href: currentWorkspaceId
? `/workspace/${currentWorkspaceId}/favorite` ? `/workspace/${currentWorkspaceId}/favorite`
: '', : '',
icon: FavouritesIcon, icon: FavouritesIcon,
}, },
{ {
title: 'Trash', title: t('Trash'),
href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/trash` : '', href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/trash` : '',
icon: TrashIcon, icon: TrashIcon,
}, },

View File

@@ -4,10 +4,11 @@ import { StyledModalFooterContent } from './style';
import { useModal } from '@/providers/global-modal-provider'; import { useModal } from '@/providers/global-modal-provider';
import { Command } from 'cmdk'; import { Command } from 'cmdk';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useTranslation } from 'react-i18next';
export const Footer = (props: { query: string }) => { export const Footer = (props: { query: string }) => {
const { triggerQuickSearchModal } = useModal(); const { triggerQuickSearchModal } = useModal();
const { openPage, createPage } = usePageHelper(); const { openPage, createPage } = usePageHelper();
const { t } = useTranslation();
const query = props.query; const query = props.query;
return ( return (
@@ -25,9 +26,9 @@ export const Footer = (props: { query: string }) => {
<StyledModalFooterContent> <StyledModalFooterContent>
<AddIcon /> <AddIcon />
{query ? ( {query ? (
<span>New &quot;{query}&quot; page</span> <span>{t('New Keyword Page', { query: query })}</span>
) : ( ) : (
<span>New page</span> <span>{t('New Page')}</span>
)} )}
</StyledModalFooterContent> </StyledModalFooterContent>
</Command.Item> </Command.Item>

View File

@@ -5,8 +5,9 @@ import { PaperIcon, EdgelessIcon } from '@blocksuite/icons';
import { Dispatch, SetStateAction, useEffect, useState } from 'react'; import { Dispatch, SetStateAction, useEffect, useState } from 'react';
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 { config } from './config'; import { useSwitchToConfig } from './config';
import { NoResultSVG } from './noResultSVG'; import { NoResultSVG } from './noResultSVG';
import { useTranslation } from 'react-i18next';
import usePageHelper from '@/hooks/use-page-helper'; import usePageHelper from '@/hooks/use-page-helper';
import usePageMetaList from '@/hooks/use-page-meta-list'; import usePageMetaList from '@/hooks/use-page-meta-list';
export const Results = (props: { export const Results = (props: {
@@ -25,8 +26,9 @@ export const Results = (props: {
const router = useRouter(); const router = useRouter();
const { currentWorkspaceId } = useAppState(); const { currentWorkspaceId } = useAppState();
const { search } = usePageHelper(); const { search } = usePageHelper();
const List = config(currentWorkspaceId); const List = useSwitchToConfig(currentWorkspaceId);
const [results, setResults] = useState(new Map<string, string | undefined>()); const [results, setResults] = useState(new Map<string, string | undefined>());
const { t } = useTranslation();
useEffect(() => { useEffect(() => {
setResults(search(query)); setResults(search(query));
setLoading(false); setLoading(false);
@@ -47,7 +49,9 @@ export const Results = (props: {
<> <>
{query ? ( {query ? (
resultsPageMeta.length ? ( resultsPageMeta.length ? (
<Command.Group heading={`Find ${resultsPageMeta.length} results`}> <Command.Group
heading={t('Find results', { number: resultsPageMeta.length })}
>
{resultsPageMeta.map(result => { {resultsPageMeta.map(result => {
return ( return (
<Command.Item <Command.Item
@@ -72,12 +76,12 @@ export const Results = (props: {
</Command.Group> </Command.Group>
) : ( ) : (
<StyledNotFound> <StyledNotFound>
<span>Find 0 result</span> <span>{t('Find 0 result')}</span>
<NoResultSVG /> <NoResultSVG />
</StyledNotFound> </StyledNotFound>
) )
) : ( ) : (
<Command.Group heading="Switch to"> <Command.Group heading={t('Switch to')}>
{List.map(link => { {List.map(link => {
return ( return (
<Command.Item <Command.Item

View File

@@ -1,71 +1,85 @@
export const macKeyboardShortcuts = { import { useTranslation } from 'react-i18next';
Undo: '⌘+Z', export const useMacKeyboardShortcuts = () => {
Redo: '⌘+⇧+Z', const { t } = useTranslation();
Bold: '⌘+B', return {
Italic: '⌘+I', [t('Undo')]: '⌘+Z',
Underline: '⌘+U', [t('Redo')]: '⌘+⇧+Z',
Strikethrough: '⌘+⇧+S', [t('Bold')]: '⌘+B',
'Inline code': ' ⌘+E', [t('Italic')]: '⌘+I',
'Code block': '⌘+⌥+C', [t('Underline')]: '⌘+U',
Link: '⌘+K', [t('Strikethrough')]: '⌘+⇧+S',
'Body text': '⌘+⌥+0', [t('Inline code')]: ' ⌘+E',
'Heading 1': '⌘+⌥+1', [t('Code block')]: '⌘+⌥+C',
'Heading 2': '⌘+⌥+2', [t('Link')]: '⌘+K',
'Heading 3': '⌘+⌥+3', [t('Body text')]: '⌘+⌥+0',
'Heading 4': '⌘+⌥+4', [t('Heading', { number: '1' })]: '⌘+⌥+1',
'Heading 5': '⌘+⌥+5', [t('Heading', { number: '2' })]: '⌘+⌥+2',
'Heading 6': '⌘+⌥+6', [t('Heading', { number: '3' })]: '⌘+⌥+3',
'Increase indent': 'Tab', [t('Heading', { number: '4' })]: '⌘+⌥+4',
'Reduce indent': '⇧+Tab', [t('Heading', { number: '5' })]: '⌘+⌥+5',
[t('Heading', { number: '6' })]: '⌘+⌥+6',
[t('Increase indent')]: 'Tab',
[t('Reduce indent')]: '⇧+Tab',
};
}; };
export const macMarkdownShortcuts = { export const useMacMarkdownShortcuts = () => {
Bold: '**Text** ', const { t } = useTranslation();
Italic: '*Text* ', return {
Underline: '~Text~ ', [t('Bold')]: '**Text** ',
Strikethrough: '~~Text~~ ', [t('Italic')]: '*Text* ',
Divider: '***', [t('Underline')]: '~Text~ ',
'Inline code': '`Text` ', [t('Strikethrough')]: '~~Text~~ ',
'Code block': '``` Space', [t('Divider')]: '***',
'Heading 1': '# Text', [t('Inline code')]: '`Text` ',
'Heading 2': '## Text', [t('Code block')]: '``` Space',
'Heading 3': '### Text', [t('Heading', { number: '1' })]: '# Text',
'Heading 4': '#### Text', [t('Heading', { number: '2' })]: '## Text',
'Heading 5': '##### Text', [t('Heading', { number: '3' })]: '### Text',
'Heading 6': '###### Text', [t('Heading', { number: '4' })]: '#### Text',
[t('Heading', { number: '5' })]: '##### Text',
[t('Heading', { number: '6' })]: '###### Text',
};
}; };
export const windowsKeyboardShortcuts = { export const useWindowsKeyboardShortcuts = () => {
Undo: 'Ctrl+Z', const { t } = useTranslation();
Redo: 'Ctrl+Y', return {
Bold: 'Ctrl+B', [t('Undo')]: 'Ctrl+Z',
Italic: 'Ctrl+I', [t('Redo')]: 'Ctrl+Y',
Underline: 'Ctrl+U', [t('Bold')]: 'Ctrl+B',
Strikethrough: 'Ctrl+Shift+S', [t('Italic')]: 'Ctrl+I',
'Inline code': ' Ctrl+E', [t('Underline')]: 'Ctrl+U',
'Code block': 'Ctrl+Alt+C', [t('Strikethrough')]: 'Ctrl+Shift+S',
Link: 'Ctrl+K', [t('Inline code')]: ' Ctrl+E',
'Body text': 'Ctrl+Shift+0', [t('Code block')]: 'Ctrl+Alt+C',
'Heading 1': 'Ctrl+Shift+1', [t('Link')]: 'Ctrl+K',
'Heading 2': 'Ctrl+Shift+2', [t('Body text')]: 'Ctrl+Shift+0',
'Heading 3': 'Ctrl+Shift+3', [t('Heading', { number: '1' })]: 'Ctrl+Shift+1',
'Heading 4': 'Ctrl+Shift+4', [t('Heading', { number: '2' })]: 'Ctrl+Shift+2',
'Heading 5': 'Ctrl+Shift+5', [t('Heading', { number: '3' })]: 'Ctrl+Shift+3',
'Heading 6': 'Ctrl+Shift+6', [t('Heading', { number: '4' })]: 'Ctrl+Shift+4',
'Increase indent': 'Tab', [t('Heading', { number: '5' })]: 'Ctrl+Shift+5',
'Reduce indent': 'Shift+Tab', [t('Heading', { number: '6' })]: 'Ctrl+Shift+6',
[t('Increase indent')]: 'Tab',
[t('Reduce indent')]: 'Shift+Tab',
};
};
export const useWinMarkdownShortcuts = () => {
const { t } = useTranslation();
return {
[t('Bold')]: '**Text** ',
[t('Italic')]: '*Text* ',
[t('Underline')]: '~Text~ ',
[t('Strikethrough')]: '~~Text~~ ',
[t('Divider')]: '***',
[t('Inline code')]: '`Text` ',
[t('Code block')]: '``` Text',
[t('Heading', { number: '1' })]: '# Text',
[t('Heading', { number: '2' })]: '## Text',
[t('Heading', { number: '3' })]: '### Text',
[t('Heading', { number: '4' })]: '#### Text',
[t('Heading', { number: '5' })]: '##### Text',
[t('Heading', { number: '6' })]: '###### Text',
}; };
export const winMarkdownShortcuts = {
Bold: '**Text** ',
Italic: '*Text* ',
Underline: '~Text~ ',
Strikethrough: '~~Text~~ ',
'Inline code': '`Text` ',
'Code block': '``` Text',
'Heading 1': '# Text',
'Heading 2': '## Text',
'Heading 3': '### Text',
'Heading 4': '#### Text',
'Heading 5': '##### Text',
'Heading 6': '###### Text',
}; };

View File

@@ -8,14 +8,15 @@ import {
StyledTitle, StyledTitle,
} from './style'; } from './style';
import { import {
macKeyboardShortcuts, useMacKeyboardShortcuts,
macMarkdownShortcuts, useMacMarkdownShortcuts,
windowsKeyboardShortcuts, useWindowsKeyboardShortcuts,
winMarkdownShortcuts, useWinMarkdownShortcuts,
} from '@/components/shortcuts-modal/config'; } from '@/components/shortcuts-modal/config';
import Slide from '@mui/material/Slide'; import Slide from '@mui/material/Slide';
import { ModalCloseButton } from '@/ui/modal'; import { ModalCloseButton } from '@/ui/modal';
import { getUaHelper } from '@/utils'; import { getUaHelper } from '@/utils';
import { useTranslation } from 'react-i18next';
type ModalProps = { type ModalProps = {
open: boolean; open: boolean;
onClose: () => void; onClose: () => void;
@@ -26,12 +27,18 @@ const isMac = () => {
}; };
export const ShortcutsModal = ({ open, onClose }: ModalProps) => { export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
const { t } = useTranslation();
const macMarkdownShortcuts = useMacMarkdownShortcuts();
const winMarkdownShortcuts = useWinMarkdownShortcuts();
const macKeyboardShortcuts = useMacKeyboardShortcuts();
const windowsKeyboardShortcuts = useWindowsKeyboardShortcuts();
const markdownShortcuts = isMac() const markdownShortcuts = isMac()
? macMarkdownShortcuts ? macMarkdownShortcuts
: winMarkdownShortcuts; : winMarkdownShortcuts;
const keyboardShortcuts = isMac() const keyboardShortcuts = isMac()
? macKeyboardShortcuts ? macKeyboardShortcuts
: windowsKeyboardShortcuts; : windowsKeyboardShortcuts;
return createPortal( return createPortal(
<Slide direction="left" in={open} mountOnEnter unmountOnExit> <Slide direction="left" in={open} mountOnEnter unmountOnExit>
<StyledShortcutsModal data-testid="shortcuts-modal"> <StyledShortcutsModal data-testid="shortcuts-modal">
@@ -39,7 +46,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
<StyledModalHeader> <StyledModalHeader>
<StyledTitle> <StyledTitle>
<KeyboardIcon /> <KeyboardIcon />
Shortcuts {t('Shortcuts')}
</StyledTitle> </StyledTitle>
<ModalCloseButton <ModalCloseButton
@@ -53,7 +60,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
/> />
</StyledModalHeader> </StyledModalHeader>
<StyledSubTitle style={{ marginTop: 0 }}> <StyledSubTitle style={{ marginTop: 0 }}>
Keyboard Shortcuts {t('Keyboard Shortcuts')}
</StyledSubTitle> </StyledSubTitle>
{Object.entries(keyboardShortcuts).map(([title, shortcuts]) => { {Object.entries(keyboardShortcuts).map(([title, shortcuts]) => {
return ( return (
@@ -63,7 +70,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
</StyledListItem> </StyledListItem>
); );
})} })}
<StyledSubTitle>Markdown Syntax</StyledSubTitle> <StyledSubTitle>{t('Markdown Syntax')}</StyledSubTitle>
{Object.entries(markdownShortcuts).map(([title, shortcuts]) => { {Object.entries(markdownShortcuts).map(([title, shortcuts]) => {
return ( return (
<StyledListItem key={title}> <StyledListItem key={title}>

View File

@@ -25,18 +25,18 @@ import Link from 'next/link';
import { Tooltip } from '@/ui/tooltip'; import { Tooltip } from '@/ui/tooltip';
import { useModal } from '@/providers/global-modal-provider'; import { useModal } from '@/providers/global-modal-provider';
import { useAppState } from '@/providers/app-state-provider/context'; import { useAppState } from '@/providers/app-state-provider/context';
import { IconButton } from '@/ui/button'; import { IconButton } from '@/ui/button';
// import { WorkspaceSelector } from './WorkspaceSelector'; // import { WorkspaceSelector } from './WorkspaceSelector';
import useLocalStorage from '@/hooks/use-local-storage'; import useLocalStorage from '@/hooks/use-local-storage';
import usePageMetaList from '@/hooks/use-page-meta-list'; import usePageMetaList from '@/hooks/use-page-meta-list';
import { usePageHelper } from '@/hooks/use-page-helper'; import { usePageHelper } from '@/hooks/use-page-helper';
import { useTranslation } from 'react-i18next';
const FavoriteList = ({ showList }: { showList: boolean }) => { const FavoriteList = ({ showList }: { showList: boolean }) => {
const { openPage } = usePageHelper(); const { openPage } = usePageHelper();
const pageList = usePageMetaList(); const pageList = usePageMetaList();
const router = useRouter(); const router = useRouter();
const { t } = useTranslation();
const favoriteList = pageList.filter(p => p.favorite && !p.trash); const favoriteList = pageList.filter(p => p.favorite && !p.trash);
return ( return (
<Collapse in={showList}> <Collapse in={showList}>
@@ -59,7 +59,7 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
); );
})} })}
{favoriteList.length === 0 && ( {favoriteList.length === 0 && (
<StyledSubListItem disable={true}>No item</StyledSubListItem> <StyledSubListItem disable={true}>{t('No item')}</StyledSubListItem>
)} )}
</Collapse> </Collapse>
); );
@@ -70,7 +70,7 @@ export const WorkSpaceSliderBar = () => {
const { currentWorkspaceId } = useAppState(); const { currentWorkspaceId } = useAppState();
const { openPage, createPage } = usePageHelper(); const { openPage, createPage } = usePageHelper();
const router = useRouter(); const router = useRouter();
const { t } = useTranslation();
const [showTip, setShowTip] = useState(false); const [showTip, setShowTip] = useState(false);
const [show, setShow] = useLocalStorage('AFFiNE_SLIDE_BAR', false, true); const [show, setShow] = useLocalStorage('AFFiNE_SLIDE_BAR', false, true);
@@ -86,7 +86,7 @@ export const WorkSpaceSliderBar = () => {
<> <>
<StyledSliderBar show={show}> <StyledSliderBar show={show}>
<Tooltip <Tooltip
content={show ? 'Collapse sidebar' : 'Expand sidebar'} content={show ? t('Collapse sidebar') : t('Expand sidebar')}
placement="right" placement="right"
visible={showTip} visible={showTip}
> >
@@ -120,17 +120,17 @@ export const WorkSpaceSliderBar = () => {
}} }}
> >
<SearchIcon /> <SearchIcon />
Quick search {t('Quick search')}
</StyledListItem> </StyledListItem>
<Link href={{ pathname: paths.all }}> <Link href={{ pathname: paths.all }}>
<StyledListItem active={router.asPath === paths.all}> <StyledListItem active={router.asPath === paths.all}>
<AllPagesIcon /> <span>All pages</span> <AllPagesIcon /> <span>{t('All pages')}</span>
</StyledListItem> </StyledListItem>
</Link> </Link>
<StyledListItem active={router.asPath === paths.favorite}> <StyledListItem active={router.asPath === paths.favorite}>
<StyledLink href={{ pathname: paths.favorite }}> <StyledLink href={{ pathname: paths.favorite }}>
<FavouritesIcon /> <FavouritesIcon />
Favourites {t('Favourites')}
</StyledLink> </StyledLink>
<IconButton <IconButton
darker={true} darker={true}
@@ -152,12 +152,12 @@ export const WorkSpaceSliderBar = () => {
triggerImportModal(); triggerImportModal();
}} }}
> >
<ImportIcon /> Import <ImportIcon /> {t('Import')}
</StyledListItem> </StyledListItem>
<Link href={{ pathname: paths.trash }}> <Link href={{ pathname: paths.trash }}>
<StyledListItem active={router.asPath === paths.trash}> <StyledListItem active={router.asPath === paths.trash}>
<TrashIcon /> Trash <TrashIcon /> {t('Trash')}
</StyledListItem> </StyledListItem>
</Link> </Link>
<StyledNewPageButton <StyledNewPageButton
@@ -168,7 +168,7 @@ export const WorkSpaceSliderBar = () => {
} }
}} }}
> >
<AddIcon /> New Page <AddIcon /> {t('New Page')}
</StyledNewPageButton> </StyledNewPageButton>
</StyledSliderBarWrapper> </StyledSliderBarWrapper>
</StyledSliderBar> </StyledSliderBar>

View File

@@ -1,28 +1,65 @@
{ {
"Sync to Disk": "Sync to Disk", "Quick search": "Quick search",
"Share": "Share", "All pages": "All pages",
"WarningTips": { "Favourites": "Favourites",
"IsNotfsApiSupported": "Welcome to the AFFiNE demo. To begin saving changes you can SYNC DATA TO DISK with the latest version of Chromium based browser like Chrome/Edge", "No item": "No item",
"IsNotLocalWorkspace": "Welcome to the AFFiNE demo. To begin saving changes you can SYNC TO DISK.", "Import": "Import",
"DoNotStore": "AFFiNE is under active development and the current version is UNSTABLE. Please DO NOT store information or data" "Trash": "Trash",
}, "New Page": "New Page",
"Layout": "Layout", "New Keyword Page": "New '{{query}}' page",
"Comment": "Comment", "Find 0 result": "Find 0 result",
"Settings": "Settings", "Find results": "Find {{number}} results",
"ComingSoon": "Layout Settings Coming Soon...", "Collapse sidebar": "Collapse sidebar",
"Duplicate Page": "Duplicate Page", "Expand sidebar": "Expand sidebar",
"Copy Page Link": "Copy Page Link", "Removed to Favourites": "Removed to Favourites",
"Language": "Language", "Remove to favourites": "Remove to favourites",
"Clear Workspace": "Clear Workspace", "Added to Favourites": "Added to Favourites",
"Export As Markdown": "Export As Markdown", "Add to favourites": "Add to favourites",
"Export As HTML": "Export As HTML", "Paper": "Paper",
"Export As PDF (Unsupported)": "Export As PDF (Unsupported)", "Edgeless": "Edgeless",
"Import Workspace": "Import Workspace", "Switch to": "Switch to",
"Export Workspace": "Export Workspace", "Convert to ": "Convert to ",
"Last edited by": "Last edited by {{name}}", "Page": "Page",
"Logout": "Logout", "Export": "Export",
"Export to HTML": "Export to HTML",
"Export to Markdown": "Export to Markdown",
"Delete": "Delete", "Delete": "Delete",
"Turn into": "Turn into", "Title": "Title",
"Add A Below Block": "Add A Below Block", "Untitled": "Untitled",
"Divide Here As A New Group": "Divide Here As A New Group" "Created": "Created",
"Updated": "Updated",
"Open in new tab": "Open in new tab",
"Favourite": "Favourite",
"Favourited": "Favourited",
"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.",
"Moved to Trash": "Moved to Trash",
"Permanently deleted": "Permanently deleted",
"restored": "{{title}} restored",
"Cancel": "Cancel",
"Keyboard Shortcuts": "Keyboard Shortcuts",
"Contact Us": "Contact Us",
"Official Website": "Official Website",
"Get in touch!": "Get in touch!",
"AFFiNE Community": "AFFiNE Community",
"How is AFFiNE Alpha different?": "How is AFFiNE Alpha different?",
"Shortcuts": "Shortcuts",
"Undo": "Undo",
"Redo": "Redo",
"Bold": "Bold",
"Italic": "Italic",
"Underline": "Underline",
"Strikethrough": "Strikethrough",
"Inline code": "Inline code",
"Code block": "Code block",
"Link": "Link",
"Body text": "Body text",
"Heading": "Heading {{number}}",
"Increase indent": "Increase indent",
"Reduce indent": "Reduce indent",
"Markdown Syntax": "Markdown Syntax",
"Divider": "Divider",
"404 - Page Not Found": "404 - Page Not Found"
} }

View File

@@ -18,6 +18,7 @@ import { useEffect } from 'react';
import { useAppState } from '@/providers/app-state-provider'; import { useAppState } from '@/providers/app-state-provider';
import { PageLoading } from '@/components/loading'; import { PageLoading } from '@/components/loading';
import Head from 'next/head'; import Head from 'next/head';
import '@/libs/i18n';
const ThemeProvider = dynamic(() => import('@/providers/themeProvider'), { const ThemeProvider = dynamic(() => import('@/providers/themeProvider'), {
ssr: false, ssr: false,

View File

@@ -4,13 +4,13 @@ import usePageMetaList from '@/hooks/use-page-meta-list';
import { PageListHeader } from '@/components/header'; import { PageListHeader } from '@/components/header';
import { ReactElement } from 'react'; import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout'; import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from 'react-i18next';
const All = () => { const All = () => {
const pageMetaList = usePageMetaList(); const pageMetaList = usePageMetaList();
const { t } = useTranslation();
return ( return (
<> <>
<PageListHeader icon={<AllPagesIcon />}>All Page</PageListHeader> <PageListHeader icon={<AllPagesIcon />}>{t('All pages')}</PageListHeader>
<PageList <PageList
pageList={pageMetaList.filter(p => !p.trash)} pageList={pageMetaList.filter(p => !p.trash)}
showFavoriteTag={true} showFavoriteTag={true}

View File

@@ -4,12 +4,15 @@ import { FavouritesIcon } from '@blocksuite/icons';
import usePageMetaList from '@/hooks/use-page-meta-list'; import usePageMetaList from '@/hooks/use-page-meta-list';
import { ReactElement } from 'react'; import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout'; import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from 'react-i18next';
export const Favorite = () => { export const Favorite = () => {
const pageMetaList = usePageMetaList(); const pageMetaList = usePageMetaList();
const { t } = useTranslation();
return ( return (
<> <>
<PageListHeader icon={<FavouritesIcon />}>Favourites</PageListHeader> <PageListHeader icon={<FavouritesIcon />}>
{t('Favourites')}
</PageListHeader>
<PageList pageList={pageMetaList.filter(p => p.favorite && !p.trash)} /> <PageList pageList={pageMetaList.filter(p => p.favorite && !p.trash)} />
</> </>
); );

View File

@@ -4,12 +4,13 @@ import { TrashIcon } from '@blocksuite/icons';
import usePageMetaList from '@/hooks/use-page-meta-list'; import usePageMetaList from '@/hooks/use-page-meta-list';
import { ReactElement } from 'react'; import { ReactElement } from 'react';
import WorkspaceLayout from '@/components/workspace-layout'; import WorkspaceLayout from '@/components/workspace-layout';
import { useTranslation } from 'react-i18next';
export const Trash = () => { export const Trash = () => {
const pageMetaList = usePageMetaList(); const pageMetaList = usePageMetaList();
const { t } = useTranslation();
return ( return (
<> <>
<PageListHeader icon={<TrashIcon />}>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} />
</> </>
); );

View File

@@ -7,6 +7,7 @@ import {
StyledModalWrapper, StyledModalWrapper,
} from '@/ui/confirm/styles'; } from '@/ui/confirm/styles';
import { Button } from '@/ui/button'; import { Button } from '@/ui/button';
import { useTranslation } from 'react-i18next';
export type ConfirmProps = { export type ConfirmProps = {
title?: string; title?: string;
content?: string; content?: string;
@@ -26,6 +27,7 @@ export const Confirm = ({
onCancel, onCancel,
}: ConfirmProps) => { }: ConfirmProps) => {
const [open, setOpen] = useState(true); const [open, setOpen] = useState(true);
const { t } = useTranslation();
return ( return (
<Modal open={open}> <Modal open={open}>
<StyledModalWrapper> <StyledModalWrapper>
@@ -48,7 +50,7 @@ export const Confirm = ({
}} }}
style={{ marginRight: '24px' }} style={{ marginRight: '24px' }}
> >
Cancel {t('Cancel')}
</Button> </Button>
<Button <Button
type={confirmType} type={confirmType}