mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 19:38:05 +00:00
fix(react-simulator-renderer): fix missing i18n of customCreateElement
This commit is contained in:
parent
17a0f72457
commit
5c6572e302
4
packages/react-simulator-renderer/src/locale/en-US.json
Normal file
4
packages/react-simulator-renderer/src/locale/en-US.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Drag and drop components or templates here": "Drag and drop components or templates here",
|
||||||
|
"Locked elements and child elements cannot be edited": "Locked elements and child elements cannot be edited"
|
||||||
|
}
|
||||||
21
packages/react-simulator-renderer/src/locale/index.ts
Normal file
21
packages/react-simulator-renderer/src/locale/index.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { createElement } from 'react';
|
||||||
|
import enUS from './en-US.json';
|
||||||
|
import zhCN from './zh-CN.json';
|
||||||
|
|
||||||
|
const instance: Record<string, Record<string, string>> = {
|
||||||
|
'zh-CN': zhCN as Record<string, string>,
|
||||||
|
'en-US': enUS as Record<string, string>,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createIntl(locale: string = 'zh-CN') {
|
||||||
|
const intl = (id: string) => {
|
||||||
|
return instance[locale][id];
|
||||||
|
};
|
||||||
|
|
||||||
|
const intlNode = (id: string) => createElement('span', instance[locale][id]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
intl,
|
||||||
|
intlNode,
|
||||||
|
};
|
||||||
|
}
|
||||||
4
packages/react-simulator-renderer/src/locale/zh-CN.json
Normal file
4
packages/react-simulator-renderer/src/locale/zh-CN.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Drag and drop components or templates here": "拖拽组件或模板到这里",
|
||||||
|
"Locked elements and child elements cannot be edited": "锁定元素及子元素无法编辑"
|
||||||
|
}
|
||||||
@ -10,6 +10,7 @@ import { SimulatorRendererContainer, DocumentInstance } from './renderer';
|
|||||||
import { host } from './host';
|
import { host } from './host';
|
||||||
import { isRendererDetached } from './utils/misc';
|
import { isRendererDetached } from './utils/misc';
|
||||||
import './renderer.less';
|
import './renderer.less';
|
||||||
|
import { createIntl } from './locale';
|
||||||
|
|
||||||
// patch cloneElement avoid lost keyProps
|
// patch cloneElement avoid lost keyProps
|
||||||
const originCloneElement = window.React.cloneElement;
|
const originCloneElement = window.React.cloneElement;
|
||||||
@ -130,6 +131,7 @@ class Renderer extends Component<{
|
|||||||
documentInstance: DocumentInstance;
|
documentInstance: DocumentInstance;
|
||||||
}> {
|
}> {
|
||||||
startTime: number | null = null;
|
startTime: number | null = null;
|
||||||
|
schemaChangedSymbol = false;
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
this.recordTime();
|
this.recordTime();
|
||||||
@ -152,8 +154,6 @@ class Renderer extends Component<{
|
|||||||
this.recordTime();
|
this.recordTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
schemaChangedSymbol = false;
|
|
||||||
|
|
||||||
getSchemaChangedSymbol = () => {
|
getSchemaChangedSymbol = () => {
|
||||||
return this.schemaChangedSymbol;
|
return this.schemaChangedSymbol;
|
||||||
};
|
};
|
||||||
@ -172,6 +172,8 @@ class Renderer extends Component<{
|
|||||||
|
|
||||||
if (!container.autoRender || isRendererDetached()) return null;
|
if (!container.autoRender || isRendererDetached()) return null;
|
||||||
|
|
||||||
|
const { intl } = createIntl(locale);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LowCodeRenderer
|
<LowCodeRenderer
|
||||||
locale={locale}
|
locale={locale}
|
||||||
@ -206,12 +208,12 @@ class Renderer extends Component<{
|
|||||||
(children == null || (Array.isArray(children) && !children.length)) &&
|
(children == null || (Array.isArray(children) && !children.length)) &&
|
||||||
(!viewProps.style || Object.keys(viewProps.style).length === 0)
|
(!viewProps.style || Object.keys(viewProps.style).length === 0)
|
||||||
) {
|
) {
|
||||||
let defaultPlaceholder = '拖拽组件或模板到这里';
|
let defaultPlaceholder = intl('Drag and drop components or templates here');
|
||||||
const lockedNode = getClosestNode(leaf, (node) => {
|
const lockedNode = getClosestNode(leaf, (node) => {
|
||||||
return node?.getExtraProp('isLocked')?.getValue() === true;
|
return node?.getExtraProp('isLocked')?.getValue() === true;
|
||||||
});
|
});
|
||||||
if (lockedNode) {
|
if (lockedNode) {
|
||||||
defaultPlaceholder = '锁定元素及子元素无法编辑';
|
defaultPlaceholder = intl('Locked elements and child elements cannot be edited');
|
||||||
}
|
}
|
||||||
children = (
|
children = (
|
||||||
<div className={cn('lc-container-placeholder', { 'lc-container-locked': !!lockedNode })} style={viewProps.placeholderStyle}>
|
<div className={cn('lc-container-placeholder', { 'lc-container-locked': !!lockedNode })} style={viewProps.placeholderStyle}>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user