feat: add message translation indicator#2958
Open
MartinCupela wants to merge 7 commits intomasterfrom
Open
Conversation
|
Size Change: +8.76 kB (+2.22%) Total Size: 404 kB
ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 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’suserLanguage) 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
message.textand the translation foruserLanguage(fromgetTranslatedMessageText). State is per message list (channel vs thread) viaMessageTranslationViewContext.message.i18n.languageis set, shows "Translated from <Language>" (e.g. "Translated from Italian") in the current locale; otherwise "Translated" or "Original" as appropriate.message.i18nexists, (2)setTranslationViewis available from context, and (3) there is a distinct translation foruserLanguage(i.e.getTranslatedMessageText({ language: userLanguage, message })exists and differs frommessage.text). Hidden when the visible text already matches the user language so there’s no redundant toggle.Integration
translationViewandsetTranslationViewfromMessageContext(filled byMessagefromMessageTranslationViewContext), anduserLanguageandtfromTranslationContext.getTranslatedMessageTextlives inMessageTranslationViewContextand is the single source for which text is "translated" for a given language.translation-indicatorgrid area (below reminder) inMessage.scssfor no-avatar, other-with-avatar, and me-with-avatar layouts.MessageTranslationIndicator; overridable viaMessageTranslationIndicatorinComponentContext. Rendered inMessageSimplewhenmessage.i18nis set.i18n
Translated from {{ language }},Original,View original,View translation, andlanguage/<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 thelanguage/<code>entries so the source language appears in the UI language (e.g. "Translated from Italian" in EN, "Tradotto da Italiano" in IT).