toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
656 stars 113 forks source link

使用forRootAsync设置resolvers不生效? #672

Open DongFang-Jun opened 3 weeks ago

DongFang-Jun commented 3 weeks ago

Describe the bug

import { DynamicModule } from '@nestjs/common'; import { join } from 'path'; import { I18nModule as i18n, HeaderResolver } from 'nestjs-i18n'; import { ConfigService } from '@nestjs/config';

export class I18nModule { static forRootAsync(): DynamicModule { const rootPath = join(__dirname, '..', '..', '..'); return i18n.forRootAsync({ inject: [ConfigService], resolvers: [new HeaderResolver(['lang'])], // 请求头匹配 useFactory: (configService: ConfigService) => ({ fallbackLanguage: configService.get('i18n.fallbackLanguage'), // 默认语言 loaderOptions: { path: ${rootPath}${configService.get<string>('i18n.path')}, // 翻译文件位置 watch: configService.get('i18n.watch'), // 将选项设置watch为可true启用loaderOptions实时重新加载 }, }), }); } }

Reproduction

no

System Info

"nestjs-i18n": "^10.4.5",
 "i18next": "^23.14.0",
    "i18next-fs-backend": "^2.3.2",
    "i18next-http-middleware": "^3.6.0",

Used Package Manager

pnpm

Validations