* adapt not input type

* adapt not input type

* file i18n

* publish i18n

* translate

* i18n
This commit is contained in:
Archer
2024-05-11 00:21:01 +08:00
committed by GitHub
parent 8cf643d972
commit ee8cb0915e
28 changed files with 1515 additions and 1614 deletions

View File

@@ -1,10 +1,11 @@
import React from 'react';
import { useTranslation } from 'next-i18next';
import ApiKeyTable from '@/components/support/apikey/Table';
import { useI18n } from '@/web/context/I18n';
const ApiKey = () => {
const { t } = useTranslation();
return <ApiKeyTable tips={t('openapi.key tips')}></ApiKeyTable>;
const { publishT } = useI18n();
return <ApiKeyTable tips={publishT('key tips')}></ApiKeyTable>;
};
export default ApiKey;

View File

@@ -190,7 +190,7 @@ export async function getServerSideProps(content: any) {
return {
props: {
currentTab: content?.query?.currentTab || TabEnum.info,
...(await serviceSideProps(content))
...(await serviceSideProps(content, ['publish']))
}
};
}

View File

@@ -2,12 +2,13 @@ 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 { t } = useTranslation();
const { publishT } = useI18n();
return (
<Box pt={3}>
<ApiKeyTable tips={t('openapi.app key tips')} appId={appId} />
<ApiKeyTable tips={publishT('app key tips')} appId={appId} />
</Box>
);
};

View File

