Skip to content

Commit

Permalink
Update I18NextEagerPipe.ts to run inside NgZone
Browse files Browse the repository at this point in the history
Update I18NextEagerPipe.ts to be able to detect language changes inside NgZone for Microfrontend architectures
  • Loading branch information
JacobF7 authored May 29, 2023
1 parent 74f8760 commit 63e8a61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/angular-i18next/src/lib/I18NextEagerPipe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ChangeDetectorRef,
Inject,
NgZone,
OnDestroy,
Pipe,
PipeTransform,
Expand Down Expand Up @@ -34,13 +35,14 @@ export class I18NextEagerPipe
@Inject(I18NEXT_SERVICE) protected override translateI18Next: ITranslationService,
@Inject(I18NEXT_NAMESPACE) protected override ns: string | string[],
@Inject(I18NEXT_SCOPE) protected override scope: string | string[],
private cd: ChangeDetectorRef
private cd: ChangeDetectorRef,
private ngZone: NgZone
) {
super(translateI18Next, ns, scope);
translateI18Next.events.languageChanged
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(() => {
this.cd.markForCheck();
this.ngZone.run(() => this.cd.markForCheck());
});
}
private hasKeyChanged(key: string | string[]): boolean {
Expand Down

0 comments on commit 63e8a61

Please sign in to comment.