MessageTranslation

Message-row translation output, bilingual originals, pending progress, and retry status composed from explicit parts.

Preview#

AT
Atlasowner2:14 PM

让团队保留这条原始消息。

AT
Atlasowner2:14 PM

让团队保留这条原始消息。

Original

Keep this original message available for the team.

AT
Atlasowner2:14 PM
x
Translating…
AT
Atlasowner2:14 PM

Keep this original message available for the team.

Translation unavailable
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>
  );
}

Translated output#

Render translated content in the message body and use the status action to switch between the translated and original text.

AT
Atlasowner2:14 PM

让团队保留这条原始消息。

Bilingual output#

Keep the translation in the message body and compose the original-content region below it when both languages should remain visible.

AT
Atlasowner2:14 PM

让团队保留这条原始消息。

Original

Keep this original message available for the team.

Pending and failure#

Use indeterminate Progress while translated content is unavailable. Failure copy and retry behavior remain explicit children of the status row.

AT
Atlasowner2:14 PM
x
Translating…
AT
Atlasowner2:14 PM

Keep this original message available for the team.

Translation unavailable

API#WIP

PropTypeDefaultDescription
...propsComponentProps<"blockquote">Original-content blockquote for bilingual display. It shares Message Markdown's quote treatment; consumers choose when it is visible.
PropTypeDefaultDescription
...propsComponentProps<"div">Label inside the bilingual original-content container. Localization and visible copy stay consumer-owned.
PropTypeDefaultDescription
...propsComponentProps<"div">Translation status row for translated or pending states. Consumers compose icons, copy, and actions.
PropTypeDefaultDescription
...propsProgressTrackPropsTranslation progress track with theme-specific height treatment.
PropTypeDefaultDescription
...propsComponentProps<"div">Failed status row with failure treatment for copy and retry actions.
PropTypeDefaultDescription
...propsComponentProps<"button">Native button for original/translation toggles. The consumer owns callbacks and accessible labels.
PropTypeDefaultDescription
...propsComponentProps<"button">Native retry button with the failed-translation action treatment. The consumer owns callbacks, icons, copy, and accessible labels.