Skip to content

Comments

feat: add message translation indicator#2958

Open
MartinCupela wants to merge 7 commits intomasterfrom
feat/add-message-translation-indicator
Open

feat: add message translation indicator#2958
MartinCupela wants to merge 7 commits intomasterfrom
feat/add-message-translation-indicator

Conversation

@MartinCupela
Copy link
Contributor

@MartinCupela MartinCupela commented Feb 20, 2026

🎯 Goal

Closes REACT-795

Adds a message translation indicator for messages with message.i18n: it shows whether the user is viewing the original or translated text (in the app’s userLanguage) and lets them switch. The indicator is rendered in the message grid below the reminder row and follows existing message metadata styling.

6AGj.webm

Features

  • Toggle: "View original" / "View translation" switches between message.text and the translation for userLanguage (from getTranslatedMessageText). State is per message list (channel vs thread) via MessageTranslationViewContext.
  • Label: When showing translated text and message.i18n.language is set, shows "Translated from <Language>" (e.g. "Translated from Italian") in the current locale; otherwise "Translated" or "Original" as appropriate.
  • Visibility: Renders only when (1) message.i18n exists, (2) setTranslationView is available from context, and (3) there is a distinct translation for userLanguage (i.e. getTranslatedMessageText({ language: userLanguage, message }) exists and differs from message.text). Hidden when the visible text already matches the user language so there’s no redundant toggle.
  • Virtualization: - the MessageTranslationViewContext provider is rendered inside the message lists due to the fact that we need to persist the toggle state in virtualized msg list - messages are getting unmounted -> loosing state.

Integration

  • Context: Uses translationView and setTranslationView from MessageContext (filled by Message from MessageTranslationViewContext), and userLanguage and t from TranslationContext. getTranslatedMessageText lives in MessageTranslationViewContext and is the single source for which text is "translated" for a given language.
  • Grid: Uses the translation-indicator grid area (below reminder) in Message.scss for no-avatar, other-with-avatar, and me-with-avatar layouts.
  • Slot: Default component is MessageTranslationIndicator; overridable via MessageTranslationIndicator in ComponentContext. Rendered in MessageSimple when message.i18n is set.

i18n

  • Uses/adds: Translated from {{ language }}, Original, View original, View translation, and language/<code> for all Stream-supported language codes (translation docs). All 12 SDK locales (en, de, es, fr, hi, it, ja, ko, nl, pt, ru, tr) include the language/<code> entries so the source language appears in the UI language (e.g. "Translated from Italian" in EN, "Tradotto da Italiano" in IT).

@github-actions
Copy link

Size Change: +8.76 kB (+2.22%)

Total Size: 404 kB

Filename Size Change
./dist/Channel-B9FRZd2R.js 0 B -20.8 kB (removed) 🏆
./dist/Channel-C2QEtMrb.js 20.8 kB +20.8 kB (new file) 🆕
./dist/ChannelPreview-Dn0nDD9T.js 0 B -6.84 kB (removed) 🏆
./dist/ChannelPreview-DVtJZpTq.js 7.15 kB +7.15 kB (new file) 🆕
./dist/cjs/emojis.js 2.97 kB -3 B (-0.1%)
./dist/cjs/experimental.js 3.62 kB +1 B (+0.03%)
./dist/cjs/index.js 206 kB +8.48 kB (+4.3%)
./dist/css/index.css 34.6 kB +393 B (+1.15%)
./dist/limits-D_hGb90b.js 62.4 kB +62.4 kB (new file) 🆕
./dist/limits-DABobzwQ.js 0 B -62.8 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size
./dist/audioProcessing-BbOs2wMd.js 1.32 kB
./dist/cjs/mp3-encoder.js 1.27 kB
./dist/css/v2/emoji-mart.css 1.84 kB
./dist/css/v2/emoji-replacement.css 300 B
./dist/css/v2/index.css 39.4 kB
./dist/css/v2/index.layout.css 22.8 kB

compressed-size-action

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