We have to wait until Angular 6 for angular-i18n to support translations in code for error messages and such.
For those that are using angular-i18n (instead of ngx-t
See this blog entry: https://blog.ninja-squad.com/2019/12/10/angular-localize/
In a nutshell:
There is $localize which can be used to do this.
@Component({
template: '{{ title }}'
})
export class HomeComponent {
title = $localize`You have 10 users`;
}
Unfortunately the feature is not realy complete yet:
You can then translate the message the same way you would for a template. But, right now (v9.0.0), the CLI does not extract these messages with the xi18n command as it does for templates.