* 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

@@ -2,6 +2,7 @@ import React, { useRef, useCallback } from 'react';
import { Box } from '@chakra-ui/react';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useTranslation } from 'next-i18next';
import { useI18n } from '@/web/context/I18n';
export const useSelectFile = (props?: {
fileType?: string;
@@ -9,6 +10,7 @@ export const useSelectFile = (props?: {
maxCount?: number;
}) => {
const { t } = useTranslation();
const { fileT } = useI18n();
const { fileType = '*', multiple = false, maxCount = 10 } = props || {};
const { toast } = useToast();
const SelectFileDom = useRef<HTMLInputElement>(null);
@@ -30,7 +32,7 @@ export const useSelectFile = (props?: {
if (fileList.length > maxCount) {
toast({
status: 'warning',
title: t('common.file.Select file amount limit', { max: maxCount })
title: fileT('Select file amount limit', { max: maxCount })
});
fileList = fileList.slice(0, maxCount);
}
@@ -39,7 +41,7 @@ export const useSelectFile = (props?: {
/>
</Box>
),
[fileType, maxCount, multiple, t, toast]
[fileT, fileType, maxCount, multiple, toast]
);
const onOpen = useCallback((sign?: any) => {

View File

@@ -6,6 +6,8 @@ type I18nContextType = {
commonT: TFunction<['common'], undefined>;
appT: TFunction<['app'], undefined>;
datasetT: TFunction<['dataset'], undefined>;
fileT: TFunction<['file'], undefined>;
publishT: TFunction<['publish'], undefined>;
};
export const I18nContext = createContext<I18nContextType>({
@@ -17,13 +19,17 @@ 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');
return (
<I18nContext.Provider
value={{
commonT,
appT,
datasetT
datasetT,
fileT,
publishT
}}
>
{children}