@open-rlb/ng-app 3.1.112 → 3.1.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as i1$2 from '@angular/common/http';
2
2
  import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
3
3
  import * as i0 from '@angular/core';
4
- import { InjectionToken, Injectable, Inject, Optional, inject, Injector, computed, signal, importProvidersFrom, makeStateKey, makeEnvironmentProviders, input, model, ChangeDetectionStrategy, Component, Pipe, output, viewChild, TemplateRef, ViewContainerRef, effect, Directive, PLATFORM_ID, NgModule, DestroyRef, isDevMode, provideAppInitializer } from '@angular/core';
4
+ import { InjectionToken, Injectable, Inject, Optional, inject, Injector, computed, signal, importProvidersFrom, provideAppInitializer, makeStateKey, makeEnvironmentProviders, input, model, ChangeDetectionStrategy, Component, Pipe, output, viewChild, TemplateRef, ViewContainerRef, effect, Directive, PLATFORM_ID, NgModule, DestroyRef, isDevMode } from '@angular/core';
5
5
  import * as i5 from '@angular/router';
6
6
  import { ActivatedRoute, Router, NavigationEnd, RouterModule, RoutesRecognized, provideRouter } from '@angular/router';
7
7
  import { SwUpdate, provideServiceWorker } from '@angular/service-worker';
@@ -14,7 +14,7 @@ import { UniqueIdService, RLB_TRANSLATION_SERVICE, ModalService, ModalDirective,
14
14
  import * as i1$5 from 'angular-auth-oidc-client';
15
15
  import { AbstractLoggerService, AuthModule, provideAuth, AuthInterceptor, AbstractSecurityStorage } from 'angular-auth-oidc-client';
16
16
  import * as i1 from 'ngx-cookie-service-ssr';
17
- import { of, from, map, catchError, tap, switchMap, filter, take, share, lastValueFrom, zip, EMPTY, Observable, ReplaySubject, combineLatest, startWith, BehaviorSubject, distinctUntilChanged } from 'rxjs';
17
+ import { of, from, map, catchError, tap, switchMap, filter, take, ReplaySubject, share, lastValueFrom, zip, EMPTY, firstValueFrom, Observable, combineLatest, startWith, BehaviorSubject, distinctUntilChanged } from 'rxjs';
18
18
  import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
19
19
  import { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop';
20
20
  import * as i1$4 from '@ngx-translate/core';
@@ -834,6 +834,11 @@ class LanguageService {
834
834
  this.contentLanguage = this._contentLanguage.asReadonly();
835
835
  this.languageChanged$ = this.translateService.onLangChange;
836
836
  this.contentLanguageChanged = this._contentLanguage.asReadonly();
837
+ // Emits once the initial UI translation file has been loaded (or failed to load).
838
+ // Consumed by the i18n APP_INITIALIZER to block bootstrap until translations are
839
+ // available, so synchronous instant() calls during app/component init resolve keys.
840
+ this._ready$ = new ReplaySubject(1);
841
+ this.ready$ = this._ready$.asObservable();
837
842
  // Sync private signal with translate service changes
838
843
  this.translateService.onLangChange
839
844
  .pipe(takeUntilDestroyed())
@@ -842,9 +847,16 @@ class LanguageService {
842
847
  this.translateService.addLangs(this.i18nOptions.availableLangs);
843
848
  const languageUI = this.cookiesService.getCookie('ui-locale') || this.defaultLanguage || this.browserLanguage;
844
849
  const languageContent = this.cookiesService.getCookie('content-locale') || this.defaultLanguage;
845
- this.translateService.use(languageUI);
850
+ this.translateService.use(languageUI).subscribe({
851
+ next: () => this._ready$.next(true),
852
+ // Don't block bootstrap forever if the translation file fails to load.
853
+ error: () => this._ready$.next(true),
854
+ });
846
855
  this.setContentLanguage(languageContent);
847
856
  }
857
+ else {
858
+ this._ready$.next(true);
859
+ }
848
860
  }
849
861
  get currentLanguage() {
850
862
  return this.language();
@@ -1236,6 +1248,10 @@ function provideRlbI18n(i18n) {
1236
1248
  provide: RLB_TRANSLATION_SERVICE,
1237
1249
  useClass: RlbTranslateAdapterService
1238
1250
  },
1251
+ // Block bootstrap until the initial UI translation file is loaded, so that
1252
+ // synchronous instant() calls during app/component init (e.g. sidebar setup)
1253
+ // resolve real translations instead of leaking raw i18n keys.
1254
+ provideAppInitializer(() => firstValueFrom(inject(LanguageService).ready$)),
1239
1255
  ];
1240
1256
  }
1241
1257