mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 09:21:24 +08:00
chore: add translation (#2001)
This commit is contained in:
@@ -58,7 +58,7 @@ export const HelpIsland = ({
|
|||||||
style={{ height: spread ? `${showList.length * 44}px` : 0 }}
|
style={{ height: spread ? `${showList.length * 44}px` : 0 }}
|
||||||
>
|
>
|
||||||
{showList.includes('whatNew') && (
|
{showList.includes('whatNew') && (
|
||||||
<Tooltip content={t("Discover what's new")} placement="left-end">
|
<Tooltip content={t("Discover what's new!")} placement="left-end">
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
data-testid="right-bottom-change-log-icon"
|
data-testid="right-bottom-change-log-icon"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -153,21 +153,22 @@ export const CurrentWorkspaceContext = ({
|
|||||||
useRouterWithWorkspaceIdDefense(router);
|
useRouterWithWorkspaceIdDefense(router);
|
||||||
const metadata = useAtomValue(rootWorkspacesMetadataAtom);
|
const metadata = useAtomValue(rootWorkspacesMetadataAtom);
|
||||||
const exist = metadata.find(m => m.id === workspaceId);
|
const exist = metadata.find(m => m.id === workspaceId);
|
||||||
|
const { t } = useTranslation();
|
||||||
if (!router.isReady) {
|
if (!router.isReady) {
|
||||||
return <PageLoading text="Router is loading" />;
|
return <PageLoading text={t('Router is Loading')} />;
|
||||||
}
|
}
|
||||||
if (!workspaceId) {
|
if (!workspaceId) {
|
||||||
return <PageLoading text="Finding workspace id" />;
|
return <PageLoading text={t('Finding Workspace ID')} />;
|
||||||
}
|
}
|
||||||
if (!exist) {
|
if (!exist) {
|
||||||
return <PageLoading text="Workspace not found" />;
|
return <PageLoading text={t('Workspace Not Found')} />;
|
||||||
}
|
}
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WorkspaceLayout: FC<PropsWithChildren> =
|
export const WorkspaceLayout: FC<PropsWithChildren> =
|
||||||
function WorkspacesSuspense({ children }) {
|
function WorkspacesSuspense({ children }) {
|
||||||
const { i18n } = useTranslation();
|
const { i18n, t } = useTranslation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.documentElement.lang = i18n.language;
|
document.documentElement.lang = i18n.language;
|
||||||
// todo(himself65): this is a hack, we should use a better way to set the language
|
// todo(himself65): this is a hack, we should use a better way to set the language
|
||||||
@@ -236,7 +237,9 @@ export const WorkspaceLayout: FC<PropsWithChildren> =
|
|||||||
</CurrentWorkspaceContext>
|
</CurrentWorkspaceContext>
|
||||||
</AllWorkspaceContext>
|
</AllWorkspaceContext>
|
||||||
<CurrentWorkspaceContext>
|
<CurrentWorkspaceContext>
|
||||||
<Suspense fallback={<PageLoading text="Finding current workspace" />}>
|
<Suspense
|
||||||
|
fallback={<PageLoading text={t('Finding Current Workspace')} />}
|
||||||
|
>
|
||||||
<WorkspaceLayoutInner>{children}</WorkspaceLayoutInner>
|
<WorkspaceLayoutInner>{children}</WorkspaceLayoutInner>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</CurrentWorkspaceContext>
|
</CurrentWorkspaceContext>
|
||||||
@@ -251,6 +254,7 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { jumpToPage } = useRouterHelper(router);
|
const { jumpToPage } = useRouterHelper(router);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
logger.info('currentWorkspace: ', currentWorkspace);
|
logger.info('currentWorkspace: ', currentWorkspace);
|
||||||
@@ -437,8 +441,12 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
|
|||||||
</StyledSpacer>
|
</StyledSpacer>
|
||||||
<MainContainerWrapper resizing={resizing} style={{ width: mainWidth }}>
|
<MainContainerWrapper resizing={resizing} style={{ width: mainWidth }}>
|
||||||
<MainContainer className="main-container">
|
<MainContainer className="main-container">
|
||||||
<Suspense fallback={<PageLoading text="Page is Loading" />}>
|
<Suspense fallback={<PageLoading text={t('Page is Loading')} />}>
|
||||||
{isLoading ? <PageLoading text="Page is Loading" /> : children}
|
{isLoading ? (
|
||||||
|
<PageLoading text={t('Page is Loading')} />
|
||||||
|
) : (
|
||||||
|
children
|
||||||
|
)}
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<StyledToolWrapper>
|
<StyledToolWrapper>
|
||||||
{/* fixme(himself65): remove this */}
|
{/* fixme(himself65): remove this */}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { DebugLogger } from '@affine/debug';
|
import { DebugLogger } from '@affine/debug';
|
||||||
|
import { useTranslation } from '@affine/i18n';
|
||||||
import type { NextPage } from 'next';
|
import type { NextPage } from 'next';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import React, { Suspense, useEffect } from 'react';
|
import { Suspense, useEffect } from 'react';
|
||||||
|
|
||||||
import { PageLoading } from '../components/pure/loading';
|
import { PageLoading } from '../components/pure/loading';
|
||||||
import { useLastWorkspaceId } from '../hooks/affine/use-last-leave-workspace-id';
|
import { useLastWorkspaceId } from '../hooks/affine/use-last-leave-workspace-id';
|
||||||
@@ -62,8 +63,9 @@ const IndexPageInner = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const IndexPage: NextPage = () => {
|
const IndexPage: NextPage = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<PageLoading text="Loading all workspaces" />}>
|
<Suspense fallback={<PageLoading text={t('Loading All Workspaces')} />}>
|
||||||
<IndexPageInner />
|
<IndexPageInner />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useTranslation } from '@affine/i18n';
|
||||||
import { rootCurrentPageIdAtom } from '@affine/workspace/atom';
|
import { rootCurrentPageIdAtom } from '@affine/workspace/atom';
|
||||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
import { WorkspaceFlavour } from '@affine/workspace/type';
|
||||||
import { assertExists } from '@blocksuite/store';
|
import { assertExists } from '@blocksuite/store';
|
||||||
@@ -40,6 +41,7 @@ const WorkspaceDetail: React.FC = () => {
|
|||||||
const { openPage } = useRouterHelper(router);
|
const { openPage } = useRouterHelper(router);
|
||||||
const currentPageId = useAtomValue(rootCurrentPageIdAtom);
|
const currentPageId = useAtomValue(rootCurrentPageIdAtom);
|
||||||
const [currentWorkspace] = useCurrentWorkspace();
|
const [currentWorkspace] = useCurrentWorkspace();
|
||||||
|
const { t } = useTranslation();
|
||||||
assertExists(currentWorkspace);
|
assertExists(currentWorkspace);
|
||||||
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
||||||
const { setPageMeta, getPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
const { setPageMeta, getPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
||||||
@@ -84,7 +86,7 @@ const WorkspaceDetail: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [currentWorkspace]);
|
}, [currentWorkspace]);
|
||||||
if (!currentPageId) {
|
if (!currentPageId) {
|
||||||
return <PageLoading text="Loading page." />;
|
return <PageLoading text={t('Loading Page')} />;
|
||||||
}
|
}
|
||||||
if (currentWorkspace.flavour === WorkspaceFlavour.AFFINE) {
|
if (currentWorkspace.flavour === WorkspaceFlavour.AFFINE) {
|
||||||
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
|
const PageDetail = WorkspacePlugins[currentWorkspace.flavour].UI.PageDetail;
|
||||||
@@ -110,15 +112,16 @@ const WorkspaceDetailPage: NextPageWithLayout = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const currentWorkspace = useAtomValue(rootCurrentWorkspaceAtom);
|
const currentWorkspace = useAtomValue(rootCurrentWorkspaceAtom);
|
||||||
const currentPageId = useAtomValue(rootCurrentPageIdAtom);
|
const currentPageId = useAtomValue(rootCurrentPageIdAtom);
|
||||||
|
const { t } = useTranslation();
|
||||||
useRouterAndWorkspaceWithPageIdDefense(router);
|
useRouterAndWorkspaceWithPageIdDefense(router);
|
||||||
const page = useBlockSuiteWorkspacePage(
|
const page = useBlockSuiteWorkspacePage(
|
||||||
currentWorkspace.blockSuiteWorkspace,
|
currentWorkspace.blockSuiteWorkspace,
|
||||||
currentPageId
|
currentPageId
|
||||||
);
|
);
|
||||||
if (!router.isReady) {
|
if (!router.isReady) {
|
||||||
return <PageLoading text="Router is loading" />;
|
return <PageLoading text={t('Router is Loading')} />;
|
||||||
} else if (!currentPageId || !page) {
|
} else if (!currentPageId || !page) {
|
||||||
return <PageLoading text="Page is loading" />;
|
return <PageLoading text={t('Page is Loading')} />;
|
||||||
}
|
}
|
||||||
return <WorkspaceDetail />;
|
return <WorkspaceDetail />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -219,5 +219,12 @@
|
|||||||
"Shared Pages In Public Workspace Description": "The entire Workspace is published on the web and can be edited via <1>Workspace Settings</1>.",
|
"Shared Pages In Public Workspace Description": "The entire Workspace is published on the web and can be edited via <1>Workspace Settings</1>.",
|
||||||
"Open Workspace Settings": "Open Workspace Settings",
|
"Open Workspace Settings": "Open Workspace Settings",
|
||||||
"Share Menu Public Workspace Description1": "Invite others to join the Workspace or publish it to web.",
|
"Share Menu Public Workspace Description1": "Invite others to join the Workspace or publish it to web.",
|
||||||
"Share Menu Public Workspace Description2": "Current workspace has been published to the web as a public workspace."
|
"Share Menu Public Workspace Description2": "Current workspace has been published to the web as a public workspace.",
|
||||||
|
"Router is Loading": "Router is Loading",
|
||||||
|
"Finding Workspace ID": "Finding Workspace ID",
|
||||||
|
"Workspace Not Found": "Workspace Not Found",
|
||||||
|
"Finding Current Workspace": "Finding Current Workspace",
|
||||||
|
"Page is Loading": "Page is Loading",
|
||||||
|
"Loading All Workspaces": "Loading All Workspaces",
|
||||||
|
"Loading Page": "Loading Page"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user