chore: add translation (#1946)

This commit is contained in:
JimmFly
2023-04-14 15:02:43 +08:00
committed by GitHub
parent 70313eb5ee
commit 5335118e93
3 changed files with 39 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
import { getEnvironment } from '@affine/env';
import { Trans, useTranslation } from '@affine/i18n';
import type { LocalWorkspace } from '@affine/workspace/type';
import { WorkspaceFlavour } from '@affine/workspace/type';
import { useBlockSuiteWorkspacePageIsPublic } from '@toeverything/hooks/use-blocksuite-workspace-page-is-public';
@@ -6,6 +7,7 @@ import type { FC } from 'react';
import { useState } from 'react';
import { useCallback, useMemo } from 'react';
import { toast } from '../..';
import { PublicLinkDisableModal } from './disable-public-link';
import {
descriptionStyle,
@@ -21,18 +23,17 @@ import {
} from './styles';
export const LocalSharePage: FC<ShareMenuProps> = props => {
const { t } = useTranslation();
return (
<div className={menuItemStyle}>
<div className={descriptionStyle}>
Sharing page publicly requires AFFiNE Cloud service.
</div>
<div className={descriptionStyle}>{t('Shared Pages Description')}</div>
<StyledButton
data-testid="share-menu-enable-affine-cloud-button"
onClick={() => {
props.onEnableAffineCloud(props.workspace as LocalWorkspace);
}}
>
Enable AFFiNE Cloud
{t('Enable AFFiNE Cloud')}
</StyledButton>
</div>
);
@@ -43,6 +44,7 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
props.currentPage
);
const [showDisable, setShowDisable] = useState(false);
const { t } = useTranslation();
const sharingUrl = useMemo(() => {
const env = getEnvironment();
if (env.isBrowser) {
@@ -56,12 +58,13 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
}, [setIsPublic]);
const onClickCopyLink = useCallback(() => {
navigator.clipboard.writeText(sharingUrl);
}, [sharingUrl]);
toast(t('Copied link to clipboard'));
}, [sharingUrl, t]);
return (
<div className={menuItemStyle}>
<div className={descriptionStyle}>
Create a link you can easily share with anyone.
{t('Create Shared Link Description')}
</div>
<div className={inputButtonRowStyle}>
<StyledInput
@@ -74,7 +77,7 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
data-testid="affine-share-create-link"
onClick={onClickCreateLink}
>
Create
{t('Create')}
</StyledButton>
)}
{isPublic && (
@@ -82,24 +85,27 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
data-testid="affine-share-copy-link"
onClick={onClickCopyLink}
>
Copy Link
{t('Copy Link')}
</StyledButton>
)}
</div>
<div className={descriptionStyle}>
The entire Workspace is published on the web and can be edited via
<StyledLinkSpan
onClick={() => {
props.onOpenWorkspaceSettings(props.workspace);
}}
>
Workspace Settings.
</StyledLinkSpan>
<Trans i18nKey="Shared Pages In Public Workspace Description">
The entire Workspace is published on the web and can be edited via
<StyledLinkSpan
onClick={() => {
props.onOpenWorkspaceSettings(props.workspace);
}}
>
Workspace Settings
</StyledLinkSpan>
.
</Trans>
</div>
{isPublic && (
<>
<StyledDisableButton onClick={() => setShowDisable(true)}>
Disable Public Link
{t('Disable Public Link')}
</StyledDisableButton>
<PublicLinkDisableModal
page={props.currentPage}

View File

@@ -1,3 +1,4 @@
import { useTranslation } from '@affine/i18n';
import type { AffineWorkspace, LocalWorkspace } from '@affine/workspace/type';
import { WorkspaceFlavour } from '@affine/workspace/type';
import type { FC } from 'react';
@@ -7,10 +8,11 @@ import type { ShareMenuProps } from './ShareMenu';
import { StyledButton } from './styles';
const ShareLocalWorkspace: FC<ShareMenuProps<LocalWorkspace>> = props => {
const { t } = useTranslation();
return (
<div className={menuItemStyle}>
<div className={descriptionStyle}>
Invite others to join the Workspace or publish it to web.
{t('Share Menu Public Workspace Description1')}
</div>
<StyledButton
data-testid="share-menu-enable-affine-cloud-button"
@@ -18,7 +20,7 @@ const ShareLocalWorkspace: FC<ShareMenuProps<LocalWorkspace>> = props => {
props.onOpenWorkspaceSettings(props.workspace);
}}
>
Open Workspace Settings
{t('Open Workspace Settings')}
</StyledButton>
</div>
);
@@ -26,12 +28,13 @@ const ShareLocalWorkspace: FC<ShareMenuProps<LocalWorkspace>> = props => {
const ShareAffineWorkspace: FC<ShareMenuProps<AffineWorkspace>> = props => {
const isPublicWorkspace = props.workspace.public;
const { t } = useTranslation();
return (
<div className={menuItemStyle}>
<div className={descriptionStyle}>
{isPublicWorkspace
? `Current workspace has been published to the web as a public workspace.`
: `Invite others to join the Workspace or publish it to web`}
? t('Share Menu Public Workspace Description2')
: t('Share Menu Public Workspace Description1')}
</div>
<StyledButton
data-testid="share-menu-publish-to-web-button"
@@ -39,7 +42,7 @@ const ShareAffineWorkspace: FC<ShareMenuProps<AffineWorkspace>> = props => {
props.onOpenWorkspaceSettings(props.workspace);
}}
>
Open Workspace Settings
{t('Open Workspace Settings')}
</StyledButton>
</div>
);

View File

@@ -208,7 +208,14 @@
"Shared Pages": "Shared Pages",
"Disable Public Sharing": "Disable Public Sharing",
"Disable": "Disable",
"Disable Public Link": "Disable Public Link",
"Disable Public Link ?": "Disable Public Link ?",
"Disable Public Link Description": "Disabling this public link will prevent anyone with the link from accessing this page.",
"Export Shared Pages Description": "Download a static copy of your page to share with others."
"Export Shared Pages Description": "Download a static copy of your page to share with others.",
"Shared Pages Description": "Sharing page publicly requires AFFiNE Cloud service.",
"Create Shared Link Description": "Create a link you can easily share with anyone.",
"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",
"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."
}