diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts
index be95b0892..ab0a13d89 100644
--- a/packages/core/client/src/locale/zh_CN.ts
+++ b/packages/core/client/src/locale/zh_CN.ts
@@ -32,6 +32,7 @@ export default {
"Insert inner": "在里面插入",
"Delete": "删除",
"UI editor": "界面配置",
+ "Collection": "数据表",
"Collections & Fields": "数据表配置",
"Roles & Permissions": "角色和权限",
"Edit profile": "个人资料",
@@ -153,6 +154,10 @@ export default {
"is not": "不等于",
"contains": "包含",
"does not contain": "不包含",
+ "starts with": "开头是",
+ "not starts with": "开头不是",
+ "ends with": "结尾是",
+ "not ends with": "结尾不是",
"is empty": "为空",
"is not empty": "不为空",
"Edit chart": "编辑图表",
@@ -300,8 +305,8 @@ export default {
'Insert before': '在前面插入',
'Insert after': '在后面插入',
'UI Editor': '界面配置',
- 'ASC': 'ASC',
- 'DESC': 'DESC',
+ 'ASC': '升序',
+ 'DESC': '降序',
'Add sort field': '添加排序字段',
'ID': 'ID',
'Drawer': '抽屉',
@@ -399,4 +404,60 @@ export default {
'Local storage': '本地存储',
'Aliyun OSS': '阿里云 OSS',
'Amazon S3': '亚马逊 S3',
+
+ // plugins/workflow
+ 'Workflow': '工作流',
+ 'Configure workflow': '流程配置',
+ 'Executions': '执行历史',
+ 'Trigger type': '触发方式',
+ 'Description': '描述',
+ 'Status': '状态',
+ 'Enabled': '启用',
+ 'Disabled': '禁用',
+ 'Trigger configuration': '触发器配置',
+ 'Load failed': '加载失败',
+
+ 'Model event': '数据表事件',
+ 'Trigger on': '触发时机',
+ 'After record added': '新增数据后',
+ 'After record updated': '更新数据后',
+ 'After record added or updated': '新增或更新数据后',
+ 'After record deleted': '删除数据后',
+ 'Changed fields': '发生变动的字段',
+ 'Select the fields which changed will trigger the event only': '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。',
+ 'Match condition': '满足条件',
+
+ 'End': '结束',
+
+ 'Trigger context': '触发数据',
+ 'Node result': '节点数据',
+ 'Constant': '常量',
+
+ 'Boolean': '逻辑值',
+ 'String': '字符串',
+
+ 'Comparison': '值比较',
+ 'Arithmetic calculation': '算术运算',
+ 'String operation': '字符串',
+
+ 'On going': '进行中',
+ 'Success': '成功',
+ 'Failed': '失败',
+ 'Canceled': '已取消',
+
+ 'Node configuration': '配置节点',
+ 'This node contains branches, deleting will also be preformed to them, are you sure?': '节点包含分支,将同时删除其所有分支下的子节点,确定继续?',
+
+ 'Control': '流程控制',
+ 'Collection operations': '数据表操作',
+
+ 'Node type': '节点类型',
+
+ 'Calculation': '运算',
+ 'Configure calculation': '配置运算',
+ 'Calculation result': '运算结果',
+
+ 'Create record': '新增数据',
+ 'Update record': '更新数据',
+ 'Query record': '查询数据',
}
diff --git a/packages/core/client/src/workflow/WorkflowCanvas.tsx b/packages/core/client/src/workflow/WorkflowCanvas.tsx
index b1c50edde..721d53f36 100644
--- a/packages/core/client/src/workflow/WorkflowCanvas.tsx
+++ b/packages/core/client/src/workflow/WorkflowCanvas.tsx
@@ -6,9 +6,12 @@ import { addButtonClass, branchBlockClass, branchClass, nodeBlockClass, nodeCard
import {
useCollection,
+ useCompile,
useResourceActionContext
} from '..';
import { Instruction, instructions, Node } from './nodes';
+import { t } from 'i18next';
+import { useTranslation } from 'react-i18next';
@@ -34,10 +37,11 @@ export function useFlowContext() {
}
export function WorkflowCanvas() {
+ const { t } = useTranslation();
const { data, refresh, loading } = useResourceActionContext();
if (!data?.data && !loading) {
- return
加载失败
;
+ return {t('Load failed')}
;
}
const { nodes = [], ...workflow } = data?.data ?? {};
@@ -56,7 +60,7 @@ export function WorkflowCanvas() {
- 结束
+ {t('End')}
);
}
@@ -93,6 +97,7 @@ interface AddButtonProps {
};
export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
+ const compile = useCompile();
const { resource } = useCollection();
const { data } = useResourceActionContext();
const { onNodeAdded } = useFlowContext();
@@ -120,8 +125,8 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
}
const groups = [
- { value: 'control', name: '流程控制' },
- { value: 'model', name: '数据表操作' },
+ { value: 'control', name: '{{t("Control")}}' },
+ { value: 'collection', name: '{{t("Collection operations")}}' },
];
const instructionList = (Array.from(instructions.getValues()) as Instruction[]);
@@ -130,17 +135,17 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) {
onCreate(ev)}>
{groups.map(group => (
-
+
{instructionList.filter(item => item.group === group.value).map(item => item.options
? (
-
+
{item.options.map(option => (
- {option.label}
+ {compile(option.label)}
))}
)
: (
- {item.title}
+ {compile(item.title)}
))}
))}
diff --git a/packages/core/client/src/workflow/WorkflowLink.tsx b/packages/core/client/src/workflow/WorkflowLink.tsx
index f3ac5e16a..6ab518e07 100644
--- a/packages/core/client/src/workflow/WorkflowLink.tsx
+++ b/packages/core/client/src/workflow/WorkflowLink.tsx
@@ -1,12 +1,14 @@
import React from 'react';
+import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { useActionContext, useRecord } from '..';
export const WorkflowLink = () => {
+ const { t } = useTranslation();
const { id } = useRecord();
const { setVisible } = useActionContext();
return (
- setVisible(false)}>流程配置
+ setVisible(false)}>{t('Configure workflow')}
);
}
diff --git a/packages/core/client/src/workflow/WorkflowPage.tsx b/packages/core/client/src/workflow/WorkflowPage.tsx
index 473eee015..aa4bc1268 100644
--- a/packages/core/client/src/workflow/WorkflowPage.tsx
+++ b/packages/core/client/src/workflow/WorkflowPage.tsx
@@ -15,7 +15,7 @@ const workflowCollection = {
name: 'title',
interface: 'input',
uiSchema: {
- title: '流程名称',
+ title: '{{t("Name")}}',
type: 'string',
'x-component': 'Input',
required: true,
@@ -66,7 +66,7 @@ export const WorkflowPage = () => {
name: 'title',
interface: 'input',
uiSchema: {
- title: '节点名称',
+ title: '{{t("Name")}}',
type: 'string',
'x-component': 'Input',
},
@@ -76,7 +76,7 @@ export const WorkflowPage = () => {
name: 'type',
interface: 'select',
uiSchema: {
- title: '节点类型',
+ title: '{{t("Node type")}}',
type: 'string',
'x-component': 'Select',
required: true,
diff --git a/packages/core/client/src/workflow/WorkflowShortcut.tsx b/packages/core/client/src/workflow/WorkflowShortcut.tsx
index 0dd64a986..0b87064e7 100644
--- a/packages/core/client/src/workflow/WorkflowShortcut.tsx
+++ b/packages/core/client/src/workflow/WorkflowShortcut.tsx
@@ -5,6 +5,7 @@ import { uid } from '@formily/shared';
import { PluginManager } from '../plugin-manager';
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
import { WorkflowTable } from './WorkflowTable';
+import { useTranslation } from 'react-i18next';
const useCloseAction = () => {
const { setVisible } = useActionContext();
@@ -25,7 +26,7 @@ const schema: ISchema = {
[uid()]: {
'x-component': 'Action.Drawer',
type: 'void',
- title: '工作流',
+ title: '{{t("Workflow")}}',
properties: {
main: {
type: 'void',
@@ -37,12 +38,13 @@ const schema: ISchema = {
};
export const WorkflowShortcut = () => {
+ const { t } = useTranslation();
const [visible, setVisible] = useState(false);
return (
}
- title={'工作流'}
+ title={t('Workflow')}
onClick={() => {
setVisible(true);
}}
diff --git a/packages/core/client/src/workflow/calculators.tsx b/packages/core/client/src/workflow/calculators.tsx
index f495e9ef0..5c85c5e57 100644
--- a/packages/core/client/src/workflow/calculators.tsx
+++ b/packages/core/client/src/workflow/calculators.tsx
@@ -9,6 +9,7 @@ import { instructions, useNodeContext } from "./nodes";
import { useFlowContext } from "./WorkflowCanvas";
import { triggers } from "./triggers";
import { SchemaComponent, useCollectionManager, useCompile } from "..";
+import { useTranslation } from "react-i18next";
function NullRender() {
return null;
@@ -17,7 +18,7 @@ function NullRender() {
export const calculators = [
{
value: 'boolean',
- title: '值比较',
+ title: '{{t("Comparison")}}',
children: [
{ value: 'equal', name: '=' },
{ value: 'notEqual', name: '≠' },
@@ -29,7 +30,7 @@ export const calculators = [
},
{
value: 'number',
- title: '算术运算',
+ title: '{{t("Arithmetic calculation")}}',
children: [
{ value: 'add', name: '+' },
{ value: 'minus', name: '-' },
@@ -40,19 +41,19 @@ export const calculators = [
},
{
value: 'string',
- title: '字符串',
+ title: '{{t("String operation")}}',
children: [
- { value: 'includes', name: '包含' },
- { value: 'notIncludes', name: '不包含' },
- { value: 'startsWith', name: '开头是' },
- { value: 'notStartsWith', name: '开头不是' },
- { value: 'endsWith', name: '结尾是' },
- { value: 'notEndsWith', name: '结尾不是' }
+ { value: 'includes', name: '{{t("contains")}}' },
+ { value: 'notIncludes', name: '{{t("does not contain")}}' },
+ { value: 'startsWith', name: '{{t("starts with")}}' },
+ { value: 'notStartsWith', name: '{{t("not starts with")}}' },
+ { value: 'endsWith', name: '{{t("ends with")}}' },
+ { value: 'notEndsWith', name: '{{t("not ends with")}}' }
]
},
{
value: 'date',
- title: '日期',
+ title: '{{t("Date")}}',
children: []
}
];
@@ -77,7 +78,7 @@ export const BaseTypeSet = new Set(['boolean', 'number', 'string', 'date']);
const ConstantTypes = {
string: {
- title: '字符串',
+ title: '{{t("String")}}',
value: 'string',
component({ onChange, type, options, value }) {
return (
@@ -90,7 +91,7 @@ const ConstantTypes = {
default: ''
},
number: {
- title: '数字',
+ title: '{{t("Number")}}',
value: 'number',
component({ onChange, type, options, value }) {
return (
@@ -103,7 +104,7 @@ const ConstantTypes = {
default: 0
},
boolean: {
- title: '逻辑值',
+ title: '{{t("Boolean")}}',
value: 'boolean',
component({ onChange, type, options, value }) {
return (
@@ -127,7 +128,7 @@ const ConstantTypes = {
export const VariableTypes = {
constant: {
- title: '常量',
+ title: '{{t("Constant")}}',
value: 'constant',
options: Object.values(ConstantTypes).map(item => ({
value: item.value,
@@ -155,7 +156,7 @@ export const VariableTypes = {
}
},
$jobsMapByNodeId: {
- title: '节点数据',
+ title: '{{t("Node result")}}',
value: '$jobsMapByNodeId',
options() {
const node = useNodeContext();
@@ -210,7 +211,7 @@ export const VariableTypes = {
}
},
$context: {
- title: '触发数据',
+ title: '{{t("Trigger context")}}',
value: '$context',
component() {
const { workflow } = useFlowContext();
@@ -252,6 +253,7 @@ export function Operand({
onChange,
children
}: OperandProps) {
+ const compile = useCompile();
const Types = useVariableTypes();
const { type } = operand;
@@ -279,7 +281,7 @@ export function Operand({
options={Object.values(Types).map((item: any) => {
const options = typeof item.options === 'function' ? item.options() : item.options;
return {
- label: item.title,
+ label: compile(item.title),
value: item.value,
children: options,
disabled: options && !options.length,
@@ -303,6 +305,7 @@ export function Operand({
}
export function Calculation({ calculator, operands = [], onChange }) {
+ const { t } = useTranslation();
return (