import { Pipe, PipeTransform } from '@angular/core'; import { I18nService } from './../services/i18n.service'; @Pipe({ name: 'i18n' }) export class I18nPipe implements PipeTransform { constructor(private i18n: I18nService) { } transform(value: string, ...args: any[]): string { if (args.length === 1 && Array.isArray(args[0])) { args = args[0]; } return this.i18n.get(value, args); } } @Pipe({ name: 'i18nEmpty' }) export class I18nEmptyPipe implements PipeTransform { constructor(private i18n: I18nService) { } transform(value: string, ...args: any[]): string { return this.i18n.getEmpty(value, args); } } @Pipe({ name: 'errorCode' }) export class ErrorCodePipe implements PipeTransform { transform(value: string): string { return value && value.toUpperCase().replaceAll('-', '_') || value; } }