Core: Ngx Translate not loading the new language file when switching language if ionic lazy loading is used

Created on 23 Nov 2017  路  2Comments  路  Source: ngx-translate/core

I'm submitting a ... (check one with "x")

[ x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

When switch to a different language. an empty translation object returned:
lang changed detected {lang: "dutch", translations: {}}

Expected/desired behavior
Should load the new language file

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar.

it's a ionic 3 project. Please install ionic 3 if you haven't.

git clone https://github.com/lolaswift/lazyTrans
cd lazyTrans npm install ionic serve
When click on "Nederlands", "Good Morning" is not translated.

What is the expected behavior?
You should see the Dutch translation of "Good Morning", which is
"Goedemorgen!"

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.0",
"ionic-angular": "3.9.2",
"@angular/core": "5.0.1",
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Most helpful comment

As explained here https://forum.ionicframework.com/t/ngx-translate-is-broken-when-used-with-ionic-lazy-loading/112624/11 this worked for me. The loader is only required on pages that can set the language

All 2 comments

Update: by loading the translate loader on every page seems to have solved my issue
But it shouldn't be necessary, is it?
https://forum.ionicframework.com/t/ngx-translate-is-broken-when-used-with-ionic-lazy-loading/112624
Can you please clarify what should be the right way of fixing the issue.

As explained here https://forum.ionicframework.com/t/ngx-translate-is-broken-when-used-with-ionic-lazy-loading/112624/11 this worked for me. The loader is only required on pages that can set the language

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jellene4eva picture jellene4eva  路  3Comments

pndewit picture pndewit  路  3Comments

jvquarck picture jvquarck  路  3Comments

dankerk picture dankerk  路  3Comments

webprofusion-chrisc picture webprofusion-chrisc  路  4Comments