Translations not loaded on first start
Current behavior
I use ngx-translate in an Ionic 4 app. When I deploy the app to a device on the first start the translations are not loaded. If I exit the app and restart it, everthing works fine.
Expected behavior
Translations are loaded on first start of the app.
Minimal reproduction of the problem with instructions
- Build the Ionic app with initialization of ngx-translate as in the docs
- Deploy app to a device (Android or iOS)
- Start the app
Environment
ngx-translate version: 12.1.1
Angular version: 8.2.14
In my app.component.ts I initialize ngx-translate as described in the docs:
constructor(public translate: TranslateService) {
this.translate.setDefaultLang('de');
this.translate.use('de').subscribe(
next => { console.log('Initialized translations') }
);
}
It seems that the use() method does not work correctly on the first start. The output inside the subscribe does not appear on the first start, but one the second.
Maybe its related to #1162 or #1175
I found a workaround that works for me, but it's a bit hacky.
I created a class Labels that holds the labels from the JSON files. In my app.component.ts I set the translations explicitly with the values from this class when I configure the translate service.
this.translate.setTranslation('de', Labels.get('de'));
this.translate.setTranslation('en', Labels.get('en'));
This works on the first start, but now I have to maintain two versions of the translations as I want to switch back to the official way with http-loader when the bug is fixed.
@fortunella I can reproduce this issue in a non-Ionic environment.
Using @angular/core and @ngx-translate/core 13.0.0.
Occurs mostly on initial page load. Translations load after reloading window, I guess because *.js bundles are already in cache.
Is there an update or workaround for this issue?
any update on this one?
Any updates here ?
any update?
Any updates? Is this ever getting fixed?
still not fixed