inveniosoftware / invenio-app-rdm

Turn-key research data management platform.
https://inveniordm.docs.cern.ch
MIT License
101 stars 143 forks source link

i18n: add support for user defined overrisable translations in react #2621

Open zzacharo opened 5 months ago

zzacharo commented 5 months ago

Proposed solution

We utilize the dynamic resource addition of i18next to dynamically add user defined translations in every module.

Currently, each module is creating their own i18next instance. We need to add the following lines


const { languages } = require("./package.json").config;

languages.forEach((lng) => {
  try {
    const overridenTranslations = require(`@overriden_translations/${lng}/LC_MESSAGES/translations.json`);
    i18next.addResourceBundle(lng, "translation", overridenTranslations);
  } catch (e) {
    console.log("No overridden translations found for language", lng);
  }
});

in each module that instantiates such an instance. The @overriden_translations is an alias that is defined in cookiecutter-invenio-rdm and points to the same location as the backend translations. If you want to override react translations you will need to create a translations.json file with all the keys for that specific language. The workflow would look like the following:

$ invenio-cli translations init -l <locale>
$ cd translations/<locale>/LC_messages
$ touch translations.json

Next steps

Open PRs

SarahW91 commented 5 months ago

There are some thoughts on this from the workshop in Münster gathered in this pad: https://pad.uni-muenster.de/dd3q7gQcQpqgDwzKocaQBA?both#

github-actions[bot] commented 3 months ago

This issue was automatically marked as stale.

SarahW91 commented 3 months ago

Are there any news on this issue?

github-actions[bot] commented 1 month ago

This issue was automatically marked as stale.

SarahW91 commented 1 month ago

Are there any news?