Merge pull request #4674 from VitoBeijing/master

chore: 表单label国际化适配
This commit is contained in:
RUNZE LU 2022-06-22 11:01:13 +08:00 committed by GitHub
commit d77bffc061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 11 deletions

View File

@ -815,7 +815,8 @@ export class FormItemWrap extends React.Component<FormItemProps> {
hint,
data,
showErrorMsg,
useMobileUI
useMobileUI,
translate: __
} = props;
// 强制不渲染 label 的话
@ -865,7 +866,9 @@ export class FormItemWrap extends React.Component<FormItemProps> {
{label
? render(
'label',
typeof label === 'string' ? filter(label, data) : label
typeof label === 'string'
? filter(__(label), data)
: label
)
: null}
{required && (label || labelRemark) ? (
@ -968,7 +971,8 @@ export class FormItemWrap extends React.Component<FormItemProps> {
hint,
data,
showErrorMsg,
useMobileUI
useMobileUI,
translate: __
} = props;
description = description || desc;
@ -992,7 +996,9 @@ export class FormItemWrap extends React.Component<FormItemProps> {
{label
? render(
'label',
typeof label === 'string' ? filter(label, data) : label
typeof label === 'string'
? filter(__(label), data)
: label
)
: null}
{required && (label || labelRemark) ? (
@ -1086,7 +1092,8 @@ export class FormItemWrap extends React.Component<FormItemProps> {
renderDescription,
data,
showErrorMsg,
useMobileUI
useMobileUI,
translate: __
} = props;
const labelWidth = props.labelWidth || props.formLabelWidth;
description = description || desc;
@ -1113,7 +1120,9 @@ export class FormItemWrap extends React.Component<FormItemProps> {
{label
? render(
'label',
typeof label === 'string' ? filter(label, data) : label
typeof label === 'string'
? filter(__(label), data)
: label
)
: label}
{required && (label || labelRemark) ? (
@ -1210,7 +1219,8 @@ export class FormItemWrap extends React.Component<FormItemProps> {
hint,
data,
showErrorMsg,
useMobileUI
useMobileUI,
translate: __
} = props;
const labelWidth = props.labelWidth || props.formLabelWidth;
description = description || desc;
@ -1237,7 +1247,7 @@ export class FormItemWrap extends React.Component<FormItemProps> {
<span>
{render(
'label',
typeof label === 'string' ? filter(label, data) : label
typeof label === 'string' ? filter(__(label), data) : label
)}
{required && (label || labelRemark) ? (
<span className={cx(`Form-star`)}>*</span>

View File

@ -35,8 +35,7 @@ function FormField(props: FormFieldProps) {
hasError,
isRequired,
label,
description,
translate: __
description
} = props;
const errors = Array.isArray(props.errors)
@ -59,7 +58,7 @@ function FormField(props: FormFieldProps) {
{label ? (
<label className={cx(`Form-label`)}>
<span>
{__(label)}
{label}
{isRequired && label ? (
<span className={cx(`Form-star`)}>*</span>
) : null}