mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Merge pull request #2077 from ErikDakoda/GetLabelIntlFallback
SmartForm.getLabel() intl string fallback
This commit is contained in:
commit
73d7172896
1 changed files with 12 additions and 1 deletions
|
@ -423,7 +423,18 @@ class SmartForm extends Component {
|
|||
*/
|
||||
getLabel = (fieldName, fieldLocale) => {
|
||||
const collectionName = this.getCollection().options.collectionName.toLowerCase();
|
||||
const intlLabel = this.context.intl.formatMessage({ id: `${collectionName}.${fieldName}` });
|
||||
const defaultMessage = '|*|*|';
|
||||
let id = `${collectionName}.${fieldName}`;
|
||||
let intlLabel;
|
||||
intlLabel = this.context.intl.formatMessage({ id, defaultMessage });
|
||||
if (intlLabel === defaultMessage) {
|
||||
id = `global.${fieldName}`;
|
||||
intlLabel = this.context.intl.formatMessage({ id });
|
||||
if (intlLabel === defaultMessage) {
|
||||
id = fieldName;
|
||||
intlLabel = this.context.intl.formatMessage({ id });
|
||||
}
|
||||
}
|
||||
const schemaLabel = this.state.flatSchema[fieldName] && this.state.flatSchema[fieldName].label;
|
||||
const label = intlLabel || schemaLabel || fieldName;
|
||||
if (fieldLocale) {
|
||||
|
|
Loading…
Add table
Reference in a new issue