Skip to content

Commit

Permalink
feat: packages web i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Jul 17, 2024
1 parent 6838789 commit ec0e556
Show file tree
Hide file tree
Showing 75 changed files with 234 additions and 171 deletions.
4 changes: 2 additions & 2 deletions packages/web/components/common/DateRangePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const DateRangePicker = ({
mr={2}
onClick={() => setShowSelected(false)}
>
{t('common.Close')}
{t('common:common.Close')}
</Button>
<Button
size={'sm'}
Expand All @@ -112,7 +112,7 @@ const DateRangePicker = ({
setShowSelected(false);
}}
>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</Flex>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/EmptyTip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const EmptyTip = ({ text, ...props }: Props) => {
<Flex mt={5} flexDirection={'column'} alignItems={'center'} py={'10vh'} {...props}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'} fontSize={'sm'}>
{text || t('common.empty.Common Tip')}
{text || t('common:common.empty.Common Tip')}
</Box>
</Flex>
);
Expand Down
10 changes: 5 additions & 5 deletions packages/web/components/common/MyModal/EditFolderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const EditFolderModal = ({
() =>
isEdit
? {
title: t('dataset.Edit Folder')
title: t('common:dataset.Edit Folder')
}
: {
title: t('dataset.Create Folder')
title: t('common:dataset.Create Folder')
},
[isEdit, t]
);
Expand All @@ -67,7 +67,7 @@ const EditFolderModal = ({
<MyModal isOpen onClose={onClose} iconSrc="common/folderFill" title={typeMap.title}>
<ModalBody>
<Box>
<FormLabel mb={1}>{t('common.Input name')}</FormLabel>
<FormLabel mb={1}>{t('common:common.Input name')}</FormLabel>
<Input
{...register('name', { required: true })}
bg={'myGray.50'}
Expand All @@ -76,13 +76,13 @@ const EditFolderModal = ({
/>
</Box>
<Box mt={4}>
<FormLabel mb={1}>{t('common.Input folder description')}</FormLabel>
<FormLabel mb={1}>{t('common:common.Input folder description')}</FormLabel>
<Textarea {...register('intro')} bg={'myGray.50'} maxLength={200} />
</Box>
</ModalBody>
<ModalFooter>
<Button isLoading={loading} onClick={handleSubmit(onSave)} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>
Expand Down
4 changes: 2 additions & 2 deletions packages/web/components/common/MyPopover/PopoverConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ const PopoverConfirm = ({
<HStack mt={1} justifyContent={'flex-end'}>
{showCancel && (
<Button variant={'whiteBase'} size="sm" onClick={onClose}>
{t('common.Cancel')}
{t('common:common.Cancel')}
</Button>
)}
<Button isLoading={loading} variant={map.variant} size="sm" onClick={onclickConfirm}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</HStack>
</PopoverContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ const MultipleRowSelect = ({
</Flex>
))}
{list.length === 0 && (
<EmptyTip text={emptyTip ?? t('common.MultipleRowSelect.No data')} pt={1} pb={3} />
<EmptyTip
text={emptyTip ?? t('common:common.MultipleRowSelect.No data')}
pt={1}
pb={3}
/>
)}
</Box>
{children.length > 0 && <RenderList list={children} index={index + 1} />}
Expand Down
6 changes: 3 additions & 3 deletions packages/web/components/common/Radio/LeftRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ const LeftRadio = ({
whiteSpace={'nowrap'}
fontSize={'sm'}
>
{typeof item.title === 'string' ? t(item.title) : item.title}
{typeof item.title === 'string' ? t(item.title as any) : item.title}
</Box>
{!!item.tooltip && <QuestionTip label={item.tooltip} ml={1} color={'myGray.600'} />}
</Flex>
{!!item.tooltip && <QuestionTip label={item.tooltip} ml={1} color={'myGray.600'} />}
{!!item.desc && (
<Box fontSize={'xs'} color={'myGray.500'} lineHeight={1.2}>
{t(item.desc)}
{t(item.desc as any)}
</Box>
)}
{item?.children}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/Tabs/LightRowTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const LightRowTabs = <ValueType = string,>({
)}
</>
)}
{typeof item.label === 'string' ? t(item.label) : item.label}
{typeof item.label === 'string' ? t(item.label as any) : item.label}
</Flex>
))}
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions packages/web/components/common/Textarea/CodeEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const CodeEditor = (props: Props) => {
isOpen={isOpen}
onClose={onClose}
iconSrc="modal/edit"
title={t('Code editor')}
title={t('common:Code editor')}
w={'full'}
>
<ModalBody>
<MyEditor {...props} bg={'myGray.50'} defaultHeight={600} />
</ModalBody>
<ModalFooter>
<Button mr={2} onClick={onClose} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const JSONEditor = ({
} catch (error) {
toast({
status: 'warning',
title: t('common.jsonEditor.Parse error')
title: t('common:common.jsonEditor.Parse error')
});
}
}, [value]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const PromptEditor = ({
</ModalBody>
<ModalFooter>
<Button mr={2} onClick={onClose} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>
Expand Down
32 changes: 16 additions & 16 deletions packages/web/components/core/workflow/NodeInputSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NodeInputSelect = ({
}) => {
const { t } = useTranslation();
const { openConfirm, ConfirmModal } = useConfirm({
title: t('core.workflow.Change input type tip')
title: t('common:core.workflow.Change input type tip')
});
const renderType = renderTypeList[renderTypeIndex];
const theme = useTheme();
Expand All @@ -29,90 +29,90 @@ const NodeInputSelect = ({
{
type: FlowNodeInputTypeEnum.reference,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.reference].icon,
title: t('core.workflow.inputType.Reference')
title: t('common:core.workflow.inputType.Reference')
},
{
type: FlowNodeInputTypeEnum.input,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.input].icon,
title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.numberInput,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.numberInput].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.switch,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.switch].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.textarea,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.textarea].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.JSONEditor,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.JSONEditor].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.addInputParam,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.addInputParam].icon,

title: t('core.workflow.inputType.dynamicTargetInput')
title: t('common:core.workflow.inputType.dynamicTargetInput')
},
{
type: FlowNodeInputTypeEnum.selectApp,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.selectApp].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.selectLLMModel,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.selectLLMModel].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.settingLLMModel,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.settingLLMModel].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.selectDataset,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.selectDataset].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.selectDatasetParamsModal].icon,

