fix i18next.d.ts (#2064)

* fix i18next.d.ts

* feat: packages web i18n

* delete file
This commit is contained in:
jingyang
2024-07-17 15:27:51 +08:00
committed by GitHub
parent 36f8755d09
commit 982325d066
75 changed files with 216 additions and 204 deletions

View File

@@ -103,7 +103,7 @@ const DateRangePicker = ({
mr={2}
onClick={() => setShowSelected(false)}
>
{t('common.Close')}
{t('common:common.Close')}
</Button>
<Button
size={'sm'}
@@ -112,7 +112,7 @@ const DateRangePicker = ({
setShowSelected(false);
}}
>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</Flex>
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ const CodeEditor = (props: Props) => {
isOpen={isOpen}
onClose={onClose}
iconSrc="modal/edit"
title={t('Code editor')}
title={t('common:Code editor')}
w={'full'}
>
<ModalBody>
@@ -25,7 +25,7 @@ const CodeEditor = (props: Props) => {
</ModalBody>
<ModalFooter>
<Button mr={2} onClick={onClose} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>

View File

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

View File

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

View File

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

View File

@@ -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: []
},
{

View File

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

View File

@@ -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'
}
@@ -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,
@@ -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

View File

@@ -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;
@@ -116,7 +116,7 @@ export const useEditTextarea = ({
</Button>
)}
<Button onClick={onclickConfirm} px={6}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>

View File

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

View File

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

View File

@@ -82,8 +82,7 @@
"No data": "No data available"
},
"Name": "Name",
"Name Can": "Name cannot be empty",
"Name is empty": "Name cannot be empty",
"name_is_empty": "Name cannot be empty",
"Next Step": "Next Step",
"No more data": "No more data~",
"Not open": "Not open",
@@ -864,6 +863,7 @@
"http": {
"Add props": "Add parameters",
"AppId": "Application ID",
"AppSecret": "AppSecret",
"ChatId": "Current chat ID",
"Current time": "Current time",
"Histories": "Last 10 chat records",
@@ -1294,6 +1294,8 @@
"path": "Path",
"update params": "Update parameters"
},
"select_reference_variable": "Select Reference Variable",
"share_link": "Share Link",
"support": {
"account": {
"Individuation": "Personalization"
@@ -1519,10 +1521,13 @@
}
}
},
"sync_link": "Sync Link",
"system": {
"Concat us": "Concat",
"Help Document": "Help document"
},
"tag_list": "Tag List",
"team_tag": "Team Tag",
"template": {
"Quote Content Tip": "You can customize the structure of the quote content to better adapt to different scenarios. You can use some variables for template configuration:\n{{q}} - search content, {{a}} - expected content, {{source}} - source, {{sourceId}} - source file name, {{index}} - the nth quote, they are all optional, here are the default values:\n{{default}}",
"Quote Prompt Tip": "You can use {{quote}} to insert the quote content template, and use {{question}} to insert the question. Here are the default values:\n{{default}}"

View File

@@ -82,8 +82,7 @@
"No data": "没有可选值"
},
"Name": "名称",
"Name Can": "名称不能为空",
"Name is empty": "名称不能为空",
"name_is_empty": "名称不能为空",
"Next Step": "下一步",
"No more data": "没有更多了~",
"Not open": "未开启",
@@ -873,6 +872,7 @@
"http": {
"Add props": "添加参数",
"AppId": "应用 ID",
"AppSecret": "AppSecret",
"ChatId": "当前对话 ID",
"Current time": "当前时间",
"Histories": "最近 10 条聊天记录",
@@ -1303,6 +1303,8 @@
"path": "",
"update params": "更新参数"
},
"select_reference_variable": "选择引用变量",
"share_link": "分享链接",
"support": {
"account": {
"Individuation": "个性化"
@@ -1528,10 +1530,13 @@
}
}
},
"sync_link": "同步链接",
"system": {
"Concat us": "联系我们",
"Help Document": "帮助文档"
},
"tag_list": "标签列表",
"team_tag": "团队标签",
"template": {
"Quote Content Tip": "可以自定义引用内容的结构,以更好的适配不同场景。可以使用一些变量来进行模板配置:\n{{q}} - 检索内容,{{a}} - 预期内容,{{source}} - 来源,{{sourceId}} - 来源文件名,{{index}} - 第 n 个引用,他们都是可选的,下面是默认值:\n{{default}}",
"Quote Prompt Tip": "可以用 {{quote}} 来插入引用内容模板,使用 {{question}} 来插入问题。下面是默认值:\n{{default}}"

38
packages/web/types/i18next.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
import 'i18next';
import common from '../i18n/zh/common.json';
import dataset from '../i18n/zh/dataset.json';
import app from '../i18n/zh/app.json';
import file from '../i18n/zh/file.json';
import publish from '../i18n/zh/publish.json';
import workflow from '../i18n/zh/workflow.json';
import user from '../i18n/zh/user.json';
import chat from '../i18n/zh/chat.json';
export interface I18nNamespaces {
common: typeof common;
dataset: typeof dataset;
app: typeof app;
file: typeof file;
publish: typeof publish;
workflow: typeof workflow;
user: typeof user;
chat: typeof chat;
}
export type I18nNsType = (keyof I18nNamespaces)[];
export type I18nCommonKey = keyof I18nNamespaces['common'];
export type I18nDataSetKey = keyof I18nNamespaces['dataset'];
export type I18nAppKey = keyof I18nNamespaces['app'];
export type I18nPublishKey = keyof I18nNamespaces['publish'];
export type I18nWorkflowKey = keyof I18nNamespaces['workflow'];
export type I18nUserKey = keyof I18nNamespaces['user'];
export type I18nChatKey = keyof I18nNamespaces['chat'];
declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false;
defaultNS: ['common', 'dataset', 'app', 'file', 'publish', 'workflow', 'user', 'chat'];
resources: I18nNamespaces;
}
}