Angular 6 i18n runtime translation support Angular 6 i18n runtime translation support angular angular

Angular 6 i18n runtime translation support


The author of ngx-translate, Olivier Combe, is working with Angular to upgrade their i18n offerings to offer runtime translation, along with numerous other upgrades. I believe this functionality is expected in Angular 7, but Combe has published a polyfill for earlier versions.

https://github.com/ngx-translate/i18n-polyfill

It is fairly simple to integrate with an existing Angular i18n setup, with only minimal legwork. I'd recommend using this over ngx-translate, as Angular i18n - while more complicated to work with - is significantly more feature-rich than ngx-translate.

See Combe's discussion of the differences here:https://github.com/ngx-translate/core/issues/495#issuecomment-291158036


Based on a comment on https://github.com/angular/angular/issues/11405 and since we have to wait for Angular 8, I have created gist that shows how to use a helper component and a service for collecting translations.

This works only with JIT and only simple interpolations are supported.

https://gist.github.com/mohlendo/90c834f90bc084af2b869ca36a20712f