We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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实时重新加载 }, }), }); } }
${rootPath}${configService.get<string>('i18n.path')}
no
"nestjs-i18n": "^10.4.5", "i18next": "^23.14.0", "i18next-fs-backend": "^2.3.2", "i18next-http-middleware": "^3.6.0",
pnpm
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: