Originally posted by **pallimalilsuhail** September 12, 2024
I'm working on translating the validation errors in my application, which is configured as follows
`main.js` 👇🏽 ~ added the pipe and filters
```typescript
app.useGlobalPipes(
new I18nValidationPipe(),
);
.....
.....
app.useGlobalFilters(
new I18nValidationExceptionFilter({
errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
errorFormatter: validationExceptionFactory,
}),
new BusinessRuleExceptionFilter(),
new NotFoundExceptionFilter(),
new TooManyAttemptsExceptionFilter(),
);
```
`root.module.ts` 👇🏽 ~ module imported
```typescript
I18nModule.forRoot({
fallbackLanguage: "en",
throwOnMissingKey: true,
logging: true,
validatorOptions: {
stopAtFirstError: true,
},
loaderOptions: {
path: path.join(__dirname, "/i18n/"),
watch: true,
},
viewEngine: "hbs",
resolvers: [AcceptLanguageResolver],
}),
```
translation file
```json
{
"isEnum": "Testing enum translation",
"isNotEmpty": "This field cannot be empty",
"minLength": "testing min length"
}
```
request class
```typescript
export class GetBasketQueryParams {
@IsString()
@IsNotEmpty()
@IsEnum(OrderingMode)
orderingMode: OrderingMode;
@IsString()
@IsNotEmpty()
@IsEnum(SalesChannel)
salesChannel: SalesChannel;
@IsString()
@IsNotEmpty()
currency: string;
}
```
Unfortunately, the translation is not functioning as expected. Based on the constraints, the code should use `IsEnum`/`IsNotEmpty` as the keys for translation, but instead, it seems to be using the value, resulting in the following error:
`Translation salesChannel is not empty in en does not exist.`
I suspect that the value is being used as the translation key instead of the constraint's key. Has anyone else encountered this issue?"
Discussed in https://github.com/toonvanstrijp/nestjs-i18n/discussions/661