Search code examples
server-side-renderingspartacus-storefront

Spartacus not loading translations from local JSON files when using SSR


When loading translations from json files in the local assets folder,they can't be loaded by the Node server when using Server-side rendering.

Steps to reproduce:

  1. Add config for loading translations from local files to the
i18n: {
  backend: {
    loadPath: 'assets/translations/{{lng}}/{{ns}}.json',
  },
  chunks: translationChunksConfig,
  fallbackLang: 'en'
},
  1. Activate Server-side rendering using the Spartacus documentation
  2. Build an run the SSR application using yarn build:ssr and yarn serve:ssr
  3. Deactivate Javascript in the browser to see what is rendered on the server
  4. The translations are not loaded by the Node application: List item

One possible workaround is to just compile the translation into the code using Typescript files. But is there a way to also get this to work with JSON?

Thank you, Armin


Solution

  • While the issue was addressed before in in https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/6030, there has been a new bug observed: https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/6307. The latter is fixed, but not yet merged. I've just raised priority and hope we can deliver this soon in a patch release for 1.4.x.