Angular 6 i18n runtime translation support
Asked Answered
A

2

18

I've read i18n runtime support is coming in angular 6, but cant find anything in rc3. Is it postponed or not yet documented? The i18n documentation still states than one have to build a separate build for each language.

https://github.com/ngx-translate is an alternative but i don't know how long this will be supported or if the support in Angular 6 will be totally different. Migrating later then will include rewrite of all i18n instances in the code and create new translation files. I have room to wait a little in my project but not forever.

Not been able to find anything on how the new i18n support in Angular 6 will be, except that it is coming.

Amalbergas answered 10/4, 2018 at 9:9 Comment(2)
It's on it's way github.com/angular/angular/pull/22654Damian
Sweet, that would say I prospone the i18n, POC part of our application for a little while it will be available. Any idea how long this might take? the release candidates are coming pretty tight at at moment.Amalbergas
U
5

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

Unsegregated answered 15/8, 2018 at 17:45 Comment(0)
C
3

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

Cleek answered 22/6, 2018 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.