addition i18n (#2631)

This commit is contained in:
papapatrick
2024-09-06 16:57:47 +08:00
committed by GitHub
parent 9334a0dcf6
commit fb59b60761
10 changed files with 55 additions and 34 deletions

View File

@@ -37,10 +37,10 @@ const PromptTemplate = ({
: {})}
onClick={() => setSelectTemplateTitle(item)}
>
<Box color={'myGray.900'}>{item.title}</Box>
<Box color={'myGray.900'}>{t(item.title as any)}</Box>
<Box color={'myGray.500'} fontSize={'xs'} whiteSpace={'pre-wrap'}>
{item.desc}
{t(item.desc as any)}
</Box>
</Box>
))}

View File

@@ -415,7 +415,7 @@ const MenuRender = React.memo(function MenuRender({
leftIcon={<MyIcon name={item.icon as any} w={'13px'} />}
onClick={item.onClick}
>
{item.label}
{t(item.label as any)}
</Button>
</Box>
))}

View File

@@ -3,14 +3,15 @@ import type { RenderInputProps } from '../type';
import { Input } from '@chakra-ui/react';
import { useContextSelector } from 'use-context-selector';
import { WorkflowContext } from '@/pages/app/detail/components/WorkflowComponents/context';
import { useTranslation } from 'next-i18next';
const TextInput = ({ item, nodeId }: RenderInputProps) => {
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
const { t } = useTranslation();
const Render = useMemo(() => {
return (
<Input
placeholder={item.placeholder ?? item.description}
placeholder={t(item.placeholder as any) ?? t(item.description as any)}
defaultValue={item.value}
bg={'white'}
px={3}
@@ -28,7 +29,7 @@ const TextInput = ({ item, nodeId }: RenderInputProps) => {
}}
/>
);
}, [item, nodeId, onChangeNode]);
}, [item, nodeId, onChangeNode, t]);
return Render;
};

View File

@@ -3,6 +3,7 @@ import { Box } from '@chakra-ui/react';
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import React from 'react';
import { useTranslation } from 'next-i18next';
const ValueTypeLabel = ({
valueType,
@@ -12,7 +13,7 @@ const ValueTypeLabel = ({
valueDesc?: string;
}) => {
const valueTypeData = valueType ? FlowValueTypeMap[valueType] : undefined;
const { t } = useTranslation();
const label = valueTypeData?.label || '';
return !!label ? (
@@ -29,7 +30,7 @@ const ValueTypeLabel = ({
alignItems={'center'}
fontSize={'11px'}
>
{label}
{t(label as any)}
</Box>
</MyTooltip>
) : null;