import { Pipe , PipeTransform } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; @ Pipe ( { name : 'obTranslateParams' , pure : false } ) export class ObTranslateParamsPipe implements PipeTransform { constructor ( private readonly translate ) { } transform ( value , params ? ) { return this . translate . instant ( value , typeof params === 'object' ? this . translateParams ( params ) : undefined ) ; } private translateParams ( params ) { return Object . keys ( params ) . reduce ( ( parameters , key ) => ( { ... parameters , [ key ] : typeof params [ key ] === 'string' ? this . translate . instant ( params [ key ] ) : params [ key ] } ) , { } ) ; } }