inveniosoftware / invenio-app-rdm

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

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

Open zzacharo opened 8 months ago

zzacharo commented 8 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 8 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 6 months ago

This issue was automatically marked as stale.

SarahW91 commented 6 months ago

Are there any news on this issue?

github-actions[bot] commented 4 months ago

This issue was automatically marked as stale.

SarahW91 commented 4 months ago

Are there any news?

github-actions[bot] commented 2 months ago

This issue was automatically marked as stale.

github-actions[bot] commented 5 days ago

This issue was automatically marked as stale.