We've run into some problems for our MultiSite Spartacus setup when doing I18n.
We'd like to have different translations for each site, so we put these on an API that can give back the messages dependent on the baseSite, eg:
backend.org/baseSiteX/messages?group=common
But the Spartacus setup doesn't let us pass the baseSite? We can pass{{lng}}
and{{ns}}
, but no baseSite.
See https://sap.github.io/spartacus-docs/i18n/#lazy-loading We'd could do it by overridingi18nextInit
, but I'm unsure how to achieve this.In the documentation, it says you can use
crossOrigin: true
in the config, but that does not seem to work. The type-checking say it's unsupported, and it still shows uw CORS-issues
Does someone have ideas for these problems?
Currently only language {{lng}} and chunk name {{ns}} are supported as dynamic params in the
i18n.backend.loadPath
config.To achieve your goal, you can implement a custom Spartacus
CONFIG_INITIALIZER
to will populate youri18n.backend.loadPath
config based on the value from theBaseSiteService.getActive()
:and provide it in your module (i.e. in app.module):
Note: the above solution assumes the active basesite is set only once, on app start (which is the case in Spartacus by default).