Translation card (Pro)
ProIncluded in $99A translation that shows its work: the source above, the result below, phrase by phrase, so pointing at any phrase lights the words it came from.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { TranslationCard } from "@/components/ui/chatcn/pro/translation-card"
<TranslationCard
from={{ lang: "en" }}
to={{ lang: "es-MX" }}
pairs={[
{ source: "Could you move the delivery", target: "¿Podría mover la entrega" },
{ source: " to Thursday morning?", target: " al jueves por la mañana?" },
]}
variants={{ formal, casual }}
onSwap={swap}
/>Pass the text as aligned phrases, the way a model returns them when asked for a phrase map; spaces live inside the phrases. Point at a phrase in either text, or tab into the translation and use the arrow keys, and its partner lights in the other text, so a reader can check the meaning rather than trust it. variants adds a tone switch; only the phrases that changed rise in. Each side has a listen button that speaks with the browser's voice for that language, and copy takes the translation. onSwap shows the swap button; translate again and pass the new sides. Language names come from Intl.DisplayNames unless you set name.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
from, to | TranslationSide | { lang, name? }; lang is BCP 47 |
pairs | TranslationPair[] | { source, target } phrases, in order |
variants | Record<string, TranslationPair[]> | Tones by name; two or more show the switch |
tone, defaultTone, onToneChange | string | The tone shown |
onSwap | () => void | Shows the swap button |
loading | boolean | The source shows and the translation is a placeholder |
labels | Partial<TranslationCardLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Tab | Into the translation, then on to the controls |
| Arrow left, right | The previous or next phrase; its source lights |
Accessibility
- Each text carries its
lang, so screen readers switch voice. - A focused phrase has its source as a tooltip; listen buttons are toggles named with the language.
- While loading, a status names the wait.
Motion
Lit phrases fade their tint in 150 ms. Changed phrases fade and unblur in 320 ms on a tone switch; the swap arrow turns. Reduced motion keeps the tint and drops the rest.