Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
6 tasks
zzacharo opened this issue Mar 21, 2024 · 6 comments
Open
6 tasks

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

zzacharo opened this issue Mar 21, 2024 · 6 comments

Comments

@zzacharo
Copy link
Member

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

  • We need to iterate through all the invenio modules that have an i18next.js file and the code changes
  • Test that image building works with the overridden translations
  • Test that local development works with the overridden translations
  • Test that there is no errors when there are no translations defined by the user
  • Test that you can create a completely new catalog and add custom translations
    • This might be not possible now because we rely on each modules defined languages in the respective package.json.

Open PRs

@SarahW91
Copy link

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

Copy link
Contributor

This issue was automatically marked as stale.

@github-actions github-actions bot added the stale No activity for more than 60 days. label May 22, 2024
@SarahW91
Copy link

Are there any news on this issue?

@Samk13 Samk13 removed the stale No activity for more than 60 days. label May 22, 2024
Copy link
Contributor

This issue was automatically marked as stale.

@github-actions github-actions bot added the stale No activity for more than 60 days. label Jul 22, 2024
@SarahW91
Copy link

Are there any news?

@SarahW91 SarahW91 removed the stale No activity for more than 60 days. label Jul 22, 2024
Copy link
Contributor

This issue was automatically marked as stale.

@github-actions github-actions bot added the stale No activity for more than 60 days. label Sep 21, 2024
@Samk13 Samk13 removed the stale No activity for more than 60 days. label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants