Update user friendly errors for translations (#15000)

Force msg typing instead of string for user friendly errors
This commit is contained in:
Félix Malfait
2025-10-09 18:17:32 +02:00
committed by GitHub
parent 660cd38f35
commit e577c2d746
124 changed files with 796 additions and 563 deletions
@@ -1,4 +1,4 @@
import { t } from '@lingui/core/macro';
import { msg } from '@lingui/core/macro';
import {
isDefined,
isLabelIdentifierFieldMetadataTypes,
@@ -38,14 +38,14 @@ export const validateFlatObjectMetadataIdentifiers = ({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message:
'labelIdentifierFieldMetadataId validation failed: related field metadata not found',
userFriendlyMessage: t`Field declared as label identifier not found`,
userFriendlyMessage: msg`Field declared as label identifier not found`,
});
} else if (!isLabelIdentifierFieldMetadataTypes(flatFieldMetadata.type)) {
errors.push({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message:
'labelIdentifierFieldMetadataId validation failed: field type not compatible',
userFriendlyMessage: t`Field cannot be used as label identifier`,
userFriendlyMessage: msg`Field cannot be used as label identifier`,
});
}
}
@@ -61,7 +61,7 @@ export const validateFlatObjectMetadataIdentifiers = ({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message:
'imageIdentifierFieldMetadataId validation failed: related field metadata not found',
userFriendlyMessage: t`Field declared as image identifier not found`,
userFriendlyMessage: msg`Field declared as image identifier not found`,
});
}
}
@@ -1,4 +1,4 @@
import { msg, t } from '@lingui/core/macro';
import { msg } from '@lingui/core/macro';
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
@@ -44,7 +44,7 @@ export const validateFlatObjectMetadataLabel = ({
errors.push({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message: `The singular and plural labels cannot be the same for an object`,
userFriendlyMessage: t`The singular and plural labels cannot be the same for an object`,
userFriendlyMessage: msg`The singular and plural labels cannot be the same for an object`,
value: labelSingular,
});
}
@@ -1,4 +1,4 @@
import { t } from '@lingui/core/macro';
import { t, msg } from '@lingui/core/macro';
import { type FlatEntityMaps } from 'src/engine/core-modules/common/types/flat-entity-maps.type';
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
@@ -39,7 +39,7 @@ export const validateFlatObjectMetadataNameAndLabels = ({
errors.push({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message: t`Names are not synced with labels`,
userFriendlyMessage: t`Names are not synced with labels`,
userFriendlyMessage: msg`Names are not synced with labels`,
});
}
@@ -54,7 +54,7 @@ export const validateFlatObjectMetadataNameAndLabels = ({
errors.push({
code: ObjectMetadataExceptionCode.OBJECT_ALREADY_EXISTS,
message: 'Object already exists',
userFriendlyMessage: t`Object already exists`,
userFriendlyMessage: msg`Object already exists`,
});
}
@@ -1,4 +1,4 @@
import { t } from '@lingui/core/macro';
import { msg } from '@lingui/core/macro';
import { type FlatObjectMetadataValidationError } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata-validation-error.type';
import { type FlatObjectMetadata } from 'src/engine/metadata-modules/flat-object-metadata/types/flat-object-metadata.type';
@@ -30,7 +30,7 @@ export const validateFlatObjectMetadataNames = ({
errors.push({
code: ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT,
message: `The singular and plural names cannot be the same for an object`,
userFriendlyMessage: t`The singular and plural names cannot be the same for an object`,
userFriendlyMessage: msg`The singular and plural names cannot be the same for an object`,
value: namePlural,
});
}