monkey-front-core 0.0.441 → 0.0.442

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.
@@ -3307,10 +3307,46 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3307
3307
  this.translateService.setDefaultLang('pt-BR');
3308
3308
  this.translateService.use('pt-BR');
3309
3309
  }
3310
- async apply(params, environment, change = false) {
3311
- const { monkeyecxService, monkeyecxCookieStorageService, monkeyecxErrorConfigService } = this;
3310
+ async apply(environment) {
3311
+ const { monkeyecxService, monkeyecxErrorConfigService } = this;
3312
+ const lang = `${environment?.lang || 'pt-BR'}`;
3313
+ try {
3314
+ const pathName = ['alerts', 'auth', 'register', 'shared'];
3315
+ const services = pathName?.map((name) => {
3316
+ return monkeyecxService
3317
+ ?.get(`${environment.urlAssets}/data/i18n/${name}/${lang}.json`)
3318
+ .pipe(take(1))
3319
+ .toPromise();
3320
+ });
3321
+ const externali18nData = await Promise.all(services);
3322
+ externali18nData?.forEach((config) => {
3323
+ const { data } = config;
3324
+ this.translateService.setTranslation('pt-BR', data, true);
3325
+ this.translateService.setTranslation(lang, data, true);
3326
+ });
3327
+ }
3328
+ catch (err) {
3329
+ // not to do
3330
+ }
3331
+ try {
3332
+ const currenti18n = await monkeyecxService
3333
+ ?.get(`${environment.localAssets}/i18n/${lang}.json`)
3334
+ .pipe(take(1))
3335
+ .toPromise();
3336
+ const { data } = currenti18n;
3337
+ this.translateService.setTranslation('pt-BR', data, true);
3338
+ this.translateService.setTranslation(lang, data, true);
3339
+ this.translateService.use(lang);
3340
+ }
3341
+ catch (err) {
3342
+ console.error(`i18n ${lang} not found!`);
3343
+ monkeyecxErrorConfigService.apply('i18n');
3344
+ throwError(err);
3345
+ }
3346
+ }
3347
+ async applyExternal(params, environment, change = false) {
3348
+ const { monkeyecxCookieStorageService, monkeyecxErrorConfigService, monkeyecxService } = this;
3312
3349
  let { i18n } = params;
3313
- const currentExternali18n = params?.externali18n?.[`${i18n?.lang || 'pt-BR'}`];
3314
3350
  const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
3315
3351
  if (cookie && !change) {
3316
3352
  i18n = JSON.parse(atob(cookie));
@@ -3337,12 +3373,11 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3337
3373
  // not to do
3338
3374
  }
3339
3375
  try {
3340
- const currenti18n = await monkeyecxService?.get(`${environment.localAssets}/i18n/${i18n?.lang}.json`).pipe(take(1)).toPromise();
3341
- const { lang } = currenti18n;
3342
- let { data } = currenti18n;
3376
+ const lang = `${i18n?.lang || 'pt-BR'}`;
3377
+ const currentExternali18n = params?.externali18n?.[`${lang}`];
3378
+ let data = {};
3343
3379
  if (currentExternali18n) {
3344
3380
  data = {
3345
- ...data,
3346
3381
  EXTERNAL: currentExternali18n
3347
3382
  };
3348
3383
  }
@@ -3708,10 +3743,11 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
3708
3743
  getWhiteLabelSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
3709
3744
  const { monkeyecxService, configSubject$, monkeyStyleGuideSettingsService, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyGTMConfigService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService, internalValidations } = this;
3710
3745
  const url = `${environment.urlAssets}/${monkeyecxCode.toLowerCase()}`;
3746
+ monkeyecxi18nConfigService.apply(environment);
3711
3747
  monkeyecxService
3712
3748
  ?.get(`${url}/white-label.json`)
3713
- ?.subscribe(async (config) => {
3714
- await monkeyecxi18nConfigService.apply(config, environment);
3749
+ ?.subscribe((config) => {
3750
+ monkeyecxi18nConfigService.applyExternal(config, environment);
3715
3751
  monkeyecxLogsConfigService.apply(config, configBootstrap, environment, identifyCode);
3716
3752
  monkeyEcxFeatureToggleService.apply(configSubject$, environment);
3717
3753
  monkeyGTMConfigService.apply(environment);