Skip to content

[i18n] Translations unloaded to early when navigating to another page #27

Description

@DenisValcke

Hi @IbenTesara

I've noticed something that might need a different approach.

This issue happens when I change routes, mostly when that route-change is to a route that has a resolver in charge of the data.

Step 1: The resolver triggers the this.i18nService.initI18n method:

return this.i18nService.initI18n(this.i18nService.currentLanguage).pipe(

Step 2: The initI18n method will then trigger the this.translateService.reloadLang method:
https://github.com/IbenTesara/opensource/blob/main/libs/angular/i18n/src/lib/services/i18n/i18n.service.ts#L57

Step 3: The reloadLang method will trigger the this.store.deleteTranslations action:
https://github.com/ngx-translate/core/blob/44b22d641ae350c0035bbddaf1091f53ec29a176/projects/ngx-translate/src/lib/translate.service.ts#L1012

So the translations of the current page (before navigation has ended) are being unloaded when fetching the translations for the next page. This creates a very short window in which the current page is visible with the translation paths/markers instead of the corresponding translation strings.

I don't have a clear fix in mind yet, but maybe we should let the new translations live next to the old ones, and only switch them out when the navigation has ended?

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions