I'm using this @ngx-translate/core i18n service and it works fine in templates (.html) with this syntax:
{{'my.i18n.key'|translate}}
Now I want to translate something in my component typescript file (.ts) but I don't know how to use it.
I can create translate object in my constructor:
constructor(private translate: TranslateService) {}
and now how to translate 'my.i18n.key' ?
To translate something in your typescript file, do the following
constructor(private translate: TranslateService) {}
then use like this wherever you need to translate
this.translate.instant('my.i18n.key')