I am using ngx-translate for my translations in my angular app.
In a custom pipe I have some text that need to be translated.
pipe:
import { Pipe, PipeTransform } from '@angular/core';
import { Something} from '../domain';
@Pipe({
name: 'someDescription'
})
export class SomeDescriptionPipe implements PipeTransform {
transform(value: Something, args?: any): string {
switch (value) {
case Something.value1: return 'string 001';
case Something.value2: return 'string 002';
default: return value;
}
}
}
As far as I know a constructor is not suppported since angular 6. How can I translate the text in a pipe? (This is not true after some research)
The solution is use a constructor and import the TranslateService.