Skip to content

WARN [I18nService] context type: telegraf not supported #2

@AlexInCube

Description

@AlexInCube

I download this package, because i want to eliminate WARN [I18nService] context type: telegraf not supported console output when i call the t() or translate(). Localization works fine, but i get spammed in console output,

My modules
app.module.ts


@Module({
  imports: [
    ConfigModule.forRoot({
      validate: (env) =>
        z
          .object({
            AUTH_SERVICE_HOST: z.string().default('localhost'),
            AUTH_SERVICE_PORT: z.coerce.number().optional().default(6000),
            TELEGRAM_BOT_SERVICE_HOST: z.string().default('localhost'),
            TELEGRAM_BOT_SERVICE_PORT: z.coerce.number().optional().default(6001),
            TELEGRAM_TOKEN: z.string(),
          })
          .parse(env),
    }),
    LocalizationModule,
    TelegrafI18nModule,
    TelegrafModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService, TelegrafI18nMiddlewareProvider],
      useFactory: async (
        configService: ConfigService,
        telegrafI18nMiddlewareProvider: TelegrafI18nMiddlewareProvider,
      ) => ({
        token: configService.get<string>('TELEGRAM_TOKEN'),
        options: {
          contextType: TelegrafI18nContext,
        },
        include: [AuthModule],
        middlewares: [telegrafI18nMiddlewareProvider.telegrafI18nMiddleware],
      }),
    }),
    AuthModule,
    GrpcClientAuthServiceModule,
    EventEmitterModule.forRoot(),
  ],
})
export class AppModule {}

localization.module.ts

@Module({
  imports: [
    I18nModule.forRoot({
      fallbackLanguage: 'ru',
      resolvers: [AcceptLanguageResolver],
      loaderOptions: {
        path: localizationFolderPath,
        watch: true,
      },
    }),
  ],
  controllers: [],
  providers: [],
})
export class LocalizationModule {}

auth.update.ts

@Update()
@UseFilters(TelegrafExceptionFilter)
export class AuthUpdate {
  constructor(private readonly authService: AuthService) {}

  @Start()
  async start(@Ctx() ctx: TelegrafI18nContext) {
    await ctx.reply(ctx.translate('telegram-bot.welcome'));
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions