Skip to content
New issue

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

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

Open
5 tasks done
DongFang-Jun opened this issue Oct 31, 2024 · 0 comments
Open
5 tasks done

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

DongFang-Jun opened this issue Oct 31, 2024 · 0 comments

Comments

@DongFang-Jun
Copy link

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

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant