N/machineTranslation Module

Note:

The content in this help topic pertains to SuiteScript 2.1.

Use the N/machineTranslation module to translate text into supported languages using generative AI. This module uses the Oracle Cloud Infrastructure (OCI) Language service to translate text in documents you provide. For more information about this service, see Language in the OCI documentation.

You can also use the N/llm Module to translate text by providing a suitable prompt when calling generative AI methods (such as llm.generateText(options)). However, using the N/machineTranslation module provides several benefits that make it a better choice for most translation use cases:

                                   

In This Help Topic

N/machineTranslation Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

machineTranslation.Document

Object

Server scripts

A document with untranslated text (to provide to machineTranslation.translate(options) for translation) or translated text (when part of a machineTranslation.Response object returned from the translation service).

machineTranslation.Error

Object

Server scripts

An error returned from the translation service.

machineTranslation.Response

Object

Server scripts

The response from the translation service, which contains machineTranslation.Document objects with translated text.

Method

machineTranslation.createDocument(options)

Object

Server scripts

Creates a document to be used as source content when calling the translation service.

machineTranslation.translate(options)

Object

Server scripts

Translates a set of documents into the specified language.

machineTranslation.translate.promise(options)

void

Server scripts

Asynchronously translates a set of documents into the specified language.

Enum

machineTranslation.Language

enum

Server scripts

Holds string values for the source language (when creating a document) or target language (when calling machineTranslation.translate(options)).

Use this enum to set the options.language parameter in machineTranslation.createDocument(options) or the options.targetLanguage parameter in machineTranslation.translate(options).

Document Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Document.id

string

Server scripts

The ID of the document.

Document.language

string

Server scripts

The language of the document.

Document.text

string

Server scripts

The content of the document.

Error Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Error.documentId

string

Server scripts

The ID of the document in which the error occurred.

Error.message

string

Server scripts

The error message returned from the translation service.

Response Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Response.errors

machineTranslation.Error[]

Server scripts

The errors returned from the translation service.

Response.results

machineTranslation.Document[]

Server scripts

The translated documents returned from the translation service.

Related Topics

General Notices