I am using the i18n features of Angular 4 and building the project successfully with angular-cli in the target language. HTML templates are properly translated. However I got some texts in the javascript code.
What's the recommended way of localizing strings used in js source for things like validations? Can we expect i18n to come with a solution?
Currently I am using the locale to determine which translation to use.
The Locale gets set from the ng serve --locale fr or ng build --locale fr
Building/serving like this:
ng serve --aot --locale fr ...
and using the locale in the code like this:
import { LOCALE_ID } from '@angular/core';
// ...
constructor (@Inject(LOCALE_ID) locale: string) {
}
(I was following the great hints on http://blog.danieleghidoli.it/2017/01/15/i18n-angular-cli-aot/)