This method can be used to change the language the local participant receives translations in.
Only this device is affected; every other participant keeps the language they chose.
The change takes effect once the server echoes it back on onTranslationLanguageChanged. Until then, onTranslationText keeps delivering the previous language.
The target language code — a plain code such as "es", a regional variant such as "en-GB" or "pt-BR", a script variant such as "zh-Hant", or "multi".
It must be one of the codes listed under Supported Languages. Nothing in the SDK validates it — an unsupported code is not rejected: the call resolves and onTranslationText simply stops delivering text for this device.
This method can be used to start real-time translation for the room.
All participants, including the local participant, will receive the TRANSLATION_STARTING state in the onTranslationStateChanged event.
A participant who joins a room that is already translating receives no second TRANSLATION_STARTED, so drive the UI from this event and from the resolution of your own startTranslation() call.
Each participant still receives only the language they asked for, so starting translation is a room-level action while the language is a per-device one.
Optionalconfig: object
Optional translation configuration, forwarded to the server unchanged. Omit it — as the calls below do — to use the room's defaults.
This method can be used to stop the ongoing real-time translation.
Translation stops for the whole room, not only for the participant who called it. All participants, including the local participant, will receive the TRANSLATION_STOPPING state in the onTranslationStateChanged event, and the last utterances may still arrive on onTranslationText before it settles on TRANSLATION_STOPPED.
The language code that participant now receives translations in.
ID of the participant whose translation language changed.
status has following values:
TRANSLATION_STARTING - Realtime Translation is in starting phase and hasn't started yet.TRANSLATION_STARTED - Realtime Translation has started successfully.TRANSLATION_STOPPING - Realtime Translation is in stopping phase and hasn't stopped yet.TRANSLATION_STOPPED - Realtime Translation has stopped successfully.import { useTranslation } from "@videosdk.live/react-native-sdk";
function onTranslationStateChanged(data) {
const { status } = data;
if (status === "TRANSLATION_STARTING") {
console.log("Realtime translation is starting");
} else if (status === "TRANSLATION_STARTED") {
console.log("Realtime translation has started");
} else if (status === "TRANSLATION_STOPPING") {
console.log("Realtime translation is stopping");
} else if (status === "TRANSLATION_STOPPED") {
console.log("Realtime translation has stopped");
}
}
useTranslation({
onTranslationStateChanged,
});
Language code this text was translated into — the one the local participant asked for with translationLanguage or changeTranslationLanguage.
ID of the participant whose speech was translated.
Language code the participant was speaking in — the speakingLanguage they joined with.
Name of the participant whose speech was translated.
Translated text content.
Timestamp (in milliseconds since epoch) when the translation was generated.
Type of translation event:
partial - The service is still revising this utterance. Consecutive partial lines rewrite the same utterance rather than continuing it, so replace the last line drawn instead of appending.full - The utterance has settled. The settled text is not always an extension of the last partial, so append to a transcript only on full.
useTranslationprovides reactive APIs and events to manage real-time translation and receive translated text within a room.Each participant declares two languages on the
RoomProviderconfig: speakingLanguage, the language they speak, and translationLanguage, the language they want to receive. A participant with notranslationLanguagereceives no translated text, even while translation is running for the room.One translation service runs for the whole room, but each device receives only the language it asked for, so a device never receives two languages for the same speech. The receive language can be changed at any time with changeTranslationLanguage; the speaking language is fixed once the room is joined.
A failure that happens after translation has started is delivered as VideoSDKError.TRANSLATION_FAILED on
useRoom'sonError, not by any of the methods below.