MessageTranslation
Message-row translation output, bilingual originals, pending progress, and retry status composed from explicit parts.
const ORIGINAL_MESSAGE = "Keep this original message available for the team.";
const TRANSLATED_MESSAGE = "让团队保留这条原始消息。";
export function MessageTranslationBilingualComposition() {
const [showOriginal, setShowOriginal] = useState(false);
return (
<MessageItem>
<MessageItemAvatarSlot>
<Avatar size="md" type="agent">
<AvatarImage src={MESSAGE_FIXTURE_AVATAR_SRC} alt="" />
<AvatarFallback>AT</AvatarFallback>
</Avatar>
</MessageItemAvatarSlot>
<MessageItemContent>
<MessageItemHeader>
<MessageItemSender>Atlas</MessageItemSender>
<MessageItemMeta>owner</MessageItemMeta>
<MessageItemTime>2:14 PM</MessageItemTime>
</MessageItemHeader>
<MessageItemBody>
<Markdown>{showOriginal ? ORIGINAL_MESSAGE : TRANSLATED_MESSAGE}</Markdown>
</MessageItemBody>
{!showOriginal ? (
<MessageItemTranslationOriginal>
<MessageItemTranslationOriginalLabel>Original</MessageItemTranslationOriginalLabel>
<Markdown>{ORIGINAL_MESSAGE}</Markdown>
</MessageItemTranslationOriginal>
) : null}
<MessageItemTranslationStatus>
<Languages size={12} />
<MessageItemTranslationAction
title={showOriginal ? "Original shown. Show translation" : "Translated. Show original"}
aria-label={showOriginal ? "Show translation" : "Show original"}
onClick={() => setShowOriginal((current) => !current)}
>
{showOriginal ? "Show translation" : "Show original"}
</MessageItemTranslationAction>
</MessageItemTranslationStatus>
</MessageItemContent>
</MessageItem>
);
}Render translated content in the message body and use the status action to switch between the translated and original text.
Keep the translation in the message body and compose the original-content region below it when both languages should remain visible.
Use indeterminate Progress while translated content is unavailable. Failure copy and retry behavior remain explicit children of the status row.
API#WIP
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"blockquote"> | — | Original-content blockquote for bilingual display. It shares Message Markdown's quote treatment; consumers choose when it is visible. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"div"> | — | Label inside the bilingual original-content container. Localization and visible copy stay consumer-owned. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"div"> | — | Translation status row for translated or pending states. Consumers compose icons, copy, and actions. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ProgressTrackProps | — | Translation progress track with theme-specific height treatment. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"div"> | — | Failed status row with failure treatment for copy and retry actions. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"button"> | — | Native button for original/translation toggles. The consumer owns callbacks and accessible labels. |
| Prop | Type | Default | Description |
|---|---|---|---|
...props | ComponentProps<"button"> | — | Native retry button with the failed-translation action treatment. The consumer owns callbacks, icons, copy, and accessible labels. |