mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
i18n (#1444)
* adapt not input type * adapt not input type * file i18n * publish i18n * translate * i18n
This commit is contained in:
@@ -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) => {
|
||||
|
@@ -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}
|
||||
|
Reference in New Issue
Block a user