here is my decision to translate my warning message when ngx-toastr is called inside my ts file, I created a link in the template with i18n and use this element for my message with html enabled
ngOnInit() { this.toastrService.success('created successfully', ''); }
I converted it to this
@ViewChild('successContainer ') successContainerRef: ElementRef; ... constructor(private toastrService: ToastrService) {} ngOnInit() { this.toastrService.success(this.successContainerRef.nativeElement.outerHTML, '', { enableHtml : true });
and in my template I create a div with the link #successContainer
<h2 i18n="@@successMessage" #successContainer [hidden]="true">created successfully</h2>
source share