Skip to content

Conversation

@salmonumbrella
Copy link

Summary

  • Add long-press translate option to message context menu
  • Translations display inline with toggle to view original/translated
  • Uses app locale as target language automatically
  • Includes error handling, loading states, and proper i18n

Changes

  • conversationService.ts - API method for translate endpoint
  • conversationActions.ts - Redux async thunk
  • conversationTypes.ts - TypeScript payload type
  • Message.ts - Added translations field to content attributes
  • MessageItemContainer.tsx - Translate menu option with error handling
  • TextBubble.tsx - Translation display with toggle
  • en.json - i18n strings

Test plan

  • Long-press on a text message → see "Translate" option
  • Tap Translate → message translates, shows "View original" toggle
  • Tap "View original" → shows original text, toggle changes to "View translated"
  • Already-translated messages don't show Translate option
  • Error handling: disconnect network, try translate → shows error toast

🤖 Generated with Claude Code

salmonumbrella and others added 2 commits December 18, 2025 16:26
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 <[email protected]>
- 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 <[email protected]>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +258 to +262
translateMessage: createAsyncThunk<void, TranslateMessagePayload>(
'conversations/translateMessage',
async (payload, { rejectWithValue }) => {
try {
await ConversationService.translateMessage(payload);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@salmonumbrella
Copy link
Author

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!

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

Successfully merging this pull request may close these issues.

1 participant