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

Add support for overriding translations (message catalogs) #199

Open
lnielsen opened this issue Dec 9, 2021 · 2 comments
Open

Add support for overriding translations (message catalogs) #199

lnielsen opened this issue Dec 9, 2021 · 2 comments
Projects

Comments

@lnielsen
Copy link
Member

lnielsen commented Dec 9, 2021

We should add support so the default messages (text labels etc) could be overwritten in case an instance wants to use different text.

This could be achieve by adding a translations directory with message catalogs.

/translations
/translations/en
/translations/en/messages.po
/translations/en/messages.mo  

Invenio-CLI would need to symlink and compile the catalog into the Flask instance folder to be picked up:
https://github.com/inveniosoftware/invenio-i18n/blob/master/invenio_i18n/ext.py#L101-L110

Probably it should also support extra messages from local templates.

To be seen how this plays with domains etc.

@mb-wali mb-wali added this to Triage in I18N Dec 13, 2021
@lnielsen
Copy link
Member Author

lnielsen commented Apr 8, 2022

Also, this should take the React part into account. Suggestion from Zoe on the chat was to use https://github.com/i18next/i18next-chained-backend

@zguillen
Copy link

guys - I stabbed at this problem from all sorts of angles and failed to find an easy way for the RDM app to override translations defined in modules that get installed into it's node_modules. I ended up bailing on this task tho :( we needed other UI customizations to react-invenio-deposit beyond changing just the words so we needed to fork and modify the repo anyways. Where I ended up though was with 2 options, 1. let the RDM app expose it's overwritten translations files via an api endpoint and then the react-invenio-* modules can use that endpoint as a ‘chained backend’, or 2. Do some webpack magic to react-invenio-* modules so that overriding translations works sort of like how less vars get overridden. It seems like there should already be a webpack plugin for this sort of thing but I failed to find it. Something like this craco one I used years back that let me customize antd’s less vars by adding it to my webpack config and then creating the antd.customize.less file in my react app that had antd in it's node_modules: https://github.com/DocSpring/craco-antd but maybe that’s way overkill...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
I18N
Triage
Development

No branches or pull requests

2 participants