I18n: Completed i18n&&proofread some translations (#2619)

* i18n-1

* i18n: Completed the remaining parts of i18n and proofread some translations

* i18n: add default lang&&add app template i18n
This commit is contained in:
papapatrick
2024-09-05 17:29:36 +08:00
committed by GitHub
parent b4238257b6
commit dfcffc7fc1
30 changed files with 1590 additions and 1546 deletions

View File

@@ -4,7 +4,7 @@ import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import type { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types/index.d';
import { change2DefaultLng, setLngStore } from '@/web/common/utils/i18n';
import { change2DefaultLng, LangEnum, setLngStore } from '@/web/common/utils/i18n';
import { useMemoizedFn, useMount } from 'ahooks';
import { TrackEventName } from '../common/system/constants';
@@ -40,11 +40,13 @@ export const useInitApp = () => {
const initUserLanguage = useMemoizedFn(() => {
// get default language
const targetLng = change2DefaultLng(i18n.language);
if (targetLng) {
setLngStore(targetLng);
router.replace(router.asPath, undefined, { locale: targetLng });
}
const targetLng =
change2DefaultLng(i18n.language) ||
(['zh', 'zh-CN'].includes(navigator.language) ? 'zh' : 'en');
setLngStore(targetLng);
router.replace(router.asPath, undefined, { locale: targetLng });
});
useMount(() => {

View File

@@ -32,8 +32,8 @@ export const emptyTemplates: Record<
nodes: [
{
nodeId: 'userGuide',
name: '系统配置',
intro: '可以配置应用的系统参数',
name: i18nT('common:core.module.template.system_config'),
intro: i18nT('common:core.module.template.config_params'),
avatar: 'core/workflow/template/systemConfig',
flowNodeType: FlowNodeTypeEnum.systemConfig,
position: {
@@ -95,7 +95,7 @@ export const emptyTemplates: Record<
},
{
nodeId: '448745',
name: '流程开始',
name: i18nT('common:core.module.template.work_start'),
intro: '',
avatar: 'core/workflow/template/workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
@@ -109,9 +109,9 @@ export const emptyTemplates: Record<
key: 'userChatInput',
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
valueType: WorkflowIOValueTypeEnum.string,
label: '用户问题',
label: i18nT('common:core.module.input.label.user question'),
required: true,
toolDescription: '用户问题'
toolDescription: i18nT('common:core.module.input.label.user question')
}
],
outputs: [
@@ -126,8 +126,8 @@ export const emptyTemplates: Record<
},
{
nodeId: 'loOvhld2ZTKa',
name: 'AI 对话',
intro: 'AI 大模型对话',
name: i18nT('common:core.module.template.ai_chat'),
intro: i18nT('common:core.module.template.ai_chat_intro'),
avatar: 'core/workflow/template/aiChat',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
@@ -210,16 +210,16 @@ export const emptyTemplates: Record<
key: 'userChatInput',
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
valueType: WorkflowIOValueTypeEnum.string,
label: '用户问题',
label: i18nT('common:core.module.input.label.user question'),
required: true,
toolDescription: '用户问题',
toolDescription: i18nT('common:core.module.input.label.user question'),
value: ['448745', 'userChatInput']
},
{
key: 'quoteQA',
renderTypeList: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt],
label: '',
debugLabel: '知识库引用',
debugLabel: i18nT('common:core.module.Dataset quote.label'),
description: '',
valueType: WorkflowIOValueTypeEnum.datasetQuote
}
@@ -255,12 +255,12 @@ export const emptyTemplates: Record<
},
[AppTypeEnum.workflow]: {
avatar: 'core/app/type/workflowFill',
name: '空白工作流',
name: i18nT('common:core.module.template.empty_workflow'),
nodes: [
{
nodeId: 'userGuide',
name: '系统配置',
intro: '可以配置应用的系统参数',
name: i18nT('common:core.module.template.system_config'),
intro: i18nT('common:core.module.template.system_config_info'),
avatar: 'core/workflow/template/systemConfig',
flowNodeType: 'userGuide',
position: {
@@ -322,7 +322,7 @@ export const emptyTemplates: Record<
},
{
nodeId: '448745',
name: '流程开始',
name: i18nT('common:core.module.template.work_start'),
intro: '',
avatar: 'core/workflow/template/workflowStart',
flowNodeType: 'workflowStart',
@@ -336,9 +336,9 @@ export const emptyTemplates: Record<
key: 'userChatInput',
renderTypeList: ['reference', 'textarea'],
valueType: 'string',
label: '用户问题',
label: i18nT('common:core.module.input.label.user question'),
required: true,
toolDescription: '用户问题'
toolDescription: i18nT('common:core.module.input.label.user question')
}
],
outputs: [
@@ -356,11 +356,11 @@ export const emptyTemplates: Record<
},
[AppTypeEnum.plugin]: {
avatar: 'core/app/type/pluginFill',
name: '空白插件',
name: i18nT('common:core.module.template.empty_plugin'),
nodes: [
{
nodeId: 'pluginInput',
name: '自定义插件输入',
name: i18nT('common:core.module.template.self_input'),
avatar: 'core/workflow/template/workflowStart',
flowNodeType: FlowNodeTypeEnum.pluginInput,
showStatus: false,
@@ -374,7 +374,7 @@ export const emptyTemplates: Record<
},
{
nodeId: 'pluginOutput',
name: '自定义插件输出',
name: i18nT('common:core.module.template.self_output'),
avatar: '/imgs/workflow/output.png',
flowNodeType: FlowNodeTypeEnum.pluginOutput,
showStatus: false,

View File

@@ -162,16 +162,16 @@ export function form2AppWorkflow(
key: 'userChatInput',
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
valueType: WorkflowIOValueTypeEnum.string,
label: '用户问题',
label: i18nT('common:core.module.input.label.user question'),
required: true,
toolDescription: '用户问题',
toolDescription: i18nT('common:core.module.input.label.user question'),
value: [workflowStartNodeId, 'userChatInput']
},
{
key: 'quoteQA',
renderTypeList: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt],
label: '',
debugLabel: '知识库引用',
debugLabel: i18nT('common:core.module.Dataset quote.label'),
description: '',
valueType: WorkflowIOValueTypeEnum.datasetQuote,
value: selectedDatasets ? [datasetNodeId, 'quoteQA'] : undefined
@@ -467,7 +467,7 @@ export function form2AppWorkflow(
key: 'userChatInput',
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
valueType: WorkflowIOValueTypeEnum.string,
label: '用户问题',
label: i18nT('common:core.module.input.label.user question'),
required: true,
value: [workflowStartNodeId, 'userChatInput']
},