@@ -10,6 +10,7 @@ import { useForm } from 'react-hook-form';
import { useRequest } from '@/web/common/hooks/useRequest';
import dayjs from 'dayjs';
import { createShareChat, updateShareChat } from '@/web/support/outLink/api';
import { useI18n } from '@/web/context/I18n';
const FeiShuEditModal = ({
appId,
@@ -25,6 +26,7 @@ const FeiShuEditModal = ({
onEdit: () => void;
}) => {
const { t } = useTranslation();
const { publishT } = useI18n();
const {
register,
setValue,
@@ -58,13 +60,13 @@ const FeiShuEditModal = ({
<MyModal
isOpen={true}
iconSrc="/imgs/modal/shareFill.svg"
title={isEdit ? t('outlink.Edit Link') : t('outlink.Create Link')}
title={isEdit ? publishT('Edit Link') : publishT('Create Link')}
>
<ModalBody>
<Flex alignItems={'center'}>
<Box flex={'0 0 90px'}>{t('Name')}</Box>
<Input
placeholder={t('outlink.Feishu name') || 'Link Name'} // TODO: i18n
placeholder={publishT('Feishu name') || 'Link Name'} // TODO: i18n
maxLength={20}
{...register('name', {
required: t('common.Name is empty') || 'Name is empty'
@@ -74,7 +76,7 @@ const FeiShuEditModal = ({
<Flex alignItems={'center'} mt={4}>
<Flex flex={'0 0 90px'} alignItems={'center'}>
QPM
<MyTooltip label={t('outlink.QPM Tips' || '')}>
<MyTooltip label={publishT('QPM Tips' || '')}>
<QuestionOutlineIcon ml={1} />
</MyTooltip>
</Flex>
@@ -84,7 +86,7 @@ const FeiShuEditModal = ({
min: 0,
max: 1000,
valueAsNumber: true,
required: t('outlink.QPM is empty') || ''
required: publishT('QPM is empty') || ''
})}
/>
</Flex>
@@ -126,10 +128,10 @@ const FeiShuEditModal = ({
{/* TODO: i18n */}
</Flex>
<Input
placeholder={t('outlink.Default Response') || 'Link Name'}
placeholder={publishT('Default Response') || 'Link Name'}
maxLength={20}
{...register('defaultResponse', {
required: t('common.default Response is empty') || 'Name is empty'
required: true
})}
/>
</Flex>
@@ -139,10 +141,10 @@ const FeiShuEditModal = ({
{/* TODO: i18n */}
</Flex>
<Input
placeholder={t('outlink.Default Response') || 'Link Name'}
placeholder={publishT('Default Response') || 'Link Name'}
maxLength={20}
{...register('immediateResponse', {
required: t('common.default Response is empty') || 'Name is empty'
required: true
})}
/>
</Flex>
@@ -152,14 +154,14 @@ const FeiShuEditModal = ({
placeholder={t('core.module.http.appId') || 'Link Name'}
// maxLength={20}
{...register('app.appId', {
required: t('common.Name is empty') || 'Name is empty'
required: true
})}
/>
</Flex>
<Flex alignItems={'center'} mt={4}>
<Box flex={'0 0 90px'}>{t('core.module.http.AppSecret')}</Box>
<Input
placeholder={t('outlink.AppSecret') || 'Link Name'}
placeholder={'App Secret'}
// maxLength={20}
{...register('app.appSecret', {
required: t('common.Name is empty') || 'Name is empty'

View File

@@ -44,6 +44,7 @@ import { getDocPath } from '@/web/common/system/doc';
import dynamic from 'next/dynamic';
import MyMenu from '@fastgpt/web/components/common/MyMenu';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
import { useI18n } from '@/web/context/I18n';
const SelectUsingWayModal = dynamic(() => import('./SelectUsingWayModal'));
@@ -261,6 +262,7 @@ function EditLinkModal({
}) {
const { feConfigs } = useSystemStore();
const { t } = useTranslation();
const { publishT } = useI18n();
const {
register,
setValue,
@@ -293,13 +295,13 @@ function EditLinkModal({
<MyModal
isOpen={true}
iconSrc="/imgs/modal/shareFill.svg"
title={isEdit ? t('outlink.Edit Link') : t('outlink.Create Link')}
title={isEdit ? publishT('Edit Link') : publishT('Create Link')}
>
<ModalBody>
<Flex alignItems={'center'}>
<Box flex={'0 0 90px'}>{t('Name')}</Box>
<Input
placeholder={t('outlink.Link Name') || 'Link Name'}
placeholder={publishT('Link Name')}
maxLength={20}
{...register('name', {
required: t('common.Name is empty') || 'Name is empty'
@@ -327,7 +329,7 @@ function EditLinkModal({
<Flex alignItems={'center'} mt={4}>
<Flex flex={'0 0 90px'} alignItems={'center'}>
QPM
<MyTooltip label={t('outlink.QPM Tips' || '')}>
<MyTooltip label={publishT('QPM Tips' || '')}>
<QuestionOutlineIcon ml={1} />
</MyTooltip>
</Flex>
@@ -337,7 +339,7 @@ function EditLinkModal({
min: 0,
max: 1000,
valueAsNumber: true,
required: t('outlink.QPM is empty') || ''
required: publishT('QPM is empty') || ''
})}
/>
</Flex>
@@ -360,13 +362,13 @@ function EditLinkModal({
<Flex alignItems={'center'} mt={4}>
<Flex flex={'0 0 90px'} alignItems={'center'}>
{t('outlink.token auth')}
<MyTooltip label={t('outlink.token auth Tips') || ''}>
{publishT('token auth')}
<MyTooltip label={publishT('token auth Tips') || ''}>
<QuestionOutlineIcon ml={1} />
</MyTooltip>
</Flex>
<Input
placeholder={t('outlink.token auth Tips') || ''}
placeholder={publishT('token auth Tips') || ''}
fontSize={'sm'}
{...register('limit.hookUrl')}
/>
@@ -377,7 +379,7 @@ function EditLinkModal({
fontSize={'sm'}
color={'myGray.500'}
>
{t('outlink.token auth use cases')}
{publishT('token auth use cases')}
</Link>
</>
)}

View File

@@ -196,7 +196,7 @@ export async function getServerSideProps(context: any) {
const currentTab = context?.query?.currentTab || TabEnum.simpleEdit;
return {
props: { currentTab, ...(await serviceSideProps(context, ['app'])) }
props: { currentTab, ...(await serviceSideProps(context, ['app', 'file', 'publish'])) }
};
}

View File

@@ -371,7 +371,7 @@ export async function getServerSideProps(context: any) {
props: {
appId: context?.query?.appId || '',
chatId: context?.query?.chatId || '',
...(await serviceSideProps(context))
...(await serviceSideProps(context, ['file']))
}
};
}

View File

@@ -431,7 +431,7 @@ export async function getServerSideProps(context: any) {
appName: app?.appId?.name || '',
appAvatar: app?.appId?.avatar || '',
appIntro: app?.appId?.intro || '',
...(await serviceSideProps(context))
...(await serviceSideProps(context, ['file']))
}
};
}

View File

@@ -382,7 +382,7 @@ const OutLink = () => {
export async function getServerSideProps(context: any) {
return {
props: {
...(await serviceSideProps(context))
...(await serviceSideProps(context, ['file']))
}
};
}

View File

@@ -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 (

View File

@@ -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

View 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')}

View File

@@ -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'])) }
};
}