fix(bot-services): add global: true to I18nModule dynamic module config

The @Global() decorator on a module class doesn't apply when using
dynamic modules (forRoot/forRootAsync). The global: true property
must be set directly in the DynamicModule return object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-02-17 12:48:28 +01:00
parent 9b01c094c1
commit fd30fdc620

View file

@ -1,4 +1,4 @@
import { Module, DynamicModule, Global } from '@nestjs/common'; import { Module, DynamicModule } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config'; import { ConfigModule } from '@nestjs/config';
import { I18nService, I18N_OPTIONS } from './i18n.service'; import { I18nService, I18N_OPTIONS } from './i18n.service';
import { I18nOptions } from './types'; import { I18nOptions } from './types';
@ -28,7 +28,6 @@ import { I18nOptions } from './types';
* }) * })
* ``` * ```
*/ */
@Global()
@Module({}) @Module({})
export class I18nModule { export class I18nModule {
/** /**
@ -37,6 +36,7 @@ export class I18nModule {
static forRoot(options?: I18nOptions): DynamicModule { static forRoot(options?: I18nOptions): DynamicModule {
return { return {
module: I18nModule, module: I18nModule,
global: true,
imports: [ConfigModule], imports: [ConfigModule],
providers: [ providers: [
{ {
@ -59,6 +59,7 @@ export class I18nModule {
}): DynamicModule { }): DynamicModule {
return { return {
module: I18nModule, module: I18nModule,
global: true,
imports: [...(options.imports || []), ConfigModule], imports: [...(options.imports || []), ConfigModule],
providers: [ providers: [
{ {