I want to translate text from the .ts components in a Angular 2+ application.
Right now I've already translated text from the HTML template using the official guide (https://angular.io/guide/i18n) but can't find a way to translate text from the .ts component.
For example, I would like to translate the title of the page
import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit {
constructor(private title: Title) {}
ngOnInit() {
this.title.setTitle('I would like to have this title translated');
}
}
Any way to achieve that nicely?