All files / lib/services i18n-request-scope.service.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201x 1x 1x     1x   18x 18x       6x       6x      
import { Inject, Injectable, Scope } from '@nestjs/common';
import { REQUEST } from '@nestjs/core';
import { I18nService } from './i18n.service';
 
@Injectable({ scope: Scope.REQUEST })
export class I18nRequestScopeService {
  constructor(
    @Inject(REQUEST) private readonly req,
    private readonly i18nService: I18nService,
  ) {}
 
  public translate(key, options?) {
    options = {
      lang: this.req.i18nLang,
      ...options,
    };
    return this.i18nService.translate(key, options);
  }
}