chore: 支持表达式多语言默认显示 (#7805)

This commit is contained in:
sqzhou 2023-08-15 10:12:22 +08:00 committed by GitHub
parent 42d43050ce
commit 2a102312f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
// 多语言支持
import React from 'react';
import hoistNonReactStatic from 'hoist-non-react-statics';
import moment from 'moment';
import {resolveVariable} from './utils/tpl-builtin';
export type TranslateFn<T = any> = (str: T, data?: object) => T;
@ -11,6 +12,12 @@ interface LocaleConfig {
let defaultLocale: string = 'zh-CN';
const momentLocaleMap: Record<string, string> = {
'zh-CN': 'zh-cn',
'en-US': 'en',
'de-DE': 'de'
};
const locales: {
[propName: string]: LocaleConfig;
} = {};
@ -154,6 +161,7 @@ export function localeable<
locale,
translate: translate!
};
moment.locale(momentLocaleMap?.[locale] ?? locale);
const refConfig = ComposedComponent.prototype?.isReactComponent
? {ref: this.childRef}
: {forwardedRef: this.childRef};