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

translateService.use doesn't work for multiple lazy loaded components #1175

Open
sergiubologa opened this issue Feb 20, 2020 · 1 comment
Open

Comments

@sergiubologa
Copy link

sergiubologa commented Feb 20, 2020

Current behavior

If you have an app with one base component and other 2 components which are lazy loaded the translateService.use function doesn't make the request to retrieve translation files.

Expected behavior

It should retrieve the translation files for each lazy loaded modules.

How do you think that we should fix this?

The issue is caused by this line:

// don't change the language if the language given is already selected
if (lang === this.currentLang) {
    return of(this.translations[lang]);
}

I'm not sure what would happen if the check is removed, but my first guess is to remove it. :)

Minimal reproduction of the problem with instructions

Here's a stackblitz demonstrating the issue: https://stackblitz.com/edit/angular-sm99qe-ngx-translate-lazy-load

Environment


ngx-translate version: 12.1.1
Angular version: 7.0.0.

@leon-marzahn
Copy link

Nothing should happen if you remove the check, it'll just load the translations again if you call translateService.use. Maybe there should be an additional check, to see what context you're in

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

2 participants