monkey-front-core 0.0.208 → 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.
- package/esm2020/lib/core/interfaces/monkeyecx-config.mjs +1 -1
- package/esm2020/lib/core/services/config/monkeyecx-i18n-config.service.mjs +32 -12
- package/fesm2015/monkey-front-core.mjs +45 -24
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +30 -11
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interfaces/monkeyecx-config.d.ts +1 -0
- package/lib/core/services/config/monkeyecx-i18n-config.service.d.ts +1 -1
- package/monkey-front-core-0.0.209.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.208.tgz +0 -0
|
@@ -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
|
|
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
|
-
|
|
2748
|
-
const
|
|
2749
|
-
|
|
2750
|
-
|
|
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:
|
|
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
|
-
}
|
|
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 });
|