Repository navigation
Conversation
… passing them as props
|
PR in |
mkloeppe
left a comment
There was a problem hiding this comment.
This looks good. Default labels are used when no additional labels are provided through props.
| * only need to override the strings they actually want to translate. | ||
| */ | ||
| getLabels = () => { | ||
| return { ...defaultLabels, ...this.props.labels }; |
There was a problem hiding this comment.
| return { ...defaultLabels, ...this.props.labels }; | |
| const { labels } = this.props; | |
| return { ...defaultLabels, ...labels }; |
There was a problem hiding this comment.
Just to please the linter. Destructuring props before using them is the way.
Samk13
left a comment
There was a problem hiding this comment.
Thanks for this!
the labels are wired into the existing:
attachment button
upload message
preview tooltip/title
Should we also forward labels through RichInputField? It currently constructs RichEditor without passing that prop.
Have you tested changing languages after mounting is working? TinyMCE ignores initialization configuration changes after launch, and the toolbar labels are captured during setup.
Screenshots are always welcome showing the translated attachment button, upload message, and preview tooltip/dialog, plus an example confirming that omitted labels retain their English defaults. Thanks!


Description
Problem:
RichEditorhardcodes several user-facing strings ("Attach files", "Uploading file...", "Preview math equations", image alt text). Since this package has no translation workflow of its own, consuming packages cannot translate these strings, leading to non-translatable UI elements (e.g. the "Attach files" button ininvenio-requests' comment editor).This PR introduces an optional labels prop (object) with sensible English defaults, matching current behavior. Consuming packages can override any subset of labels with translated strings without needing to fork or patch the component. Fully backwards-compatible — no labels prop means unchanged behavior.
Disclaimer: I used Claude to help me with this PR since I'm not a React/JS specialist.
I tested this code locally and it works and allows to the mentioned labels to be translated, if props are passed by
invenio-requests. I'll create a separate PR there for passing the translatable strings.Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: