mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00
i18n (#1444)
* adapt not input type * adapt not input type * file i18n * publish i18n * translate * i18n
This commit is contained in:
@@ -27,9 +27,11 @@ import {
|
||||
postCreateDatasetTextCollection
|
||||
} from '@/web/core/dataset/api';
|
||||
import Tag from '@fastgpt/web/components/common/Tag/index';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
|
||||
const Upload = () => {
|
||||
const { t } = useTranslation();
|
||||
const { fileT } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const { datasetDetail } = useDatasetStore();
|
||||
@@ -131,7 +133,7 @@ const Upload = () => {
|
||||
)
|
||||
);
|
||||
},
|
||||
errorToast: t('common.file.Upload failed')
|
||||
errorToast: fileT('Upload failed')
|
||||
});
|
||||
|
||||
return (
|
||||
|
@@ -13,6 +13,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { uploadFile2DB } from '@/web/common/file/controller';
|
||||
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
|
||||
import { ImportSourceItemType } from '@/web/core/dataset/type';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
|
||||
export type SelectFileItemType = {
|
||||
fileId: string;
|
||||
@@ -35,6 +36,8 @@ const FileSelector = ({
|
||||
onFinishSelect: () => void;
|
||||
} & FlexProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { fileT } = useI18n();
|
||||
|
||||
const { toast } = useToast();
|
||||
const { feConfigs } = useSystemStore();
|
||||
|
||||
@@ -129,7 +132,7 @@ const FileSelector = ({
|
||||
files = files.slice(0, maxCount - selectFiles.length);
|
||||
toast({
|
||||
status: 'warning',
|
||||
title: t('common.file.Some file count exceeds limit', { maxCount })
|
||||
title: fileT('Some file count exceeds limit', { maxCount })
|
||||
});
|
||||
}
|
||||
// size check
|
||||
@@ -141,7 +144,7 @@ const FileSelector = ({
|
||||
if (filterFiles.length < files.length) {
|
||||
toast({
|
||||
status: 'warning',
|
||||
title: t('common.file.Some file size exceeds limit', { maxSize: formatFileSize(maxSize) })
|
||||
title: fileT('Some file size exceeds limit', { maxSize: formatFileSize(maxSize) })
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,7 +206,7 @@ const FileSelector = ({
|
||||
let isErr = files.some((item) => item.type === '');
|
||||
if (isErr) {
|
||||
return toast({
|
||||
title: t('file.upload error description'),
|
||||
title: fileT('upload error description'),
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
@@ -262,18 +265,18 @@ const FileSelector = ({
|
||||
<>
|
||||
<Box fontWeight={'bold'}>
|
||||
{isDragging
|
||||
? t('file.Release the mouse to upload the file')
|
||||
: t('common.file.Select and drag file tip')}
|
||||
? fileT('Release the mouse to upload the file')
|
||||
: fileT('Select and drag file tip')}
|
||||
</Box>
|
||||
{/* file type */}
|
||||
<Box color={'myGray.500'} fontSize={'xs'}>
|
||||
{t('common.file.Support file type', { fileType })}
|
||||
{fileT('Support file type', { fileType })}
|
||||
</Box>
|
||||
<Box color={'myGray.500'} fontSize={'xs'}>
|
||||
{/* max count */}
|
||||
{maxCount && t('common.file.Support max count', { maxCount })}
|
||||
{maxCount && fileT('Support max count', { maxCount })}
|
||||
{/* max size */}
|
||||
{maxSize && t('common.file.Support max size', { maxSize: formatFileSize(maxSize) })}
|
||||
{maxSize && fileT('Support max size', { maxSize: formatFileSize(maxSize) })}
|
||||
</Box>
|
||||
|
||||
<File
|
||||
|
@@ -16,6 +16,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import MyTooltip from '@/components/MyTooltip';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
|
||||
const PreviewRawText = dynamic(() => import('./PreviewRawText'));
|
||||
|
||||
@@ -29,6 +30,7 @@ export const RenderUploadFiles = ({
|
||||
showPreviewContent?: boolean;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { fileT } = useI18n();
|
||||
const [previewFile, setPreviewFile] = useState<ImportSourceItemType>();
|
||||
|
||||
return files.length > 0 ? (
|
||||
@@ -38,13 +40,13 @@ export const RenderUploadFiles = ({
|
||||
<Thead draggable={false}>
|
||||
<Tr bg={'myGray.100'} mb={2}>
|
||||
<Th borderLeftRadius={'md'} borderBottom={'none'} py={4}>
|
||||
{t('common.file.File Name')}
|
||||
{fileT('File Name')}
|
||||
</Th>
|
||||
<Th borderBottom={'none'} py={4}>
|
||||
{t('core.dataset.import.Upload file progress')}
|
||||
</Th>
|
||||
<Th borderBottom={'none'} py={4}>
|
||||
{t('common.file.File Size')}
|
||||
{fileT('File Size')}
|
||||
</Th>
|
||||
<Th borderRightRadius={'md'} borderBottom={'none'} py={4}>
|
||||
{t('common.Action')}
|
||||
|
@@ -295,7 +295,7 @@ export async function getServerSideProps(context: any) {
|
||||
const datasetId = context?.query?.datasetId;
|
||||
|
||||
return {
|
||||
props: { currentTab, datasetId, ...(await serviceSideProps(context)) }
|
||||
props: { currentTab, datasetId, ...(await serviceSideProps(context, ['file'])) }
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user