feat(messages): add translate message functionality#990
feat(messages): add translate message functionality#990salmonumbrella wants to merge 2 commits intochatwoot:developfrom
Conversation
Add long-press translate option for messages on iOS/Android: - Add translateMessage API call to ConversationService - Add translateMessage async action to conversationActions - Add Translate menu option in message long-press context menu - Update TextBubble to display translations with toggle - Add translations field to MessageContentAttributes type - Add i18n strings for translate feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add try-catch with .unwrap() for proper error handling - Show error toast when translation fails - Add loading state to prevent duplicate translation requests - Hide translate option for already-translated messages - Add null safety check for displayContent - Use Object.values() for cleaner translation extraction - Add TRANSLATE_MESSAGE_ERROR i18n string 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| translateMessage: createAsyncThunk<void, TranslateMessagePayload>( | ||
| 'conversations/translateMessage', | ||
| async (payload, { rejectWithValue }) => { | ||
| try { | ||
| await ConversationService.translateMessage(payload); |
There was a problem hiding this comment.
Update store with translated message data
The new translateMessage thunk only posts to the API and returns without dispatching any update, so no reducer ever adds the returned translations to the message in the store. TextBubble renders translated text only when contentAttributes.translations is present (lines 21‑33 in TextBubble.tsx), which means users will see a success toast but the message stays untranslated and the Translate menu remains available until the conversation is reloaded or updated externally. Wire the API response into addOrUpdateMessage or trigger a refetch so the translated content appears immediately.
Useful? React with 👍 / 👎.
|
Hi @muhsin-k — this one implements message translation functionality for the mobile app. Would be great to get a review if you have time. Happy to make adjustments based on your feedback! |
Summary
Changes
conversationService.ts- API method for translate endpointconversationActions.ts- Redux async thunkconversationTypes.ts- TypeScript payload typeMessage.ts- Added translations field to content attributesMessageItemContainer.tsx- Translate menu option with error handlingTextBubble.tsx- Translation display with toggleen.json- i18n stringsTest plan
🤖 Generated with Claude Code