title: t('core.workflow.inputType.Manual select')
title: t('common:core.workflow.inputType.Manual select')
},
{
type: FlowNodeInputTypeEnum.settingDatasetQuotePrompt,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.settingDatasetQuotePrompt].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.hidden,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.hidden].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
},
{
type: FlowNodeInputTypeEnum.custom,
icon: FlowNodeInputMap[FlowNodeInputTypeEnum.custom].icon,

title: t('core.workflow.inputType.Manual input')
title: t('common:core.workflow.inputType.Manual input')
}
]);

Expand Down
8 changes: 4 additions & 4 deletions packages/web/core/workflow/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { TFunction } from 'next-i18next';
export const workflowNodeTemplateList = (t: TFunction): NodeTemplateListType => [
{
type: FlowNodeTemplateTypeEnum.systemInput,
label: t('core.module.template.System input module'),
label: t('common:core.module.template.System input module'),
list: []
},
{
type: FlowNodeTemplateTypeEnum.ai,
label: t('core.module.template.AI function'),
label: t('common:core.module.template.AI function'),
list: []
},
{
type: FlowNodeTemplateTypeEnum.tools,
label: t('core.module.template.Tool module'),
label: t('common:core.module.template.Tool module'),
list: []
},
{
type: FlowNodeTemplateTypeEnum.other,
label: t('common.Other'),
label: t('common:common.Other'),
list: []
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/web/hooks/useBeforeunload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect } from 'react';
export const useBeforeunload = (props?: { callback?: () => any; tip?: string }) => {
const { t } = useTranslation();

const { tip = t('common.Confirm to leave the page'), callback } = props || {};
const { tip = t('common:common.Confirm to leave the page'), callback } = props || {};

useEffect(() => {
const listen =
Expand Down
10 changes: 5 additions & 5 deletions packages/web/hooks/useConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const useConfirm = (props?: {
const map = useMemo(() => {
const map = {
common: {
title: t('common.confirm.Common Tip'),
title: t('common:common.confirm.Common Tip'),
variant: 'primary',
iconSrc: 'common/confirm/commonTip'
},
delete: {
title: t('common.Delete Warning'),
title: t('common:common.Delete Warning'),
variant: 'dangerFill',
iconSrc: 'common/confirm/deleteTip'
}
Expand All @@ -31,7 +31,7 @@ export const useConfirm = (props?: {
}, [props?.type, t]);

const {
title = map?.title || t('Warning'),
title = map?.title || t('common:Warning'),
iconSrc = map?.iconSrc,
content,
showCancel = true,
Expand All @@ -58,8 +58,8 @@ export const useConfirm = (props?: {

const ConfirmModal = useCallback(
({
closeText = t('common.Cancel'),
confirmText = t('common.Confirm'),
closeText = t('common:common.Cancel'),
confirmText = t('common:common.Confirm'),
isLoading,
bg,
countDown = 0
Expand Down
4 changes: 2 additions & 2 deletions packages/web/hooks/useEditTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const useEditTextarea = ({
({
maxLength = 30,
iconSrc = 'modal/edit',
closeBtnText = t('common.Close')
closeBtnText = t('common:common.Close')
}: {
maxLength?: number;
iconSrc?: string;
Expand Down Expand Up @@ -116,7 +116,7 @@ export const useEditTextarea = ({
</Button>
)}
<Button onClick={onclickConfirm} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>
Expand Down
4 changes: 2 additions & 2 deletions packages/web/hooks/useRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...pr
onError?.(err, variables, context);

if (errorToast !== undefined) {
const errText = t(getErrText(err, errorToast || ''));
const errText = t(getErrText(err, errorToast || '') as any);
if (errText) {
toast({
title: errText,
Expand Down Expand Up @@ -64,7 +64,7 @@ export const useRequest2 = <TData, TParams extends any[]>(
onError: (err, params) => {
rest?.onError?.(err, params);
if (errorToast !== undefined) {
const errText = t(getErrText(err, errorToast || ''));
const errText = t(getErrText(err, errorToast || '') as any);
if (errText) {
toast({
title: errText,
Expand Down
2 changes: 1 addition & 1 deletion packages/web/hooks/useScrollPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function useScrollPagination<
<Box ref={wrapperRef}>{children}</Box>
{noMore.current && list.length > 0 && (
<Box py={4} textAlign={'center'} color={'myGray.600'} fontSize={'xs'}>
{t('common.No more data')}
{t('common:common.No more data')}
</Box>
)}
{list.length === 0 && !isLoading && EmptyChildren && <>{EmptyChildren}</>}
Expand Down
Loading

0 comments on commit ec0e556

Please sign in to comment.