Closed quanjongliang closed 1 year ago
As the error suggests, you should use AcceptLanguageResolver
.
import { Module } from '@nestjs/common';
import * as path from 'path';
import {
AcceptLanguageResolver,
I18nJsonLoader,
I18nModule
} from 'nestjs-i18n';
@Module({
imports: [
I18nModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
fallbackLanguage: "en",
loaderOptions: {
path: join(__dirname, "/i18n/"),
watch: true,
},
}),
resolvers: [
AcceptLanguageResolver,
],
inject: [ConfigService],
}),
],
controllers: [],
})
export class AppModule {}
As the error suggests, you should use
AcceptLanguageResolver
.import { Module } from '@nestjs/common'; import * as path from 'path'; import { AcceptLanguageResolver, I18nJsonLoader, I18nModule } from 'nestjs-i18n'; @Module({ imports: [ I18nModule.forRootAsync({ useFactory: (configService: ConfigService) => ({ fallbackLanguage: "en", loaderOptions: { path: join(__dirname, "/i18n/"), watch: true, }, }), resolvers: [ AcceptLanguageResolver, ], inject: [ConfigService], }), ], controllers: [], }) export class AppModule {}
Hi rubin, may you explain this section please? i didn't understand that.
inject: [ConfigService],
You could ignore that if you are not using config service to manage fallbacks
Hi everyone, How can I set the current language in i18n as headers value I tried
resolvers: [new HeaderResolver('accept-language')],
but receivedWARN [I18nService] HeaderResolver does not support RFC4647 Accept-Language header. Please use AcceptLanguageResolver instead.
Thanks