HSTranslationSession
TypeJavaScript-visible API for a translation session bound to a specific language pair.
Properties
Methods
translate(text) -> Promise<string>
Translate a string from the session's source language to its target language.
Declaration
translate(text) -> Promise<string>
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The text to translate. |
Returns
Promise<string>
A Promise resolving to the translated string,
Example
const session = hs.translation.session("en", "fr")
session.translate("Hello, world!").then(result => console.log(result))
// "Bonjour le monde !"