Skip to content

Commit 19decf1

Browse files
i18n module integrated
1 parent 7e757d9 commit 19decf1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Module } from '@nestjs/common';
2+
import { DatabaseModule } from '../../infrastructure/database/typeorm/database.module';
3+
import { ConfigModule, ConfigService } from '@nestjs/config';
4+
import { RecipeModule } from './recipe.module';
5+
import { UserModule } from './user.module';
6+
import { APP_GUARD } from '@nestjs/core';
7+
import { JwtAuthGuard } from '../../infrastructure/auth/jwt/jwt.guard';
8+
import { AuthModule } from './auth.module';
9+
import { AcceptLanguageResolver, I18nModule, QueryResolver } from 'nestjs-i18n';
10+
import * as path from 'path';
11+
12+
@Module({
13+
imports: [
14+
AuthModule,
15+
DatabaseModule,
16+
RecipeModule,
17+
UserModule,
18+
ConfigModule.forRoot({
19+
isGlobal: true,
20+
}),
21+
I18nModule.forRootAsync({
22+
useFactory: (configService: ConfigService) => ({
23+
fallbackLanguage: configService.get('LANGUAGE'),
24+
loaderOptions: {
25+
path: path.join(__dirname, '../../infrastructure/i18n'),
26+
},
27+
}),
28+
inject: [ConfigService],
29+
resolvers: [
30+
{ use: AcceptLanguageResolver, options: ['accept-language'] },
31+
new QueryResolver(['lang']),
32+
new AcceptLanguageResolver(), // <- NORMALIZA en-US → en
33+
],
34+
}),
35+
],
36+
providers: [
37+
{
38+
provide: APP_GUARD,
39+
useClass: JwtAuthGuard,
40+
},
41+
],
42+
})
43+
export class AppModule {}

0 commit comments

Comments
 (0)