Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addition i18n #2631

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions packages/global/core/ai/prompt/AIChat.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PromptTemplateItem } from '../type.d';

import { i18nT } from '../../../../web/i18n/utils';
export const Prompt_QuoteTemplateList: PromptTemplateItem[] = [
{
title: '标准模板',
desc: '标准提示词,用于结构不固定的知识库。',
title: i18nT('app:template.standard_template'),
desc: i18nT('app:template.standard_template_des'),
value: `{{q}}
{{a}}`
},
{
title: '问答模板',
desc: '适合 QA 问答结构的知识库,可以让AI较为严格的按预设内容回答',
title: i18nT('app:template.qa_template'),
desc: i18nT('app:template.qa_template_des'),
value: `<Question>
{{q}}
</Question>
Expand All @@ -18,14 +18,14 @@ export const Prompt_QuoteTemplateList: PromptTemplateItem[] = [
</Answer>`
},
{
title: '标准严格模板',
desc: '在标准模板基础上,对模型的回答做更严格的要求。',
title: i18nT('app:template.standard_strict'),
desc: i18nT('app:template.standard_strict_des'),
value: `{{q}}
{{a}}`
},
{
title: '严格问答模板',
desc: '在问答模板基础上,对模型的回答做更严格的要求。',
title: i18nT('app:template.hard_strict'),
desc: i18nT('app:template.hard_strict_des'),
value: `<Question>
{{q}}
</Question>
Expand All @@ -37,7 +37,7 @@ export const Prompt_QuoteTemplateList: PromptTemplateItem[] = [

export const Prompt_QuotePromptList: PromptTemplateItem[] = [
{
title: '标准模板',
title: i18nT('app:template.standard_template'),
desc: '',
value: `使用 <Data></Data> 标记中的内容作为你的知识:

Expand All @@ -55,7 +55,7 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
问题:"""{{question}}"""`
},
{
title: '问答模板',
title: i18nT('app:template.qa_template'),
desc: '',
value: `使用 <QA></QA> 标记中的问答对进行回答。

Expand All @@ -72,7 +72,7 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
问题:"""{{question}}"""`
},
{
title: '标准严格模板',
title: i18nT('app:template.standard_strict'),
desc: '',
value: `忘记你已有的知识,仅使用 <Data></Data> 标记中的内容作为你的知识:

Expand All @@ -94,7 +94,7 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
问题:"""{{question}}"""`
},
{
title: '严格问答模板',
title: i18nT('app:template.hard_strict'),
desc: '',
value: `忘记你已有的知识,仅使用 <QA></QA> 标记中的问答对进行回答。

Expand Down
12 changes: 6 additions & 6 deletions packages/global/core/workflow/node/constant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WorkflowIOValueTypeEnum } from '../constants';

import { i18nT } from '../../../../web/i18n/utils';
export enum FlowNodeInputTypeEnum { // render ui
reference = 'reference', // reference to other node output
input = 'input', // one line input
Expand Down Expand Up @@ -167,23 +167,23 @@ export const FlowValueTypeMap = {
value: WorkflowIOValueTypeEnum.any
},
[WorkflowIOValueTypeEnum.chatHistory]: {
label: '历史记录',
label: i18nT('common:core.chat.History'),
value: WorkflowIOValueTypeEnum.chatHistory
},
[WorkflowIOValueTypeEnum.datasetQuote]: {
label: '知识库引用',
label: i18nT('common:core.workflow.Dataset quote'),
value: WorkflowIOValueTypeEnum.datasetQuote
},
[WorkflowIOValueTypeEnum.selectApp]: {
label: '选择应用',
label: i18nT('common:plugin.App'),
value: WorkflowIOValueTypeEnum.selectApp
},
[WorkflowIOValueTypeEnum.selectDataset]: {
label: '选择知识库',
label: i18nT('common:core.chat.Select dataset'),
value: WorkflowIOValueTypeEnum.selectDataset
},
[WorkflowIOValueTypeEnum.dynamic]: {
label: '动态输入',
label: i18nT('common:core.workflow.dynamic_input'),
value: WorkflowIOValueTypeEnum.dynamic
}
};
Expand Down
17 changes: 13 additions & 4 deletions packages/web/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"confirm_delete_folder_tip": "Confirm to delete this folder? All apps and corresponding conversation records under it will be deleted. Please confirm!",
"copy_one_app": "Create Duplicate",
"create_copy_success": "Duplicate Created Successfully",
"create_empty_app": "Create Blank App",
"create_empty_plugin": "Create Blank Plugin",
"create_empty_workflow": "Create Blank Workflow",
"create_empty_app": "Create Default App",
"create_empty_plugin": "Create Default Plugin",
"create_empty_workflow": "Create Default Workflow",
"cron": {
"every_day": "Run Daily",
"every_month": "Run Monthly",
Expand Down Expand Up @@ -108,6 +108,15 @@
"template": {
"simple_robot": "Simple Robot"
},
"template.hard_strict": "Strict Q&A template",
"template.hard_strict_des": "Based on the question and answer template, stricter requirements are imposed on the model's answers.",
"template.qa_template": "Q&A template",
"template.qa_template_des": "A knowledge base suitable for QA question and answer structure, which allows AI to answer strictly according to preset content",
"template.simple_robot": "Simple robot",
"template.standard_strict": "Standard strict template",
"template.standard_strict_des": "Based on the standard template, stricter requirements are imposed on the model's answers.",
"template.standard_template": "Standard template",
"template.standard_template_des": "Standard prompt words for knowledge bases with unfixed structures.",
"templateMarket": {
"Search_template": "Search Template",
"Template_market": "Template Market",
Expand Down Expand Up @@ -182,4 +191,4 @@
"user_select": "User Selection",
"user_select_tip": "This module can configure multiple options for selection during the dialogue. Different options can lead to different workflow branches."
}
}
}
3 changes: 2 additions & 1 deletion packages/web/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
"Random": "Divergent",
"Search team tags": "Search Tags",
"Select TTS": "Select Voice Playback Mode",
"Select app from template": "Select from Template",
"Select app from template": "Template",
"Select quote template": "Select Quote Prompt Template",
"Set a name for your app": "Set a Name for Your App",
"Setting ai property": "Click to Configure AI Model Properties",
Expand Down Expand Up @@ -957,6 +957,7 @@
"Run result": "Run Result",
"Show result": "Show Result"
},
"dynamic_input": "dynamic input",
"inputType": {
"JSON Editor": "JSON Input Box",
"Manual input": "Manual Input",
Expand Down
12 changes: 10 additions & 2 deletions packages/web/i18n/zh/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@
"setting_app": "应用配置",
"setting_plugin": "插件配置",
"template": {
"simple_robot": "简易机器人"
"simple_robot": "简易机器人",
"standard_template": "标准模板",
"standard_template_des": "标准提示词,用于结构不固定的知识库。",
"qa_template": "问答模板",
"qa_template_des": "适合 QA 问答结构的知识库,可以让AI较为严格的按预设内容回答",
"standard_strict": "标准严格模板",
"standard_strict_des": "在标准模板基础上,对模型的回答做更严格的要求。",
"hard_strict": "严格问答模板",
"hard_strict_des": "在问答模板基础上,对模型的回答做更严格的要求。"
},
"templateMarket": {
"Search_template": "搜索模板",
Expand Down Expand Up @@ -182,4 +190,4 @@
"manage": "写权限基础上,可配置发布渠道、查看对话日志、分配该应用权限"
}
}
}
}
1 change: 1 addition & 0 deletions packages/web/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@
},
"view_chat_detail": "查看对话详情",
"workflow": {
"dynamic_input": "动态输入",
"Can not delete node": "该节点不允许删除",
"Change input type tip": "修改输入类型会清空已填写的值,请确认!",
"Check Failed": "工作流校验失败,请检查节点是否正确填值,以及连线是否正常",
Expand Down
4 changes: 2 additions & 2 deletions projects/app/src/components/PromptTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -28,7 +29,7 @@ const TextInput = ({ item, nodeId }: RenderInputProps) => {
}}
/>
);
}, [item, nodeId, onChangeNode]);
}, [item, nodeId, onChangeNode, t]);

return Render;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,7 +13,7 @@ const ValueTypeLabel = ({
valueDesc?: string;
}) => {
const valueTypeData = valueType ? FlowValueTypeMap[valueType] : undefined;

const { t } = useTranslation();
const label = valueTypeData?.label || '';

return !!label ? (
Expand All @@ -29,7 +30,7 @@ const ValueTypeLabel = ({
alignItems={'center'}
fontSize={'11px'}
>
{label}
{t(label as any)}
</Box>
</MyTooltip>
) : null;
Expand Down
Loading