SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
740 stars 386 forks source link

Spike: lazy register Angular's locale data #1829

Open Platonn opened 5 years ago

Platonn commented 5 years ago

For date (and cxDate) pipe to work in the language other than en, we need to import and register locale data from @angular/common/locales/<localeId> in the shell app. For example:

import localeDe from '@angular/common/locales/de';
import localeJa from '@angular/common/locales/ja';
import localeZh from '@angular/common/locales/zh';
registerLocaleData(localeDe);
registerLocaleData(localeJa);
registerLocaleData(localeZh);

The drawbacks of such a solution are:

Maybe we can leverage the dynamic imports in the shell app for lazy loading. But it will require in tsconfig "module": "commonjs". The final solution have to also work in SSR.

andreas-becker commented 3 years ago

Hey @Platonn , any improvements on this? We're rolling out an international shop and try to find a dynamic solution to include/load the different languages (and date formats)