Ionic 4 built in Angular i18n

Hey guys, I have an Angular application that requires i18n. So far for web projects we are using the built-in i18n of Angular. We want to stick with this in the Ionic project we have and have implemented it so far. I’ve set up a custom configuration that specifies the i18nFile, i18nLocale and i18nFormat. Building with Angular itself (ng build) works fine and returns the translated application.

My current problem is that Ionic (or Cordova) seems to ignore the i18n-file I’m providing in the configuration if I run ionic cordova build android --configuration=…

I know ngx-translate exists, but I would like to consider it as the last option since it requires some changes in the existing app.

2 Likes

I have the same issue. Any ideas?

We did not found a “real” solution for this problem, more like a workaround. We are sticking with native i18n-attributes and are utilizing https://github.com/martinroob/ngx-i18nsupport/wiki/ngx-translate-usage. Basically we do

  1. In the code add i18n attribute
  2. In the code add {{ i18n@@id | translate }} (or wherever you need the translation)
  3. run ngx-i18nsupport to extract xlf
  4. translate xlf
  5. run ngx-i18n-support again to (automatically) generate json files for ngx-translate
4 Likes