mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-14 13:03:07 +00:00
22 lines
521 B
TypeScript
22 lines
521 B
TypeScript
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] || id;
|
|
};
|
|
|
|
const intlNode = (id: string) => createElement('span', instance[locale]?.[id] || id);
|
|
|
|
return {
|
|
intl,
|
|
intlNode,
|
|
};
|
|
}
|