diff --git a/web/app/(commonLayout)/datasets/Doc.tsx b/web/app/(commonLayout)/datasets/Doc.tsx index f12c97b248..b1b7b00cf7 100644 --- a/web/app/(commonLayout)/datasets/Doc.tsx +++ b/web/app/(commonLayout)/datasets/Doc.tsx @@ -5,6 +5,7 @@ import { useContext } from 'use-context-selector' import TemplateEn from './template/template.en.mdx' import TemplateZh from './template/template.zh.mdx' import I18n from '@/context/i18n' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' type DocProps = { apiBaseUrl: string @@ -13,11 +14,11 @@ const Doc: FC = ({ apiBaseUrl, }) => { const { locale } = useContext(I18n) - + const language = getModelRuntimeSupported(locale) return (
{ - locale === 'en' + language !== LanguagesSupportedUnderscore[1] ? : } diff --git a/web/app/activate/activateForm.tsx b/web/app/activate/activateForm.tsx index 2c8b3e8c67..40595b71fd 100644 --- a/web/app/activate/activateForm.tsx +++ b/web/app/activate/activateForm.tsx @@ -12,12 +12,11 @@ import Button from '@/app/components/base/button' import { SimpleSelect } from '@/app/components/base/select' import { timezones } from '@/utils/timezone' -import { LanguagesSupported, languages } from '@/utils/language' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported, languages } from '@/utils/language' import { activateMember, invitationCheck } from '@/service/common' import Toast from '@/app/components/base/toast' import Loading from '@/app/components/base/loading' import I18n from '@/context/i18n' - const validPassword = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/ const ActivateForm = () => { @@ -43,9 +42,9 @@ const ActivateForm = () => { const [name, setName] = useState('') const [password, setPassword] = useState('') const [timezone, setTimezone] = useState('Asia/Shanghai') - const [language, setLanguage] = useState('en-US') + const [language, setLanguage] = useState(getModelRuntimeSupported(locale)) const [showSuccess, setShowSuccess] = useState(false) - const defaultLanguage = useCallback(() => (window.navigator.language.startsWith('zh') ? LanguagesSupported[1] : LanguagesSupported[0]) || LanguagesSupported[0], []) + const defaultLanguage = useCallback(() => (window.navigator.language.startsWith('zh') ? LanguagesSupportedUnderscore[1] : LanguagesSupportedUnderscore[0]) || LanguagesSupportedUnderscore[0], []) const showErrorMessage = useCallback((message: string) => { Toast.notify({ @@ -208,7 +207,7 @@ const ActivateForm = () => { {t('login.license.link')} diff --git a/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx b/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx index e66b1a566e..37512abf6c 100644 --- a/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx +++ b/web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx @@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general' import I18n from '@/context/i18n' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' const CSV_TEMPLATE_QA_EN = [ ['question', 'answer'], @@ -22,14 +23,13 @@ const CSV_TEMPLATE_QA_CN = [ const CSVDownload: FC = () => { const { t } = useTranslation() + const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { CSVDownloader, Type } = useCSVDownloader() const getTemplate = () => { - if (locale === 'en') - return CSV_TEMPLATE_QA_EN - - return CSV_TEMPLATE_QA_CN + return language !== LanguagesSupportedUnderscore[1] ? CSV_TEMPLATE_QA_EN : CSV_TEMPLATE_QA_CN } return ( @@ -58,7 +58,7 @@ const CSVDownload: FC = () => { diff --git a/web/app/components/app/annotation/header-opts/index.tsx b/web/app/components/app/annotation/header-opts/index.tsx index 738aa0bb9c..58bc31d12e 100644 --- a/web/app/components/app/annotation/header-opts/index.tsx +++ b/web/app/components/app/annotation/header-opts/index.tsx @@ -14,10 +14,10 @@ import type { AnnotationItemBasic } from '../type' import BatchAddModal from '../batch-add-annotation-modal' import s from './style.module.css' import CustomPopover from '@/app/components/base/popover' -// import Divider from '@/app/components/base/divider' import { FileDownload02, FilePlus02 } from '@/app/components/base/icons/src/vender/line/files' import I18n from '@/context/i18n' import { fetchExportAnnotationList } from '@/service/annotation' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' const CSV_HEADER_QA_EN = ['Question', 'Answer'] const CSV_HEADER_QA_CN = ['问题', '答案'] @@ -38,6 +38,7 @@ const HeaderOptions: FC = ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { CSVDownloader, Type } = useCSVDownloader() const [list, setList] = useState([]) const fetchList = async () => { @@ -67,10 +68,10 @@ const HeaderOptions: FC = ({ [item.question, item.answer]), ]} > diff --git a/web/app/components/app/configuration/config/agent/agent-tools/choose-tool/index.tsx b/web/app/components/app/configuration/config/agent/agent-tools/choose-tool/index.tsx index 443c08057b..b5dec18a5b 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/choose-tool/index.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/choose-tool/index.tsx @@ -10,6 +10,7 @@ import Drawer from '@/app/components/base/drawer-plus' import ConfigContext from '@/context/debug-configuration' import type { ModelConfig } from '@/models/debug' import I18n from '@/context/i18n' +import { getModelRuntimeSupported } from '@/utils/language' type Props = { show: boolean onHide: () => void @@ -23,7 +24,7 @@ const ChooseTool: FC = ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) - + const language = getModelRuntimeSupported(locale) const { modelConfig, setModelConfig, @@ -59,7 +60,7 @@ const ChooseTool: FC = ({ provider_type: collection.type, provider_name: collection.name, tool_name: tool.name, - tool_label: tool.label[locale === 'en' ? 'en_US' : 'zh_Hans'], + tool_label: tool.label[language], tool_parameters: parameters, enabled: true, }) diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx index bb1d60b891..b468442847 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx @@ -13,7 +13,7 @@ import I18n from '@/context/i18n' import Button from '@/app/components/base/button' import Loading from '@/app/components/base/loading' import { DiagonalDividingLine } from '@/app/components/base/icons/src/public/common' - +import { getModelRuntimeSupported } from '@/utils/language' type Props = { collection: Collection toolName: string @@ -32,6 +32,7 @@ const SettingBuiltInTool: FC = ({ onSave, }) => { const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { t } = useTranslation() const [isLoading, setIsLoading] = useState(true) @@ -83,7 +84,7 @@ const SettingBuiltInTool: FC = ({ {t('tools.setBuiltInTools.toolDescription')}
- {currTool?.description[locale === 'en' ? 'en_US' : 'zh_Hans']} + {currTool?.description[language]}
{infoSchemas.length > 0 && ( @@ -96,7 +97,7 @@ const SettingBuiltInTool: FC = ({ {infoSchemas.map((item: any, index) => (
-
{item.label[locale === 'en' ? 'en_US' : 'zh_Hans']}
+
{item.label[language]}
{item.type === 'number-input' ? t('tools.setBuiltInTools.number') : t('tools.setBuiltInTools.string')}
{item.required && (
{t('tools.setBuiltInTools.required')}
@@ -104,7 +105,7 @@ const SettingBuiltInTool: FC = ({
{item.human_description && (
- {item.human_description?.[locale === 'en' ? 'en_US' : 'zh_Hans']} + {item.human_description?.[language]}
)}
@@ -140,7 +141,7 @@ const SettingBuiltInTool: FC = ({ backgroundImage: `url(${collection.icon})`, }} > -
{currTool?.label[locale === 'en' ? 'en_US' : 'zh_Hans']}
+
{currTool?.label[language]}
{(hasSetting && !readonly) && (<>
diff --git a/web/app/components/app/configuration/toolbox/moderation/index.tsx b/web/app/components/app/configuration/toolbox/moderation/index.tsx index c049c2b42f..7731d9ebd2 100644 --- a/web/app/components/app/configuration/toolbox/moderation/index.tsx +++ b/web/app/components/app/configuration/toolbox/moderation/index.tsx @@ -7,11 +7,12 @@ import { useModalContext } from '@/context/modal-context' import ConfigContext from '@/context/debug-configuration' import { fetchCodeBasedExtensionList } from '@/service/common' import I18n from '@/context/i18n' - +import { getModelRuntimeSupported } from '@/utils/language' const Moderation = () => { const { t } = useTranslation() const { setShowModerationSettingModal } = useModalContext() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { moderationConfig, setModerationConfig, @@ -38,7 +39,7 @@ const Moderation = () => { else if (moderationConfig.type === 'api') prefix = t('common.apiBasedExtension.selector.title') else - prefix = codeBasedExtensionList?.data.find(item => item.name === moderationConfig.type)?.label[locale === 'en' ? 'en-US' : 'zh-Hans'] || '' + prefix = codeBasedExtensionList?.data.find(item => item.name === moderationConfig.type)?.label[language] || '' if (moderationConfig.config?.inputs_config?.enabled && moderationConfig.config?.outputs_config?.enabled) suffix = t('appDebug.feature.moderation.allEnabled') diff --git a/web/app/components/app/configuration/toolbox/moderation/moderation-setting-modal.tsx b/web/app/components/app/configuration/toolbox/moderation/moderation-setting-modal.tsx index 2522bd492f..38199379ed 100644 --- a/web/app/components/app/configuration/toolbox/moderation/moderation-setting-modal.tsx +++ b/web/app/components/app/configuration/toolbox/moderation/moderation-setting-modal.tsx @@ -17,6 +17,7 @@ import { } from '@/service/common' import type { CodeBasedExtensionItem } from '@/models/common' import I18n from '@/context/i18n' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' import { InfoCircle } from '@/app/components/base/icons/src/vender/line/general' import { useModalContext } from '@/context/modal-context' import { CustomConfigurationStatusEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' @@ -43,6 +44,7 @@ const ModerationSettingModal: FC = ({ const { t } = useTranslation() const { notify } = useToastContext() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { data: modelProviders, isLoading, mutate } = useSWR('/workspaces/current/model-providers', fetchModelProviders) const [localeData, setLocaleData] = useState(data) const { setShowAccountSettingModal } = useModalContext() @@ -198,12 +200,12 @@ const ModerationSettingModal: FC = ({ } if (localeData.type === 'keywords' && !localeData.config.keywords) { - notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: locale === 'en' ? 'keywords' : '关键词' }) }) + notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: language !== LanguagesSupportedUnderscore[1] ? 'keywords' : '关键词' }) }) return } if (localeData.type === 'api' && !localeData.config.api_based_extension_id) { - notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: locale === 'en' ? 'API Extension' : 'API 扩展' }) }) + notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: language !== LanguagesSupportedUnderscore[1] ? 'API Extension' : 'API 扩展' }) }) return } @@ -212,7 +214,7 @@ const ModerationSettingModal: FC = ({ if (!localeData.config?.[currentProvider.form_schema[i].variable] && currentProvider.form_schema[i].required) { notify({ type: 'error', - message: t('appDebug.errorMessage.valueOfVarRequired', { key: locale === 'en' ? currentProvider.form_schema[i].label['en-US'] : currentProvider.form_schema[i].label['zh-Hans'] }), + message: t('appDebug.errorMessage.valueOfVarRequired', { key: language !== LanguagesSupportedUnderscore[1] ? currentProvider.form_schema[i].label['en-US'] : currentProvider.form_schema[i].label['zh-Hans'] }), }) return } diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx index d9f3ca8634..1797b10a4f 100644 --- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx +++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx @@ -12,6 +12,7 @@ import { BookOpen01 } from '@/app/components/base/icons/src/vender/line/educatio import { fetchCodeBasedExtensionList } from '@/service/common' import { SimpleSelect } from '@/app/components/base/select' import I18n from '@/context/i18n' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' import type { CodeBasedExtensionItem, ExternalDataTool, @@ -40,6 +41,7 @@ const ExternalDataToolModal: FC = ({ const { t } = useTranslation() const { notify } = useToastContext() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const [localeData, setLocaleData] = useState(data.type ? data : { ...data, type: 'api' }) const [showEmojiPicker, setShowEmojiPicker] = useState(false) const { data: codeBasedExtensionList } = useSWR( @@ -155,7 +157,7 @@ const ExternalDataToolModal: FC = ({ } if (localeData.type === 'api' && !localeData.config?.api_based_extension_id) { - notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: locale === 'en' ? 'API Extension' : 'API 扩展' }) }) + notify({ type: 'error', message: t('appDebug.errorMessage.valueOfVarRequired', { key: language !== LanguagesSupportedUnderscore[1] ? 'API Extension' : 'API 扩展' }) }) return } @@ -164,7 +166,7 @@ const ExternalDataToolModal: FC = ({ if (!localeData.config?.[currentProvider.form_schema[i].variable] && currentProvider.form_schema[i].required) { notify({ type: 'error', - message: t('appDebug.errorMessage.valueOfVarRequired', { key: locale === 'en' ? currentProvider.form_schema[i].label['en-US'] : currentProvider.form_schema[i].label['zh-Hans'] }), + message: t('appDebug.errorMessage.valueOfVarRequired', { key: language !== LanguagesSupportedUnderscore[1] ? currentProvider.form_schema[i].label['en-US'] : currentProvider.form_schema[i].label['zh-Hans'] }), }) return } diff --git a/web/app/components/app/overview/customize/index.tsx b/web/app/components/app/overview/customize/index.tsx index 9feb3a35d7..1f52561918 100644 --- a/web/app/components/app/overview/customize/index.tsx +++ b/web/app/components/app/overview/customize/index.tsx @@ -9,6 +9,7 @@ import I18n from '@/context/i18n' import Button from '@/app/components/base/button' import Modal from '@/app/components/base/modal' import Tag from '@/app/components/base/tag' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' type IShareLinkProps = { isShow: boolean @@ -43,6 +44,7 @@ const CustomizeModal: FC = ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const isChatApp = mode === 'chat' return = ({

{t(`${prefixCustomize}.way2.name`)}

diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsx index d62af1ec48..67ca7c4ecf 100644 --- a/web/app/components/header/account-dropdown/index.tsx +++ b/web/app/components/header/account-dropdown/index.tsx @@ -16,7 +16,7 @@ import { useAppContext } from '@/context/app-context' import { ArrowUpRight, ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows' import { LogOut01 } from '@/app/components/base/icons/src/vender/line/general' import { useModalContext } from '@/context/modal-context' - +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' export type IAppSelecotr = { isMobile: boolean } @@ -30,6 +30,7 @@ export default function AppSelector({ isMobile }: IAppSelecotr) { const [aboutVisible, setAboutVisible] = useState(false) const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { t } = useTranslation() const { userProfile, langeniusVersionInfo } = useAppContext() const { setShowAccountSettingModal } = useModalContext() @@ -122,7 +123,7 @@ export default function AppSelector({ isMobile }: IAppSelecotr) {
{t('common.userProfile.helpCenter')}
diff --git a/web/app/components/header/account-setting/members-page/index.tsx b/web/app/components/header/account-setting/members-page/index.tsx index a61408cbdc..0bd9c6cf4a 100644 --- a/web/app/components/header/account-setting/members-page/index.tsx +++ b/web/app/components/header/account-setting/members-page/index.tsx @@ -20,7 +20,7 @@ import { useProviderContext } from '@/context/provider-context' import { Plan } from '@/app/components/billing/type' import UpgradeBtn from '@/app/components/billing/upgrade-btn' import { NUM_INFINITE } from '@/app/components/billing/config' - +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' dayjs.extend(relativeTime) const MembersPage = () => { @@ -31,6 +31,7 @@ const MembersPage = () => { normal: t('common.members.normal'), } const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { userProfile, currentWorkspace, isCurrentWorkspaceManager } = useAppContext() const { data, mutate } = useSWR({ url: '/workspaces/current/members' }, fetchMembers) const [inviteModalVisible, setInviteModalVisible] = useState(false) @@ -54,7 +55,7 @@ const MembersPage = () => { {isNotUnlimitedMemberPlan ? (
-
{t('billing.plansCommon.member')}{locale === 'en' && accounts.length > 1 && 's'}
+
{t('billing.plansCommon.member')}{language !== LanguagesSupportedUnderscore[1] && accounts.length > 1 && 's'}
{accounts.length}
/
{plan.total.teamMembers === NUM_INFINITE ? t('billing.plansCommon.unlimited') : plan.total.teamMembers}
@@ -63,7 +64,7 @@ const MembersPage = () => { : (
{accounts.length}
-
{t('billing.plansCommon.memberAfter')}{locale === 'en' && accounts.length > 1 && 's'}
+
{t('billing.plansCommon.memberAfter')}{language !== LanguagesSupportedUnderscore[1] && accounts.length > 1 && 's'}
)}
diff --git a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx index d4b54c1b9e..a2e3c454d4 100644 --- a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx +++ b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx @@ -10,6 +10,7 @@ import Button from '@/app/components/base/button' import Drawer from '@/app/components/base/drawer-plus' import I18n from '@/context/i18n' import { testAPIAvailable } from '@/service/tools' +import { getModelRuntimeSupported } from '@/utils/language' type Props = { customCollection: CustomCollectionBackend @@ -26,6 +27,7 @@ const TestApi: FC = ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const [credentialsModalShow, setCredentialsModalShow] = useState(false) const [tempCredential, setTempCredential] = React.useState(customCollection.credentials) const [result, setResult] = useState('') @@ -78,7 +80,7 @@ const TestApi: FC = ({ {parameters.map((item, index) => ( - {item.label[locale === 'en' ? 'en_US' : 'zh_Hans']} + {item.label[language]} = ({ onShowEditCustomCollection, }) => { const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const { t } = useTranslation() const isInToolsPage = loc === LOC.tools const isInDebugPage = !isInToolsPage @@ -38,13 +40,13 @@ const Header: FC = ({ {icon}
-
{collection.label[locale === 'en' ? 'en_US' : 'zh_Hans']}
+
{collection.label[language]}
·
{t('tools.author')} {collection.author}
{collection.description && (
- {collection.description[locale === 'en' ? 'en_US' : 'zh_Hans']} + {collection.description[language]}
)}
diff --git a/web/app/components/tools/tool-list/item.tsx b/web/app/components/tools/tool-list/item.tsx index c802bc899f..f4437f065a 100644 --- a/web/app/components/tools/tool-list/item.tsx +++ b/web/app/components/tools/tool-list/item.tsx @@ -10,6 +10,7 @@ import { CollectionType } from '../types' import TooltipPlus from '../../base/tooltip-plus' import I18n from '@/context/i18n' import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool' +import { getModelRuntimeSupported } from '@/utils/language' type Props = { collection: Collection @@ -32,6 +33,7 @@ const Item: FC = ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const isBuiltIn = collection.type === CollectionType.builtIn const canShowDetail = !isBuiltIn || (isBuiltIn && isInToolsPage) const [showDetail, setShowDetail] = useState(false) @@ -45,9 +47,9 @@ const Item: FC = ({
{icon}
-
{payload.label[locale === 'en' ? 'en_US' : 'zh_Hans']}
+
{payload.label[language]}
- {payload.description[locale === 'en' ? 'en_US' : 'zh_Hans']} + {payload.description[language]}
diff --git a/web/app/components/tools/tool-nav-list/item.tsx b/web/app/components/tools/tool-nav-list/item.tsx index b426d29df3..5e32503d18 100644 --- a/web/app/components/tools/tool-nav-list/item.tsx +++ b/web/app/components/tools/tool-nav-list/item.tsx @@ -6,6 +6,7 @@ import cn from 'classnames' import AppIcon from '../../base/app-icon' import type { Collection } from '@/app/components/tools/types' import I18n from '@/context/i18n' +import { getModelRuntimeSupported } from '@/utils/language' type Props = { isCurrent: boolean @@ -19,7 +20,7 @@ const Item: FC = ({ onClick, }) => { const { locale } = useContext(I18n) - + const language = getModelRuntimeSupported(locale) return (
= ({ background={payload.icon.background} /> )} -
{payload.label[locale === 'en' ? 'en_US' : 'zh_Hans']}
+
{payload.label[language]}
) diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts index 1fdb3172c4..e06e011767 100644 --- a/web/app/components/tools/types.ts +++ b/web/app/components/tools/types.ts @@ -55,10 +55,7 @@ export type ToolParameter = { export type Tool = { name: string label: TypeWithI18N - description: { - zh_Hans: string - en_US: string - } + description: any parameters: ToolParameter[] } diff --git a/web/app/install/installForm.tsx b/web/app/install/installForm.tsx index b951a9a8bd..489839b4e6 100644 --- a/web/app/install/installForm.tsx +++ b/web/app/install/installForm.tsx @@ -3,11 +3,12 @@ import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import Link from 'next/link' import { useRouter } from 'next/navigation' -import { useContext } from 'use-context-selector' +// import { useContext } from 'use-context-selector' import Toast from '../components/base/toast' import Loading from '../components/base/loading' import Button from '@/app/components/base/button' -import I18n from '@/context/i18n' +// import I18n from '@/context/i18n' + import { fetchSetupStatus, setup } from '@/service/common' import type { SetupStatusResponse } from '@/models/common' @@ -16,7 +17,8 @@ const validPassword = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/ const InstallForm = () => { const { t } = useTranslation() - const { locale } = useContext(I18n) + // const { locale } = useContext(I18n) + // const language = getModelRuntimeSupported(locale) const router = useRouter() const [email, setEmail] = React.useState('') @@ -168,7 +170,7 @@ const InstallForm = () => { {t('login.license.link')} diff --git a/web/app/signin/normalForm.tsx b/web/app/signin/normalForm.tsx index 084825d19f..4050b8b3a4 100644 --- a/web/app/signin/normalForm.tsx +++ b/web/app/signin/normalForm.tsx @@ -8,11 +8,11 @@ import Link from 'next/link' import { useContext } from 'use-context-selector' import Toast from '../components/base/toast' import style from './page.module.css' -// import Tooltip from '@/app/components/base/tooltip/index' import { IS_CE_EDITION, apiPrefix } from '@/config' import Button from '@/app/components/base/button' import { login, oauth } from '@/service/common' import I18n from '@/context/i18n' +import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language' const validEmailReg = /^[\w\.-]+@([\w-]+\.)+[\w-]{2,}$/ @@ -67,6 +67,7 @@ const NormalForm = () => { const { t } = useTranslation() const router = useRouter() const { locale } = useContext(I18n) + const language = getModelRuntimeSupported(locale) const [state, dispatch] = useReducer(reducer, { formValid: false, @@ -282,13 +283,13 @@ const NormalForm = () => { {t('login.tos')}  &  {t('login.pp')} diff --git a/web/app/signin/oneMoreStep.tsx b/web/app/signin/oneMoreStep.tsx index ecd50f7fec..468df4e988 100644 --- a/web/app/signin/oneMoreStep.tsx +++ b/web/app/signin/oneMoreStep.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next' import Link from 'next/link' import useSWR from 'swr' import { useRouter } from 'next/navigation' -import { useContext } from 'use-context-selector' +// import { useContext } from 'use-context-selector' import Button from '@/app/components/base/button' import Tooltip from '@/app/components/base/tooltip/index' @@ -13,7 +13,7 @@ import { timezones } from '@/utils/timezone' import { LanguagesSupported, languages } from '@/utils/language' import { oneMoreStep } from '@/service/common' import Toast from '@/app/components/base/toast' -import I18n from '@/context/i18n' +// import I18n from '@/context/i18n' type IState = { formState: 'processing' | 'error' | 'success' | 'initial' @@ -47,7 +47,7 @@ const reducer = (state: IState, action: any) => { const OneMoreStep = () => { const { t } = useTranslation() const router = useRouter() - const { locale } = useContext(I18n) + // const { locale } = useContext(I18n) const [state, dispatch] = useReducer(reducer, { formState: 'initial', @@ -161,7 +161,7 @@ const OneMoreStep = () => { {t('login.license.link')} diff --git a/web/models/common.ts b/web/models/common.ts index e38f615310..f8038d5d35 100644 --- a/web/models/common.ts +++ b/web/models/common.ts @@ -219,7 +219,7 @@ export type CodeBasedExtensionForm = { export type CodeBasedExtensionItem = { name: string - label: I18nText + label: any form_schema: CodeBasedExtensionForm[] } export type CodeBasedExtension = { diff --git a/web/utils/language.ts b/web/utils/language.ts index 21f6c7697c..e5d6343827 100644 --- a/web/utils/language.ts +++ b/web/utils/language.ts @@ -4,6 +4,8 @@ export type Item = { } export const LanguagesSupported = ['en-US', 'zh-Hans', 'pt-BR', 'es-ES', 'fr-FR', 'de-DE', 'ja-JP', 'ko-KR', 'ru-RU', 'it-IT'] +export const LanguagesSupportedUnderscore = ['en_US', 'zh_Hans', 'pt_BR', 'es_ES', 'fr_FR', 'de_DE', 'ja_JP', 'ko_KR', 'ru_RU', 'it_IT'] + export const languages = [ { value: 'en-US',