monkey-front-core 21.0.30 → 21.0.32

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.
@@ -2581,7 +2581,7 @@ class MonkeyEcxLocaleService {
2581
2581
  }
2582
2582
  loadFromWhitelabel(lang) {
2583
2583
  try {
2584
- const whiteLabel = this._configsService.whiteLabel;
2584
+ const { whiteLabel } = this._configsService;
2585
2585
  const currentExternali18n = whiteLabel?.externali18n?.[`${lang}`];
2586
2586
  let data = {};
2587
2587
  if (currentExternali18n) {
@@ -2629,6 +2629,39 @@ class MonkeyEcxLocaleService {
2629
2629
  console.error(`MonkeyEcxLocaleService -> loadInternal i18n ${lang} not found!`);
2630
2630
  }
2631
2631
  }
2632
+ async loadByFederationSettings(lang) {
2633
+ try {
2634
+ const key = 'federation-settings';
2635
+ if (!this.isExpired(lang, key))
2636
+ return;
2637
+ const { bootstrap } = this._configsService;
2638
+ const federationSettings = bootstrap?.federationSettings;
2639
+ if (!federationSettings)
2640
+ return;
2641
+ const requests = [];
2642
+ const errors = [];
2643
+ Object.entries(federationSettings).forEach(([name, config]) => {
2644
+ const url = `${config.host}/assets/i18n/${lang}.json`;
2645
+ requests.push(firstValueFrom(this._service.get(url))
2646
+ .then((resp) => {
2647
+ this._bootstrapService.handleI18N(lang, resp.data);
2648
+ })
2649
+ .catch((err) => {
2650
+ console.error(`MonkeyEcxLocaleService -> loadByFederationSettings i18n ${lang} not found!`);
2651
+ errors.push(err);
2652
+ }));
2653
+ });
2654
+ await Promise.all(requests);
2655
+ if (errors.length) {
2656
+ this._errorService.apply(errors[0]);
2657
+ }
2658
+ MonkeyEcxLocaleService._loadedBundles.set(`${key}/${lang}`, Date.now());
2659
+ }
2660
+ catch (e) {
2661
+ this._errorService.apply(e);
2662
+ console.error(`MonkeyEcxLocaleService -> loadByFederationSettings i18n ${lang} not found!`);
2663
+ }
2664
+ }
2632
2665
  async handleValidation() {
2633
2666
  const lang = this._tokenStorageService.getMe()?.locale || this._localeId;
2634
2667
  if (this._localeId === 'es-CL') {
@@ -2640,11 +2673,14 @@ class MonkeyEcxLocaleService {
2640
2673
  else {
2641
2674
  registerLocaleData(ptBr);
2642
2675
  }
2643
- await this.loadExternal(lang, 'auth');
2676
+ // this codes bellow is commented cuz we will not use this approach anymore
2677
+ // making tests to make sure everything is ok, after the we will delete it
2678
+ // await this.loadExternal(lang, 'auth');
2644
2679
  await this.loadInternal(lang);
2645
- await this.loadExternal(lang, 'shared');
2646
- this.loadExternal(lang, 'alerts');
2647
- this.loadExternal(lang, 'register');
2680
+ await this.loadByFederationSettings(lang);
2681
+ // await this.loadExternal(lang, 'shared');
2682
+ // this.loadExternal(lang, 'alerts');
2683
+ // this.loadExternal(lang, 'register');
2648
2684
  this.loadFromWhitelabel(lang);
2649
2685
  }
2650
2686
  async apply() {