API Docs

JavaScript-visible API for a translation session bound to a specific language pair.

Properties

typeName

string

The Swift type name, for JavaScript introspection.

sourceLanguage

string

BCP-47 identifier of the source language (e.g. "en").

targetLanguage

string

BCP-47 identifier of the target language (e.g. "fr").

Methods

translate(text) -> Promise<string>

Translate a string from the session's source language to its target language.

translate(text) -> Promise<string>
Name Type Description
text string The text to translate.
Promise<string>
A Promise resolving to the translated string,
const session = hs.translation.session("en", "fr")
session.translate("Hello, world!").then(result => console.log(result))
// "Bonjour le monde !"