remove i18n tip (#4202)

This commit is contained in:
Archer
2025-03-17 21:54:02 +08:00
committed by archer
parent e0b5d35d8e
commit f842ad93ce
11 changed files with 26 additions and 62 deletions

View File

@@ -17,15 +17,8 @@ usageMatchRegex:
# you can ignore it and use your own matching rules as well
- "[^\\w\\d]t\\(['\"`]({key})['\"`]"
- "[^\\w\\d]commonT\\(['\"`]({key})['\"`]"
# 支持 appT("your.i18n.keys")
- "[^\\w\\d]appT\\(['\"`]({key})['\"`]"
# 支持 datasetT("your.i18n.keys")
- "[^\\w\\d]datasetT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]fileT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]publishT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]workflowT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]userT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]chatT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]i18nT\\(['\"`]({key})['\"`]"
# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys

3
pnpm-lock.yaml generated
View File

@@ -462,9 +462,6 @@ importers:
'@fortaine/fetch-event-source':
specifier: ^3.0.6
version: 3.0.6
'@node-rs/jieba':
specifier: 2.0.1
version: 2.0.1
'@tanstack/react-query':
specifier: ^4.24.10
version: 4.36.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)

View File

@@ -39,9 +39,9 @@ const nextConfig = {
if (!config.externals) {
config.externals = [];
}
config.externals.push('@node-rs/jieba');
if (isServer) {
config.externals.push('@node-rs/jieba');
if (nextRuntime === 'nodejs') {
const oldEntry = config.entry;
config = {
@@ -85,7 +85,6 @@ const nextConfig = {
'pg',
'@zilliz/milvus2-sdk-node',
"tiktoken",
"@node-rs/jieba"
],
outputFileTracingRoot: path.join(__dirname, '../../'),
instrumentationHook: true

View File

@@ -64,7 +64,6 @@
"request-ip": "^3.3.0",
"sass": "^1.58.3",
"use-context-selector": "^1.4.4",
"@node-rs/jieba": "2.0.1",
"zustand": "^4.3.5"
},
"devDependencies": {

View File

@@ -54,7 +54,6 @@ const InputGuideConfig = ({
onChange: (e: ChatInputGuideConfigType) => void;
}) => {
const { t } = useTranslation();
const { chatT } = useI18n();
const { isOpen, onOpen, onClose } = useDisclosure();
const {
isOpen: isOpenLexiconConfig,
@@ -87,11 +86,11 @@ const InputGuideConfig = ({
<Flex alignItems={'center'}>
<MyIcon name={'core/app/inputGuides'} mr={2} w={'20px'} />
<Flex alignItems={'center'}>
<FormLabel color={'myGray.600'}>{chatT('input_guide')}</FormLabel>
<FormLabel color={'myGray.600'}>{t('chat:input_guide')}</FormLabel>
<ChatFunctionTip type={'inputGuide'} />
</Flex>
<Box flex={1} />
<MyTooltip label={chatT('config_input_guide')}>
<MyTooltip label={t('chat:config_input_guide')}>
<Button
variant={'transparentBase'}
iconSpacing={1}
@@ -104,7 +103,7 @@ const InputGuideConfig = ({
</Button>
</MyTooltip>
<MyModal
title={chatT('input_guide')}
title={t('chat:input_guide')}
iconSrc="core/app/inputGuides"
isOpen={isOpen}
onClose={onClose}
@@ -126,7 +125,7 @@ const InputGuideConfig = ({
{isOpenQuestionGuide && (
<>
<Flex mt={8} alignItems={'center'}>
<FormLabel>{chatT('input_guide_lexicon')}</FormLabel>
<FormLabel>{t('chat:input_guide_lexicon')}</FormLabel>
<Box fontSize={'xs'} px={2} bg={'myGray.100'} ml={1} rounded={'full'}>
{total}
</Box>
@@ -144,7 +143,7 @@ const InputGuideConfig = ({
</Flex>
<>
<Flex mt={8} alignItems={'center'}>
<FormLabel>{chatT('custom_input_guide_url')}</FormLabel>
<FormLabel>{t('chat:custom_input_guide_url')}</FormLabel>
<Flex
onClick={() => window.open(getDocPath('/docs/guide/course/chat_input_guide/'))}
color={'primary.700'}
@@ -181,7 +180,7 @@ const InputGuideConfig = ({
export default React.memo(InputGuideConfig);
const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () => void }) => {
const { chatT, commonT } = useI18n();
const { commonT } = useI18n();
const { t } = useTranslation();
const { toast } = useToast();
const { File, onOpen: onOpenSelectFile } = useSelectFile({
@@ -232,7 +231,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () =>
if (res.insertLength < textList.length) {
toast({
status: 'warning',
title: chatT('insert_input_guide,_some_data_already_exists', { len: res.insertLength })
title: t('chat:insert_input_guide,_some_data_already_exists', { len: res.insertLength })
});
} else {
toast({
@@ -301,7 +300,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () =>
return (
<MyModal
title={chatT('config_input_guide_lexicon_title')}
title={t('chat:config_input_guide_lexicon_title')}
iconSrc="core/app/inputGuides"
isOpen={true}
onClose={onClose}
@@ -338,7 +337,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () =>
});
}}
>
<QuestionTip ml={-2} label={chatT('csv_input_lexicon_tip')} />
<QuestionTip ml={-2} label={t('chat:csv_input_lexicon_tip')} />
</Box>
</Flex>
<Box px={8}>
@@ -394,7 +393,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () =>
<MyInput
autoFocus
rightIcon={<MyIcon name={'save'} w={'14px'} cursor={'pointer'} />}
placeholder={chatT('new_input_guide_lexicon')}
placeholder={t('chat:new_input_guide_lexicon')}
onBlur={(e) => {
createNewData([e.target.value.trim()]);
}}
@@ -411,7 +410,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () =>
px={8}
flex={'1 0 0'}
fontSize={'sm'}
EmptyChildren={<EmptyTip text={chatT('chat_input_guide_lexicon_is_empty')} />}
EmptyChildren={<EmptyTip text={t('chat:chat_input_guide_lexicon_is_empty')} />}
>
{scrollDataList.map((data, index) => {
const item = data.data;

View File

@@ -22,7 +22,6 @@ export default function InputGuideBox({
onSend: (text: string) => void;
}) {
const { t } = useTranslation();
const { chatT } = useI18n();
const chatInputGuide = useContextSelector(ChatBoxContext, (v) => v.chatInputGuide);
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
@@ -65,9 +64,9 @@ export default function InputGuideBox({
>
<Flex alignItems={'center'} fontSize={'sm'} color={'myGray.600'} gap={2} mb={2} px={2}>
<MyIcon name={'union'} />
<Box>{chatT('input_guide')}</Box>
<Box>{t('chat:input_guide')}</Box>
</Flex>
{data.map((item, index) => (
{data.map((item) => (
<Flex
alignItems={'center'}
as={'li'}

View File

@@ -3,11 +3,10 @@ import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import MyIcon from '@fastgpt/web/components/common/Icon';
import React from 'react';
import { DatasetTypeMap } from '@fastgpt/global/core/dataset/constants';
import { useI18n } from '@/web/context/I18n';
import { useTranslation } from 'next-i18next';
const DatasetTypeTag = ({ type, ...props }: { type: `${DatasetTypeEnum}` } & FlexProps) => {
const { datasetT } = useI18n();
const { t } = useTranslation();
const item = DatasetTypeMap[type] || DatasetTypeMap['dataset'];
return (
@@ -24,8 +23,7 @@ const DatasetTypeTag = ({ type, ...props }: { type: `${DatasetTypeEnum}` } & Fle
{...props}
>
<MyIcon name={item.icon as any} w={'16px'} mr={2} color={'myGray.400'} />
{/* @ts-ignore */}
<Box>{datasetT(item.label)}</Box>
<Box>{t(item.label as any)}</Box>
</Flex>
);
};

View File

@@ -1,12 +1,10 @@
import React, { useEffect, useState } from 'react';
import ApiKeyTable from '@/components/support/apikey/Table';
import { useTranslation } from 'next-i18next';
import { Box } from '@chakra-ui/react';
import { useI18n } from '@/web/context/I18n';
const API = ({ appId }: { appId: string }) => {
const { publishT } = useI18n();
return <ApiKeyTable tips={publishT('app_key_tips')} appId={appId} />;
const { t } = useTranslation();
return <ApiKeyTable tips={t('publish:app_key_tips')} appId={appId} />;
};
export default API;

View File

@@ -3,31 +3,30 @@ import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { useI18n } from '@/web/context/I18n';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { Box, Flex } from '@chakra-ui/react';
import { i18nT } from '@fastgpt/web/i18n/utils';
const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
const { appT } = useI18n();
const map = useRef({
[AppTypeEnum.simple]: {
label: appT('type.Simple bot'),
label: i18nT('app:type.Simple bot'),
icon: 'core/app/type/simple',
bg: '#DBF3FF',
color: '#0884DD'
},
[AppTypeEnum.workflow]: {
label: appT('type.Workflow bot'),
label: i18nT('app:type.Workflow bot'),
icon: 'core/app/type/workflow',
bg: '#E4E1FC',
color: '#6F5DD7'
},
[AppTypeEnum.plugin]: {
label: appT('type.Plugin'),
label: i18nT('app:type.Plugin'),
icon: 'core/app/type/plugin',
bg: '#D0F5EE',
color: '#007E7C'
},
[AppTypeEnum.httpPlugin]: {
label: appT('type.Http plugin'),
label: i18nT('app:type.Http plugin'),
icon: 'core/app/type/httpPlugin',
bg: '#FFE4EE',
color: '#E82F72'

View File

@@ -6,7 +6,6 @@ import { useRouter } from 'next/router';
import { useContextSelector } from 'use-context-selector';
import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext';
import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs';
import { useI18n } from '@/web/context/I18n';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import MyPopover from '@fastgpt/web/components/common/MyPopover';
import ParentPaths from '@/components/common/ParentPaths';
@@ -22,7 +21,6 @@ export enum TabEnum {
const NavBar = ({ currentTab }: { currentTab: TabEnum }) => {
const theme = useTheme();
const { t } = useTranslation();
const { datasetT } = useI18n();
const router = useRouter();
const query = router.query;
const { isPc } = useSystem();
@@ -168,7 +166,7 @@ const NavBar = ({ currentTab }: { currentTab: TabEnum }) => {
{rebuildingCount > 0 && (
<Box mb={3}>
<Box fontSize={'sm'}>
{datasetT('rebuilding_index_count', { count: rebuildingCount })}
{t('dataset:rebuilding_index_count', { count: rebuildingCount })}
</Box>
</Box>
)}

View File

@@ -4,13 +4,8 @@ import { TFunction } from 'i18next';
type I18nContextType = {
commonT: TFunction<['common'], undefined>;
appT: TFunction<['app'], undefined>;
datasetT: TFunction<['dataset'], undefined>;
fileT: TFunction<['file'], undefined>;
publishT: TFunction<['publish'], undefined>;
workflowT: TFunction<['workflow'], undefined>;
userT: TFunction<['user'], undefined>;
chatT: TFunction<['chat'], undefined>;
};
export const I18nContext = createContext<I18nContextType>({
@@ -20,25 +15,15 @@ export const I18nContext = createContext<I18nContextType>({
const I18nContextProvider = ({ children }: { children: React.ReactNode }) => {
const { t: commonT } = useTranslation('common');
const { t: appT } = useTranslation('app');
const { t: datasetT } = useTranslation('dataset');
const { t: fileT } = useTranslation('file');
const { t: publishT } = useTranslation('publish');
const { t: workflowT } = useTranslation('workflow');
const { t: userT } = useTranslation('user');
const { t: chatT } = useTranslation('chat');
return (
<I18nContext.Provider
value={{
commonT,
appT,
datasetT,
fileT,
publishT,
workflowT,
userT,
chatT
workflowT
}}
>
{children}