mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 00:17:31 +00:00
feat: optimize i18n implementation for better localization (#2062)
* feat: optimize i18n implementation for better localization * delete i18n-ally-custom-framework.yml * update common key
This commit is contained in:
@@ -69,7 +69,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
setValue('avatar', src);
|
||||
} catch (err: any) {
|
||||
toast({
|
||||
title: getErrText(err, t('common.avatar.Select Failed')),
|
||||
title: getErrText(err, t('common:common.avatar.Select Failed')),
|
||||
status: 'warning'
|
||||
});
|
||||
}
|
||||
@@ -83,8 +83,8 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
const id = await postCreateDataset(data);
|
||||
return id;
|
||||
},
|
||||
successToast: t('common.Create Success'),
|
||||
errorToast: t('common.Create Failed'),
|
||||
successToast: t('common:common.Create Success'),
|
||||
errorToast: t('common:common.Create Failed'),
|
||||
onSuccess(id) {
|
||||
router.push(`/dataset/detail?datasetId=${id}`);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
) {
|
||||
return toast({
|
||||
status: 'warning',
|
||||
title: t('common.system.Commercial version function')
|
||||
title: t('common:common.system.Commercial version function')
|
||||
});
|
||||
}
|
||||
setValue('type', e);
|
||||
@@ -109,7 +109,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
return (
|
||||
<MyModal
|
||||
iconSrc="/imgs/workflow/db.png"
|
||||
title={t('core.dataset.Create dataset')}
|
||||
title={t('common:core.dataset.Create dataset')}
|
||||
isOpen
|
||||
onClose={onClose}
|
||||
isCentered={!isPc}
|
||||
@@ -118,7 +118,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
<ModalBody py={2}>
|
||||
<>
|
||||
<Box mb={1} color={'myGray.900'}>
|
||||
{t('core.dataset.Dataset Type')}
|
||||
{t('common:core.dataset.Dataset Type')}
|
||||
</Box>
|
||||
<MyRadio
|
||||
gridGap={2}
|
||||
@@ -148,9 +148,9 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
/>
|
||||
</>
|
||||
<Box mt={5}>
|
||||
<Box color={'myGray.900'}>{t('common.Set Name')}</Box>
|
||||
<Box color={'myGray.900'}>{t('common:common.Set Name')}</Box>
|
||||
<Flex mt={1} alignItems={'center'}>
|
||||
<MyTooltip label={t('common.avatar.Select Avatar')}>
|
||||
<MyTooltip label={t('common:common.avatar.Select Avatar')}>
|
||||
<Avatar
|
||||
flexShrink={0}
|
||||
src={avatar}
|
||||
@@ -166,7 +166,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
flex={1}
|
||||
autoFocus
|
||||
bg={'myWhite.600'}
|
||||
placeholder={t('common.Name')}
|
||||
placeholder={t('common:common.Name')}
|
||||
maxLength={30}
|
||||
{...register('name', {
|
||||
required: true
|
||||
@@ -177,8 +177,8 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
{filterNotHiddenVectorModelList.length > 1 && (
|
||||
<Flex mt={6} alignItems={'center'}>
|
||||
<Flex alignItems={'center'} flex={'0 0 100px'} fontSize={'sm'}>
|
||||
{t('core.ai.model.Vector Model')}
|
||||
<QuestionTip label={t('core.dataset.embedding model tip')} />
|
||||
{t('common:core.ai.model.Vector Model')}
|
||||
<QuestionTip label={t('common:core.dataset.embedding model tip')} />
|
||||
</Flex>
|
||||
<Box flex={1}>
|
||||
<AIModelSelector
|
||||
@@ -198,7 +198,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
{datasetModelList.length > 1 && (
|
||||
<Flex mt={6} alignItems={'center'}>
|
||||
<Box flex={'0 0 100px'} fontSize={'sm'}>
|
||||
{t('core.ai.model.Dataset Agent Model')}
|
||||
{t('common:core.ai.model.Dataset Agent Model')}
|
||||
</Box>
|
||||
<Box flex={1}>
|
||||
<AIModelSelector
|
||||
@@ -219,10 +219,10 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
|
||||
|
||||
<ModalFooter>
|
||||
<Button variant={'whiteBase'} mr={3} onClick={onClose}>
|
||||
{t('common.Close')}
|
||||
{t('common:common.Close')}
|
||||
</Button>
|
||||
<Button isLoading={creating} onClick={handleSubmit((data) => onclickCreate(data))}>
|
||||
{t('common.Confirm Create')}
|
||||
{t('common:common.Confirm Create')}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
|
||||
|
@@ -93,22 +93,22 @@ function List() {
|
||||
onSuccess() {
|
||||
toast({
|
||||
status: 'success',
|
||||
title: t('core.dataset.Start export')
|
||||
title: t('common:core.dataset.Start export')
|
||||
});
|
||||
},
|
||||
onSettled() {
|
||||
setLoading(false);
|
||||
},
|
||||
errorToast: t('dataset.Export Dataset Limit Error')
|
||||
errorToast: t('common:dataset.Export Dataset Limit Error')
|
||||
});
|
||||
|
||||
const EditResourceModal = dynamic(() => import('@/components/common/Modal/EditResourceModal'));
|
||||
|
||||
const DeleteTipsMap = useRef({
|
||||
[DatasetTypeEnum.folder]: t('dataset.deleteFolderTips'),
|
||||
[DatasetTypeEnum.dataset]: t('core.dataset.Delete Confirm'),
|
||||
[DatasetTypeEnum.websiteDataset]: t('core.dataset.Delete Confirm'),
|
||||
[DatasetTypeEnum.externalFile]: t('core.dataset.Delete Confirm')
|
||||
[DatasetTypeEnum.folder]: t('common:dataset.deleteFolderTips'),
|
||||
[DatasetTypeEnum.dataset]: t('common:core.dataset.Delete Confirm'),
|
||||
[DatasetTypeEnum.websiteDataset]: t('common:core.dataset.Delete Confirm'),
|
||||
[DatasetTypeEnum.externalFile]: t('common:core.dataset.Delete Confirm')
|
||||
});
|
||||
|
||||
const formatDatasets = useMemo(
|
||||
@@ -253,14 +253,14 @@ function List() {
|
||||
},
|
||||
{
|
||||
icon: 'common/file/move',
|
||||
label: t('Move'),
|
||||
label: t('common:Move'),
|
||||
onClick: () => setMoveDatasetId(dataset._id)
|
||||
},
|
||||
...(dataset.permission.hasManagePer
|
||||
? [
|
||||
{
|
||||
icon: 'support/team/key',
|
||||
label: t('permission.Permission'),
|
||||
label: t('common:permission.Permission'),
|
||||
onClick: () => setEditPerDatasetIndex(index)
|
||||
}
|
||||
]
|
||||
@@ -273,7 +273,7 @@ function List() {
|
||||
children: [
|
||||
{
|
||||
icon: 'export',
|
||||
label: t('Export'),
|
||||
label: t('common:Export'),
|
||||
onClick: () => {
|
||||
exportDataset(dataset);
|
||||
}
|
||||
@@ -288,7 +288,7 @@ function List() {
|
||||
children: [
|
||||
{
|
||||
icon: 'delete',
|
||||
label: t('common.Delete'),
|
||||
label: t('common:common.Delete'),
|
||||
type: 'danger' as 'danger',
|
||||
onClick: () => onClickDeleteDataset(dataset._id)
|
||||
}
|
||||
@@ -317,8 +317,8 @@ function List() {
|
||||
>
|
||||
{dataset.intro ||
|
||||
(dataset.type === DatasetTypeEnum.folder
|
||||
? t('core.dataset.Folder placeholder')
|
||||
: t('core.dataset.Intro Placeholder'))}
|
||||
? t('common:core.dataset.Folder placeholder')
|
||||
: t('common:core.dataset.Intro Placeholder'))}
|
||||
</Box>
|
||||
<Flex alignItems={'center'} fontSize={'sm'}>
|
||||
<Box flex={1}>
|
||||
@@ -337,7 +337,11 @@ function List() {
|
||||
</Grid>
|
||||
)}
|
||||
{myDatasets.length === 0 && (
|
||||
<EmptyTip pt={'35vh'} text={t('core.dataset.Empty Dataset Tips')} flexGrow="1"></EmptyTip>
|
||||
<EmptyTip
|
||||
pt={'35vh'}
|
||||
text={t('common:core.dataset.Empty Dataset Tips')}
|
||||
flexGrow="1"
|
||||
></EmptyTip>
|
||||
)}
|
||||
|
||||
{editedDataset && (
|
||||
|
@@ -45,7 +45,7 @@ const MoveModal = ({
|
||||
() => [
|
||||
{
|
||||
parentId: '',
|
||||
parentName: t('core.dataset.My Dataset')
|
||||
parentName: t('common:core.dataset.My Dataset')
|
||||
},
|
||||
...(data?.[1] || [])
|
||||
],
|
||||
@@ -59,7 +59,7 @@ const MoveModal = ({
|
||||
const { mutate, isLoading } = useRequest({
|
||||
mutationFn: () => putDatasetById({ id: moveDataId, parentId }),
|
||||
onSuccess,
|
||||
errorToast: t('dataset.Move Failed')
|
||||
errorToast: t('common:dataset.Move Failed')
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -99,7 +99,7 @@ const MoveModal = ({
|
||||
))}
|
||||
</Flex>
|
||||
) : (
|
||||
<Box>{t('core.dataset.My Dataset')}</Box>
|
||||
<Box>{t('common:core.dataset.My Dataset')}</Box>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
@@ -124,8 +124,8 @@ const MoveModal = ({
|
||||
key={item._id}
|
||||
label={
|
||||
item.type === DatasetTypeEnum.dataset
|
||||
? t('dataset.Select Dataset')
|
||||
: t('dataset.Select Folder')
|
||||
? t('common:dataset.Select Dataset')
|
||||
: t('common:dataset.Select Folder')
|
||||
}
|
||||
>
|
||||
<Card
|
||||
@@ -154,7 +154,7 @@ const MoveModal = ({
|
||||
</Flex>
|
||||
<Flex justifyContent={'flex-end'} alignItems={'center'} fontSize={'sm'}>
|
||||
{item.type === DatasetTypeEnum.folder ? (
|
||||
<Box color={'myGray.500'}>{t('Folder')}</Box>
|
||||
<Box color={'myGray.500'}>{t('common:Folder')}</Box>
|
||||
) : (
|
||||
<>
|
||||
<MyIcon mr={1} name="kbTest" w={'12px'} />
|
||||
@@ -168,12 +168,14 @@ const MoveModal = ({
|
||||
})()
|
||||
)}
|
||||
</Grid>
|
||||
{folderList.length === 0 && <EmptyTip text={t('common.folder.No Folder')}></EmptyTip>}
|
||||
{folderList.length === 0 && (
|
||||
<EmptyTip text={t('common:common.folder.No Folder')}></EmptyTip>
|
||||
)}
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
<Button isLoading={isLoading} onClick={mutate}>
|
||||
{t('dataset.Confirm move the folder')}
|
||||
{t('common:dataset.Confirm move the folder')}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Flex>
|
||||
|
@@ -117,8 +117,8 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
|
||||
const [editedDataset, setEditedDataset] = useState<EditResourceInfoFormType>();
|
||||
|
||||
const { runAsync: onDelDataset } = useRequest2(delDatasetById, {
|
||||
successToast: t('common.Delete Success'),
|
||||
errorToast: t('dataset.Delete Dataset Error')
|
||||
successToast: t('common:common.Delete Success'),
|
||||
errorToast: t('common:dataset.Delete Dataset Error')
|
||||
});
|
||||
|
||||
const contextValue = {
|
||||
|
@@ -80,7 +80,7 @@ const Dataset = () => {
|
||||
<Flex flex={1} alignItems={'center'}>
|
||||
<Image src={'/imgs/workflow/db.png'} alt={''} mr={2} h={'24px'} />
|
||||
<Box className="textlg" letterSpacing={1} fontSize={'24px'} fontWeight={'bold'}>
|
||||
{t('core.dataset.My Dataset')}
|
||||
{t('common:core.dataset.My Dataset')}
|
||||
</Box>
|
||||
</Flex>
|
||||
}
|
||||
@@ -100,7 +100,7 @@ const Dataset = () => {
|
||||
<Button variant={'primary'} px="0">
|
||||
<Flex alignItems={'center'} px={'20px'}>
|
||||
<AddIcon mr={2} />
|
||||
<Box>{t('common.Create New')}</Box>
|
||||
<Box>{t('common:common.Create New')}</Box>
|
||||
</Flex>
|
||||
</Button>
|
||||
}
|
||||
@@ -111,7 +111,7 @@ const Dataset = () => {
|
||||
label: (
|
||||
<Flex>
|
||||
<MyIcon name={FolderIcon} w={'20px'} mr={1} />
|
||||
{t('Folder')}
|
||||
{t('common:Folder')}
|
||||
</Flex>
|
||||
),
|
||||
onClick: () => setEditFolderData({})
|
||||
@@ -120,7 +120,7 @@ const Dataset = () => {
|
||||
label: (
|
||||
<Flex>
|
||||
<Image src={'/imgs/workflow/db.png'} alt={''} w={'20px'} mr={1} />
|
||||
{t('core.dataset.Dataset')}
|
||||
{t('common:core.dataset.Dataset')}
|
||||
</Flex>
|
||||
),
|
||||
onClick: onOpenCreateModal
|
||||
@@ -150,7 +150,7 @@ const Dataset = () => {
|
||||
});
|
||||
}}
|
||||
onMove={() => setMoveDatasetId(folderDetail._id)}
|
||||
deleteTip={t('dataset.deleteFolderTips')}
|
||||
deleteTip={t('common:dataset.deleteFolderTips')}
|
||||
onDelete={() =>
|
||||
onDelDataset(folderDetail._id).then(() => {
|
||||
router.replace({
|
||||
|
Reference in New Issue
Block a user