The Translator interface of the Translator and Language Detector APIs contains all the associated translation functionality, including checking AI model availability, creating a new Translator instance, using it to create a translation, and more.
Instance properties
The input quota available to the browser for generating translations.
sourceLanguage Read only ExperimentalThe expected language of the input text to be translated.
targetLanguage Read only ExperimentalThe language that the input text will be translated into.
Static methods
Returns an enumerated value that indicates the availability of the AI model for the given Translator configuration.
create() ExperimentalCreates a new Translator instance from which to generate translations.
Instance methods
Destroys the Translator instance it is called on.
measureInputUsage() ExperimentalReports how much input quota would be used by a translation operation for a given text input.
translate() ExperimentalReturns a string containing a translation of the input string.
translateStreaming() ExperimentalGenerates a translation of the input string as a ReadableStream.