files/en-us/web/api/translator/create_static/index.md
{{APIRef("Translator and Language Detector APIs")}}{{SeeCompatTable}}{{securecontext_header}}
The create() static method of the {{domxref("Translator")}} interface creates a new Translator instance that can be used to translate text.
[!NOTE] The
create()method requires transient activation, that is, it must be invoked in response to a user action such as a mouse click or button press.
Translator.create(options)
options
Translator. Possible values include:
sourceLanguage
targetLanguage
monitor {{optional_inline}}
signal {{optional_inline}}
create() operation to be aborted via the associated {{domxref("AbortController")}}. The exact effect is dependant on when {{domxref("AbortController.abort()")}} is called:
abort() is called before the create() promise resolves, the create() operation is cancelled.abort() is called after the create() promise fulfills, it has the same effect as calling {{domxref("Translator.destroy()")}}: The resources assigned to the resulting Translator instance are released, and any ongoing and subsequent Translator method calls will reject with an AbortError.A {{jsxref("Promise")}} that fulfills with a Translator object instance.
InvalidStateError {{domxref("DOMException")}}
NetworkError {{domxref("DOMException")}}
NotAllowedError {{domxref("DOMException")}}
create() method wasn't called via {{glossary("transient activation")}}.NotSupportedError {{domxref("DOMException")}}
sourceLanguage or targetLanguage are invalid, or not supported. This is the case if the specified sourceLanguage and targetLanguage are the same.sourceLanguage and targetLanguage is not available.OperationError {{domxref("DOMException")}}
Translator creation failed for any other reason.Translator creationconst translator = await Translator.create({
sourceLanguage: "en",
targetLanguage: "ja",
});
{{Specifications}}
{{Compat}}