import { PureComponent } from 'react'; import { globalLocale, Tip } from '@ali/lowcode-editor-core'; import { PluginProps } from '@ali/lowcode-types'; import { intl } from './locale'; import { IconZh } from './icons/zh'; import { IconEn } from './icons/en'; import './index.less'; export default class ZhEn extends PureComponent { static displayName = 'LowcodeZhEn'; state = { locale: globalLocale.getLocale(), }; private dispose = globalLocale.onLocaleChange((locale) => { this.setState({ locale }); }); componentWillUnmount() { this.dispose(); } render() { const isZh = this.state.locale === 'zh-CN'; return (
{ globalLocale.setLocale(isZh ? 'en-US' : 'zh-CN'); }}> {isZh ? : } {intl('To Locale')}
); } }