Closed ihengshuai closed 1 year ago
I will also report an error without injecting configService, and I cannot use useFactory
same issue? https://github.com/toonvanstrijp/nestjs-i18n/issues/472
put the resolvers prop outside of useFactory
The resolvers position is wrong. You should put it outside as @Susccy said
import { Module } from '@nestjs/common';
import * as path from 'path';
import {
AcceptLanguageResolver,
QueryResolver,
HeaderResolver,
CookieResolver,
I18nJsonLoader,
I18nModule,
} from 'nestjs-i18n';
@Module({
imports: [
I18nModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
fallbackLanguage: "en",
loaderOptions: {
path: join(__dirname, "/i18n/"),
watch: true,
},
}),
resolvers: [
new QueryResolver(["lang", "l"]),
new HeaderResolver(["x-custom-lang"]),
new CookieResolver(),
AcceptLanguageResolver,
],
inject: [ConfigService],
}),
],
controllers: [],
})
export class AppModule {}
Thanks, I already have other solutions 🤗
Describe the bug
Hi, guys, I want to use configService to load the application configuration, so I use the forRootAsync class to inject configService, but I did not expect an error
When I run the terminal I get the following error:
Please take a look at this error, thanks
Reproduction
https://github.com/ihengshuai/nestjs-practive/tree/i18n_error
System Info
Used Package Manager
yarn
Validations