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 # you can ignore it and use your own matching rules as well
- "[^\\w\\d]t\\(['\"`]({key})['\"`]" - "[^\\w\\d]t\\(['\"`]({key})['\"`]"
- "[^\\w\\d]commonT\\(['\"`]({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]fileT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]publishT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]workflowT\\(['\"`]({key})['\"`]" - "[^\\w\\d]workflowT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]userT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]chatT\\(['\"`]({key})['\"`]"
- "[^\\w\\d]i18nT\\(['\"`]({key})['\"`]" - "[^\\w\\d]i18nT\\(['\"`]({key})['\"`]"
# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys # 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': '@fortaine/fetch-event-source':
specifier: ^3.0.6 specifier: ^3.0.6
version: 3.0.6 version: 3.0.6
'@node-rs/jieba':
specifier: 2.0.1
version: 2.0.1
'@tanstack/react-query': '@tanstack/react-query':
specifier: ^4.24.10 specifier: ^4.24.10
version: 4.36.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) 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) { if (!config.externals) {
config.externals = []; config.externals = [];
} }
config.externals.push('@node-rs/jieba');
if (isServer) { if (isServer) {
config.externals.push('@node-rs/jieba');
if (nextRuntime === 'nodejs') { if (nextRuntime === 'nodejs') {
const oldEntry = config.entry; const oldEntry = config.entry;
config = { config = {
@@ -85,7 +85,6 @@ const nextConfig = {
'pg', 'pg',
'@zilliz/milvus2-sdk-node', '@zilliz/milvus2-sdk-node',
"tiktoken", "tiktoken",
"@node-rs/jieba"
], ],
outputFileTracingRoot: path.join(__dirname, '../../'), outputFileTracingRoot: path.join(__dirname, '../../'),
instrumentationHook: true instrumentationHook: true

View File

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

View File

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

View File

@@ -22,7 +22,6 @@ export default function InputGuideBox({
onSend: (text: string) => void; onSend: (text: string) => void;
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { chatT } = useI18n();
const chatInputGuide = useContextSelector(ChatBoxContext, (v) => v.chatInputGuide); const chatInputGuide = useContextSelector(ChatBoxContext, (v) => v.chatInputGuide);
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData); 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}> <Flex alignItems={'center'} fontSize={'sm'} color={'myGray.600'} gap={2} mb={2} px={2}>
<MyIcon name={'union'} /> <MyIcon name={'union'} />
<Box>{chatT('input_guide')}</Box> <Box>{t('chat:input_guide')}</Box>
</Flex> </Flex>
{data.map((item, index) => ( {data.map((item) => (
<Flex <Flex
alignItems={'center'} alignItems={'center'}
as={'li'} 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 MyIcon from '@fastgpt/web/components/common/Icon';
import React from 'react'; import React from 'react';
import { DatasetTypeMap } from '@fastgpt/global/core/dataset/constants'; 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 DatasetTypeTag = ({ type, ...props }: { type: `${DatasetTypeEnum}` } & FlexProps) => {
const { datasetT } = useI18n(); const { t } = useTranslation();
const item = DatasetTypeMap[type] || DatasetTypeMap['dataset']; const item = DatasetTypeMap[type] || DatasetTypeMap['dataset'];
return ( return (
@@ -24,8 +23,7 @@ const DatasetTypeTag = ({ type, ...props }: { type: `${DatasetTypeEnum}` } & Fle
{...props} {...props}
> >
<MyIcon name={item.icon as any} w={'16px'} mr={2} color={'myGray.400'} /> <MyIcon name={item.icon as any} w={'16px'} mr={2} color={'myGray.400'} />
{/* @ts-ignore */} <Box>{t(item.label as any)}</Box>
<Box>{datasetT(item.label)}</Box>
</Flex> </Flex>
); );
}; };

View File

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

View File

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

View File

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

View File

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