monkey-front-core 0.0.206 → 0.0.209

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.
@@ -2731,36 +2731,55 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
2731
2731
  this.translateService.setDefaultLang('pt-BR');
2732
2732
  this.translateService.use('pt-BR');
2733
2733
  }
2734
- apply(params, environment, change = false) {
2734
+ async apply(params, environment, change = false) {
2735
2735
  const { monkeyecxService, monkeyecxCookieStorageService, monkeyecxErrorConfigService } = this;
2736
2736
  let { i18n } = params;
2737
- const externali18n = params?.externali18n?.[`${i18n?.lang || 'pt-BR'}`];
2737
+ const currentExternali18n = params?.externali18n?.[`${i18n?.lang || 'pt-BR'}`];
2738
2738
  const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
2739
2739
  if (cookie && !change) {
2740
2740
  i18n = JSON.parse(atob(cookie));
2741
2741
  }
2742
2742
  else {
2743
2743
  monkeyecxCookieStorageService.setCookie('monkey-app-locale', btoa(JSON.stringify(i18n)), environment);
2744
- if (!cookie)
2745
- change = true;
2746
2744
  }
2747
- monkeyecxService?.get(`${environment.localAssets}/i18n/${i18n?.lang}.json`)?.subscribe((config) => {
2748
- const { lang } = config;
2749
- let { data } = config;
2750
- if (externali18n) {
2745
+ try {
2746
+ const currenti18n = await monkeyecxService?.get(`${environment.localAssets}/i18n/${i18n?.lang}.json`).pipe(take(1)).toPromise();
2747
+ const { lang } = currenti18n;
2748
+ let { data } = currenti18n;
2749
+ if (currentExternali18n) {
2751
2750
  data = {
2752
2751
  ...data,
2753
- EXTERNAL: externali18n
2752
+ EXTERNAL: currentExternali18n
2754
2753
  };
2755
2754
  }
2756
2755
  this.translateService.setTranslation('pt-BR', data, true);
2757
2756
  this.translateService.setTranslation(lang, data, true);
2758
2757
  this.translateService.use(lang);
2759
- }, (err) => {
2758
+ }
2759
+ catch (err) {
2760
2760
  console.error(`i18n ${i18n?.lang} not found!`);
2761
2761
  monkeyecxErrorConfigService.apply('i18n');
2762
2762
  throwError(err);
2763
- });
2763
+ return;
2764
+ }
2765
+ try {
2766
+ const externali18nPaths = params?.i18n?.paths || [];
2767
+ const services = externali18nPaths?.map((url) => {
2768
+ return monkeyecxService?.get(`${url}/${i18n?.lang}.json`).pipe(take(1)).toPromise();
2769
+ });
2770
+ if (!services?.length)
2771
+ return;
2772
+ const externali18nData = await Promise.all(services);
2773
+ externali18nData?.forEach((config) => {
2774
+ const { lang } = config;
2775
+ const { data } = config;
2776
+ this.translateService.setTranslation('pt-BR', data, true);
2777
+ this.translateService.setTranslation(lang, data, true);
2778
+ });
2779
+ }
2780
+ catch (err) {
2781
+ // not to do
2782
+ }
2764
2783
  }
2765
2784
  }
2766
2785
  MonkeyEcxi18nConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, deps: [{ token: MonkeyEcxService }, { token: i1$1.TranslateService }, { token: MonkeyEcxCookieStorageService }, { token: MonkeyEcxErrorConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -4504,7 +4523,6 @@ class MonkeyEcxFeatureByProgramDirective {
4504
4523
  ngOnInit() {
4505
4524
  if (!this.feature)
4506
4525
  return;
4507
- this.elementRef.nativeElement.style.display = 'none';
4508
4526
  this.cdr.detectChanges();
4509
4527
  this.handleDisplay();
4510
4528
  }