-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow for tree-shaking unused langauges translations in custom …
…apps (#19799) - add a lot of missing `index.ts` files to re-export JSON translations in TS for new langauges - update `translations.ts` barrel files, to export each langauge in a separate public API members (to allow for treeshaking unused langauges). Note: it preservers the old feature prefix (e.g. `asmTranslations` -> `asmTranslationsEn`, `asmTranslationsDe`, ...) - deprecate the the old wrapper consts e.g. `asmTranslations` (and moved those deprecated tokens to `public_api.ts` files from `translations.ts` files) - remove from the old wrapper consts e.g. `asmTranslations` langauges other than `en` (in other words: revert the change made previously on the branch [epic/tew-translation](https://github.com/SAP/spartacus/tree/epic/tew-translation) which added 3 other langauges into those wrapper objects) - add a new function `extractTranslationChunksConfig()` in `@spartacus/core` and use it in every library for creating chunks config in their `translation.ts` files. It extracts the chunks config from the translations assets automatically. So no more need to type chunks config manually. - fix our installation schematics, to use the new recommended syntax in the scaffolded features e.g.: ```diff - resources: asmTranslations, + resources: { en: asmTranslationsEn } ``` By the way: - noticed a broken chunks mapping for the cpqQuote feature. now should be fixed since using function `extractTranslationChunksConfig()` - noticed a typo in the existing old chunk name `myAccountV2NotifiationPerference`, HOWEVER I didn't fix it in this PR - it should be done in a separate PR - noticed yet another typo in existing file name `my-account-v2-notification-perference.json` (btw. it's a different typo than the above chunk name), HOWEVER I didnt fix it in this PR - noticed some i18n JSON files don't use camelCase, but kebab-case, HOWEVER I didn't fix it in this PR - it should be done in a separate PR The reason I didn't want to fix those things by the way is: - it might affect the workflow of the TEW team, and I'd need to first double check with them - it's not related to this PR's main purpose (three-shaking) TODO - [x] fix unit tests and Jest snapshots in schematics - [x] use it this way also in our storefrontapp - [ ] write doc input for the migration docs (to use specific langauges) related to https://jira.tools.sap/browse/CXSPA-9131 **QA steps** 1. checkout to this branch 2. build libs 3. publish to verdaccio 4. create a new app `npx @angular/cli@17 new test-app --standalone=false --ssr=false` 6. in the new app, install sparatcus from verdaccio `ng add @spartacus/[email protected]. 0-1 --baseUrl="https://40.76.109. 9:9002" --ssr` AND PLEASE SELECT ALL possible features and integrations in the interactive prompt 7. In VsCode search everywhere (Cmd+Shift+F) for the phrase `resources:` and verify that everywhere in every feature module we use the new approach with explicit EN translations 8. In some of those modules try to change the approach to old `translations` wrapper object and verify it's `@deprecated` (crossed out in VSCode) 9. in spartacus-configuration.module.ts add also German translations for the main translations: ```ts i18n: { resources: { en: translationsEn, de: translationsDe }, ``` 10. in spartacus-configuration.module.ts add this config (it's needed for later to run `http-server`) ```ts provideConfig(<SiteContextConfig>{ context: { baseSite: ['electronics-spa', 'apparel-uk-spa'], currency: ['USD', 'GBP'], language: ['en', 'de'], }, }), ``` 11. `ng build` (or for interactive mode run `npm run watch`). Don't try `ng serve --configuration=production` - it doesn't have so well tree shaking as `ng build` 12. `npx http-server dist/test-app/browser` (or for interactive mode run in another terminal `npx nodemon --watch "./dist/test-app/browser" --exec "npx http-server './dist/$test-app/browser'" --ext "*"` 13. In Chrome open http://127.0.0.1:8080/ (8080! not 4200 port!) 14. In devtools Sources tab do the search (Cmd+F) 15. paste this search phrase `ariaLabelSuggestions` and verify that in the loaded `main.js` file there are only 2 langauges (EN and DE which you have enabled in steps above) with translations for this key <img width="512" alt="image" src="https://github.com/user-attachments/assets/f6be33e1-7cc7-4e2a-bde3-ecdf4a19db81" />
- Loading branch information
Showing
861 changed files
with
8,832 additions
and
1,390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const cs = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asm from './asm.json'; | ||
|
||
export const de = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asm from './asm.json'; | ||
|
||
export const en = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const es = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const es_CO = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const fr = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const hi = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const hu = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const id = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const it = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asm from './asm.json'; | ||
|
||
export const ja = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const ko = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const pl = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const pt = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const ru = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asm from './asm.json'; | ||
|
||
export const zh = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asm from './asm.json'; | ||
export const zh_TW = { | ||
asm, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/cs/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const cs = { | ||
asmCustomer360, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
|
||
export const de = { | ||
asmCustomer360, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
|
||
export const en = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/es/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const es = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/es_CO/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const es_CO = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/fr/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const fr = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/hi/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const hi = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/hu/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const hu = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/id/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const id = { | ||
asmCustomer360, | ||
}; |
11 changes: 11 additions & 0 deletions
11
feature-libs/asm/customer-360/assets/translations/it/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <[email protected]> | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import asmCustomer360 from './asmCustomer360.json'; | ||
export const it = { | ||
asmCustomer360, | ||
}; |
Oops, something went wrong.