Conversation
Samk13
left a comment
There was a problem hiding this comment.
Thanks for this @SarahW91! this is a nice addition, enabling translations definitely makes sense.
Before merging, I'd prefer we align this a bit more with what we already have in invenio-app-rdm:
- use the more recent compileCatalog.js pattern (async/await, proper error handling, normalized output, etc..),
- generate the translations index (like _generatedTranslations.js) instead of maintaining messages/index.js manually.
This will keep things consistent across packages and avoid extra maintenance later on.
| @@ -0,0 +1,38 @@ | |||
| // This file is part of React-Searchkit | |||
There was a problem hiding this comment.
Could we align the scripts with the implementation we already use in invenio-app-rdm? https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/compileCatalog.js
| @@ -0,0 +1,69 @@ | |||
| import TRANSLATE_AF from "./af/translations.json"; | |||
There was a problem hiding this comment.
There was a problem hiding this comment.
What I don't quite get is where the *.po files and language configs are coming from. Are they pulled from Transifex? because there seems to be no step to automatically generate them otherwise
There was a problem hiding this comment.
Yes, without Transifex yet, the new language has to be bootstrapped locally first.
In the current Invenio setup, init_catalog only adds the language to package.json; it does not create the .po file automatically.
Then extract_messages updates the extracted JSON and generates the English source files (translations.pot / messages/en/messages.po).
For any additional language, you still need to create messages//messages.po locally first, and only then compile_catalog can convert it to translations.json.
So the local dev flow is basically:
npm run init_catalog lang <lang>
npm run extract_messages # create/bootstrap messages/<lang>/messages.po
npm run compile_catalog lang <lang>Once Transifex is set up, that manual step (dev work) gets replaced by pulling the .po files from Transifex.
It makes me wonder where all these languages listed in this PR are coming from. Were they generated automatically, or are they copied manually from another package?
There was a problem hiding this comment.
I copied those over from https://github.com/inveniosoftware/react-invenio-deposit
There was a problem hiding this comment.
I updated the language list to be the same as on Transifex, created all *.po files and "compiled" the translations to generate the translation.json files.
What would still be missing now to merge this PR @Samk13 ?
c5af22a to
e87f8a6
Compare
Samk13
left a comment
There was a problem hiding this comment.
Thanks for this @SarahW91. I left few comments on smaller cleanup points, but from my testing, the PR looks good and seems ready to merge.
We will have another pass once we publish it on Transifex if something needs to be adjusted, as we can't push directly while developing.
And there are many places where the strings are not wrapped for translations, but you can choose if we add it here or in a follow-up PR e.g:
| "da", | ||
| "de", | ||
| "el", | ||
| "en", |
There was a problem hiding this comment.
After we test that it's working, we can remove all these, and keep en for now, when we set up the Transifex repo, it will update automatically
There was a problem hiding this comment.
But there's no harm in keeping them for now? I'd rather remove them in a separate PR after we see everything working together with Transifex
| @@ -0,0 +1,55 @@ | |||
| msgid "" | |||
There was a problem hiding this comment.
I think it's safe to delete all other languages other than en at this stage. Once we set up the Transifex, then we can do another pass.
| }, | ||
| "jest": { | ||
| "moduleNameMapper": { | ||
| "@translations/i18next": "<rootDir>/src/lib/i18next" | ||
| } | ||
| } |
There was a problem hiding this comment.
Should we remove this block?
It looks like it was added only to mirror the new Rollup alias for @translations/i18next, so Jest can resolve that import if tests cover those components.
I don’t think it’s exercised by the current test suite, so if we keep the alias it’s mostly defensive; if we drop the alias and use relative imports instead, this config can go away too.
WDYT?
There was a problem hiding this comment.
I don't know enough about this setup to feel confident in removing it. If someone with more experience thinks it's safe, I can do it, but for now I'd say we keep it.
I'm not sure if AriaLabels need translating. Where do they show up for users? Sorry if that's obvious, but I'm not usually a frontend dev ;) |
hmmm, I'd lean toward translating them. ARIA labels don't show up visually in the UI, but they're used by screen readers, so they're still part of the user experience for people relying on assistive technologies. If those users don't speak English, leaving ARIA labels untranslated can make navigation difficult or confusing. From an accessibility perspective, its usually best to include them in translations. That said, its not always enforced strictly all over our code base, so as I mentioned, we could also handle it in a follow up if thats easier. |

Description
I think it would be beneficial to enable translations for this module. There are some rather prominent components, e.g.
EmptyResultsthat can't be translated otherwise.Adding the necessary scripts and dependencies adds this ability, e.g.:
What do you think? If you are generally okay with this, I'll start marking all strings in the module as translatable.
Checklist