Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations not loaded on first start #1178

Open
fortunella opened this issue Feb 26, 2020 · 8 comments
Open

Translations not loaded on first start #1178

fortunella opened this issue Feb 26, 2020 · 8 comments

Comments

@fortunella
Copy link

fortunella commented Feb 26, 2020

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

  1. Build the Ionic app with initialization of ngx-translate as in the docs
  2. Deploy app to a device (Android or iOS)
  3. 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

@fortunella
Copy link
Author

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.

@blumk
Copy link

blumk commented Aug 30, 2020

@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.

@do-nat
Copy link

do-nat commented Jan 11, 2022

Is there an update or workaround for this issue?

@brandart
Copy link

any update on this one?

@ajlif
Copy link

ajlif commented May 12, 2022

Any updates here ?

@yogawa
Copy link

yogawa commented Jun 20, 2023

any update?

@scarela
Copy link

scarela commented Aug 31, 2023

Any updates? Is this ever getting fixed?

@MoathTar
Copy link

MoathTar commented Feb 11, 2024

still not fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants