diff --git a/libs/components/layout/package.json b/libs/components/layout/package.json index d7a0a26481..a36a746d84 100644 --- a/libs/components/layout/package.json +++ b/libs/components/layout/package.json @@ -11,9 +11,7 @@ "@mui/icons-material": "^5.8.4", "clsx": "^1.2.1", "date-fns": "^2.29.2", - "i18next": "^21.9.1", "jotai": "^1.8.1", - "react-i18next": "^11.18.4", "tinycolor2": "^1.4.2", "turndown": "7.1.1" }, diff --git a/libs/components/layout/src/header/FileSystem.tsx b/libs/components/layout/src/header/FileSystem.tsx index 30c2b68816..5e8440b4ce 100644 --- a/libs/components/layout/src/header/FileSystem.tsx +++ b/libs/components/layout/src/header/FileSystem.tsx @@ -3,8 +3,9 @@ import { useCallback, useMemo, useState } from 'react'; import { CloseIcon } from '@toeverything/components/common'; import { IconButton, MuiSnackbar, styled } from '@toeverything/components/ui'; import { services } from '@toeverything/datasource/db-service'; +import { useTranslation } from '@toeverything/datasource/i18n'; import { useLocalTrigger } from '@toeverything/datasource/state'; -import { useTranslation } from 'react-i18next'; + const cleanupWorkspace = (workspace: string) => new Promise((resolve, reject) => { const req = indexedDB.deleteDatabase(workspace); diff --git a/libs/components/layout/src/header/LayoutHeader.tsx b/libs/components/layout/src/header/LayoutHeader.tsx index 9b104b4442..e6ab719a5a 100644 --- a/libs/components/layout/src/header/LayoutHeader.tsx +++ b/libs/components/layout/src/header/LayoutHeader.tsx @@ -5,13 +5,13 @@ import { SideBarViewIcon, } from '@toeverything/components/icons'; import { IconButton, styled } from '@toeverything/components/ui'; +import { useTranslation } from '@toeverything/datasource/i18n'; import { useCurrentEditors, useLocalTrigger, useShowSettingsSidebar, } from '@toeverything/datasource/state'; import { useCallback, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; import { EditorBoardSwitcher } from './EditorBoardSwitcher'; import { fsApiSupported } from './FileSystem'; import { CurrentPageTitle } from './Title'; diff --git a/libs/components/layout/src/i18n/index.ts b/libs/components/layout/src/i18n/index.ts deleted file mode 100644 index 20f4e2a3ce..0000000000 --- a/libs/components/layout/src/i18n/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import i18next from 'i18next'; -import { initReactI18next } from 'react-i18next'; -import en_US from './resources/en.json'; -import zh_CN from './resources/zh.json'; - -// See https://react.i18next.com/latest/typescript -declare module 'react-i18next' { - // and extend them! - interface CustomTypeOptions { - // custom namespace type if you changed it - defaultNS: 'ns1'; - // custom resources type - resources: { - en: typeof en_US.translation; - zh: typeof zh_CN.translation; - }; - } -} - -const resources = { - en: en_US, - zh: zh_CN, -} as const; - -i18next.use(initReactI18next).init({ - lng: 'en', - fallbackLng: 'en', - - resources, - interpolation: { - escapeValue: false, // not needed for react as it escapes by default - }, -}); - -export const options = [ - { value: 'en', text: 'English' }, - { value: 'zh', text: '简体中文' }, -] as const; - -export { i18next }; diff --git a/libs/components/layout/src/i18n/resources/en.json b/libs/components/layout/src/i18n/resources/en.json deleted file mode 100644 index 4c6a714e9b..0000000000 --- a/libs/components/layout/src/i18n/resources/en.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "translation": { - "Sync to Disk": "Sync to Disk", - "Share": "Share", - "WarningTips": { - "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", - "IsNotLocalWorkspace": "Welcome to the AFFiNE demo. To begin saving changes you can SYNC TO DISK.", - "DoNotStore": "AFFiNE is under active development and the current version is UNSTABLE. Please DO NOT store information or data" - }, - "Layout": "Layout", - "Comment": "Comment", - "Settings": "Settings", - "ComingSoon": "Layout Settings Coming Soon...", - "Duplicate Page": "Duplicate Page", - "Copy Page Link": "Copy Page Link", - "Language": "Language", - "Clear Workspace": "Clear Workspace", - "Export As Markdown": "Export As Markdown", - "Export As HTML": "Export As HTML", - "Export As PDF (Unsupported)": "Export As PDF (Unsupported)", - "Import Workspace": "Import Workspace", - "Export Workspace": "Export Workspace", - "Last edited by": "Last edited by {{name}}", - "Logout": "Logout" - } -} diff --git a/libs/components/layout/src/i18n/resources/zh.json b/libs/components/layout/src/i18n/resources/zh.json deleted file mode 100644 index da86cef6b2..0000000000 --- a/libs/components/layout/src/i18n/resources/zh.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "translation": { - "Sync to Disk": "同步到磁盘", - "Share": "分享", - "WarningTips": { - "IsNotfsApiSupported": "欢迎来到AFFiNE 的演示界面。您可以使用最新版本的基于Chrome的浏览器(如Chrome/Edge)将数据同步到磁盘来进行保存", - "IsNotLocalWorkspace": "欢迎来到AFFiNE 的演示界面,您可以同步到磁盘来进行保存操作。", - "DoNotStore": "AFFINE 正在积极开发中,当前版本不稳定。请不要存储信息或数据。" - }, - "ComingSoon": "布局设置即将到来", - "Layout": "布局", - "Comment": "评论", - "Settings": "设置", - "Duplicate Page": "复制页面", - "Copy Page Link": "复制页面链接", - "Language": "当前语言", - "Clear Workspace": "清空工作区域", - "Export As Markdown": "导出 markdown", - "Export As HTML": "导出 HTML", - "Export As PDF (Unsupported)": "导出 PDF (暂不支持)", - "Import Workspace": "导入 Workspace", - "Export Workspace": "导出 Workspace", - "Last edited by": "最后编辑者为 {{name}}", - "Logout": "退出登录" - } -} diff --git a/libs/components/layout/src/index.ts b/libs/components/layout/src/index.ts index 1aee5a687f..69a6d3ff72 100644 --- a/libs/components/layout/src/index.ts +++ b/libs/components/layout/src/index.ts @@ -1,4 +1,3 @@ export * from './header'; -export * from './i18n'; export * from './settings-sidebar'; export * from './workspace-sidebar'; diff --git a/libs/components/layout/src/settings-sidebar/ContainerTabs/ContainerTabs.tsx b/libs/components/layout/src/settings-sidebar/ContainerTabs/ContainerTabs.tsx index 4503482d05..3aab18642c 100644 --- a/libs/components/layout/src/settings-sidebar/ContainerTabs/ContainerTabs.tsx +++ b/libs/components/layout/src/settings-sidebar/ContainerTabs/ContainerTabs.tsx @@ -4,8 +4,8 @@ import { SettingsIcon, } from '@toeverything/components/icons'; import { styled } from '@toeverything/components/ui'; +import { useTranslation } from '@toeverything/datasource/i18n'; import { cloneElement, useCallback, useMemo, type ReactElement } from 'react'; -import { useTranslation } from 'react-i18next'; import { Comments } from '../Comments'; import { useActiveComment } from '../Comments/use-comments'; import { LayoutSettings } from '../Layout'; diff --git a/libs/components/layout/src/settings-sidebar/Settings/SettingsList.tsx b/libs/components/layout/src/settings-sidebar/Settings/SettingsList.tsx index f462ccf572..a308614d13 100644 --- a/libs/components/layout/src/settings-sidebar/Settings/SettingsList.tsx +++ b/libs/components/layout/src/settings-sidebar/Settings/SettingsList.tsx @@ -6,8 +6,7 @@ import { styled, Switch, } from '@toeverything/components/ui'; -import { useTranslation } from 'react-i18next'; -import { options } from '../../i18n'; +import { LOCALES, useTranslation } from '@toeverything/datasource/i18n'; import { useSettings } from './use-settings'; export const SettingsList = () => { @@ -52,7 +51,7 @@ export const SettingsList = () => { defaultValue={i18n.language} onChange={changeLanguage} > - {options.map(option => ( + {LOCALES.map(option => (