diff --git a/.gitignore b/.gitignore index aa43ac2e..42e7f14b 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,6 @@ dist .idea .nx + +libs/angular-accelerator/tmp/ +libs/portal-integration-angular/tmp/ diff --git a/libs/angular-accelerator/ng-package.json b/libs/angular-accelerator/ng-package.json index 8cec3fcf..d07234bf 100644 --- a/libs/angular-accelerator/ng-package.json +++ b/libs/angular-accelerator/ng-package.json @@ -5,6 +5,11 @@ "entryFile": "src/index.ts" }, "assets": [ - "./assets/**" + "./assets/**", + { + "input": "tmp/primelocale/", + "glob": "{en,de}.json", + "output": "assets/i18n/primeng" + } ] } \ No newline at end of file diff --git a/libs/angular-accelerator/project.json b/libs/angular-accelerator/project.json index f3c4906b..6092b180 100644 --- a/libs/angular-accelerator/project.json +++ b/libs/angular-accelerator/project.json @@ -6,8 +6,22 @@ "tags": [], "projectType": "library", "targets": { + "copyPrimelocaleTranslations": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "mkdir -p libs/angular-accelerator/tmp/primelocale", + "cp node_modules/primelocale/de.json libs/angular-accelerator/tmp/primelocale/", + "cp node_modules/primelocale/en.json libs/angular-accelerator/tmp/primelocale/", + "sed -i 's/\"de\":/\"primeng\":/' libs/angular-accelerator/tmp/primelocale/de.json", + "sed -i 's/\"en\":/\"primeng\":/' libs/angular-accelerator/tmp/primelocale/en.json" + ], + "parallel": false + } + }, "build": { "executor": "@nx/angular:package", + "dependsOn": ["^build", "copyPrimelocaleTranslations"], "outputs": [ "{workspaceRoot}/dist/{projectRoot}" ], diff --git a/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.spec.ts b/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.spec.ts index 81aef3eb..128ad889 100644 --- a/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.spec.ts +++ b/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.spec.ts @@ -32,7 +32,7 @@ describe('CreateTranslateLoader', () => { }) describe('without TranslationCache parameter', () => { - it('should call httpClient get 3 times if a remoteBaseUrl is set and if global loading is finished', (done) => { + it('should call httpClient get 4 times if a remoteBaseUrl is set and if global loading is finished', (done) => { currentMfe$ = of({ remoteBaseUrl: 'remoteUrl' }) globalLoading$ = of(false) const translateLoader = environmentInjector.runInContext(() => @@ -40,7 +40,7 @@ describe('CreateTranslateLoader', () => { ) translateLoader.getTranslation('en').subscribe(() => { - expect(httpClientMock.get).toHaveBeenCalledTimes(3) + expect(httpClientMock.get).toHaveBeenCalledTimes(4) done() }) }) @@ -60,7 +60,7 @@ describe('CreateTranslateLoader', () => { }) describe('with TranslationCache parameter', () => { - it('should call httpClient get 3 times if a remoteBaseUrl is set and if global loading is finished', (done) => { + it('should call httpClient get 4 times if a remoteBaseUrl is set and if global loading is finished', (done) => { currentMfe$ = of({ remoteBaseUrl: 'remoteUrl' }) globalLoading$ = of(false) const translateLoader = createTranslateLoader( @@ -70,7 +70,7 @@ describe('CreateTranslateLoader', () => { ) translateLoader.getTranslation('en').subscribe(() => { - expect(httpClientMock.get).toHaveBeenCalledTimes(3) + expect(httpClientMock.get).toHaveBeenCalledTimes(4) done() }) }) diff --git a/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.ts b/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.ts index 2c87f34f..296ccde0 100644 --- a/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.ts +++ b/libs/angular-accelerator/src/lib/utils/create-translate-loader.utils.ts @@ -34,6 +34,13 @@ export function createTranslateLoader( Location.joinWithSlash(currentMfe.remoteBaseUrl, `onecx-portal-lib/assets/i18n/`), '.json' ), + // Primelocale Translations + new CachingTranslateLoader( + ts, + http, + Location.joinWithSlash(currentMfe.remoteBaseUrl, `onecx-portal-lib/assets/i18n/primeng/`), + '.json' + ), // translations of the app new CachingTranslateLoader( ts, diff --git a/libs/portal-integration-angular/ng-package.json b/libs/portal-integration-angular/ng-package.json index 1dfe9a64..fbf3b8b7 100644 --- a/libs/portal-integration-angular/ng-package.json +++ b/libs/portal-integration-angular/ng-package.json @@ -11,6 +11,11 @@ "input": "src/lib/core/directives", "glob": "**/*.scss", "output": "assets" + }, + { + "input": "tmp/primelocale/", + "glob": "{en,de}.json", + "output": "assets/i18n/primeng" } ] } \ No newline at end of file diff --git a/libs/portal-integration-angular/project.json b/libs/portal-integration-angular/project.json index fb8314d3..cf9a3106 100644 --- a/libs/portal-integration-angular/project.json +++ b/libs/portal-integration-angular/project.json @@ -6,8 +6,22 @@ "tags": [], "projectType": "library", "targets": { + "copyPrimelocaleTranslations": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "mkdir -p libs/portal-integration-angular/tmp/primelocale", + "cp node_modules/primelocale/de.json libs/portal-integration-angular/tmp/primelocale/", + "cp node_modules/primelocale/en.json libs/portal-integration-angular/tmp/primelocale/", + "sed -i 's/\"de\":/\"primeng\":/' libs/portal-integration-angular/tmp/primelocale/de.json", + "sed -i 's/\"en\":/\"primeng\":/' libs/portal-integration-angular/tmp/primelocale/en.json" + ], + "parallel": false + } + }, "build": { "executor": "@nx/angular:package", + "dependsOn": ["^build", "copyPrimelocaleTranslations"], "outputs": [ "{workspaceRoot}/dist/{projectRoot}" ], diff --git a/package-lock.json b/package-lock.json index eac33c3b..e07be212 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,7 @@ "ngx-color": "^9.0.0", "primeflex": "^3.3.1", "primeicons": "^7.0.0", + "primelocale": "^1.0.3", "primeng": "17.18.8", "rxjs": "7.8.1", "storybook": "^8.3.1", @@ -30719,6 +30720,16 @@ "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-7.0.0.tgz", "integrity": "sha512-jK3Et9UzwzTsd6tzl2RmwrVY/b8raJ3QZLzoDACj+oTJ0oX7L9Hy+XnVwgo4QVKlKpnP/Ur13SXV/pVh4LzaDw==" }, + "node_modules/primelocale": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/primelocale/-/primelocale-1.0.3.tgz", + "integrity": "sha512-a0VuhQLgUge4IJG2RKpMJSDYHuYIAd2kcqQy/quyx8UyM1/m7Uvt9hFKoFL0QAbZZyHIVHobVmGWAOJN8d7COQ==", + "license": "MIT", + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, "node_modules/primeng": { "version": "17.18.8", "resolved": "https://registry.npmjs.org/primeng/-/primeng-17.18.8.tgz", diff --git a/package.json b/package.json index 630e150a..c6dc87bd 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "ngx-color": "^9.0.0", "primeflex": "^3.3.1", "primeicons": "^7.0.0", + "primelocale": "^1.0.3", "primeng": "17.18.8", "rxjs": "7.8.1", "storybook": "^8.3.1",