machineTranslation.Document

Note:

The content in this help topic pertains to SuiteScript 2.1.

Object Description

A document returned from machineTranslation.createDocument(options) or machineTranslation.translate(options).

A document represents text that you send to or receive from the translation service. This object includes properties for the document ID (Document.id), document language (Document.language), and document text (Document.text).

When you create a document for translation using machineTranslation.createDocument(options), you can specify the source language of the document. If you don't specify the source language, the translation service detects the language automatically.

Note:

For best translation results, each document should contain text in a single language only. The translation service supports documents that use multiple languages, but the accuracy and completeness of the resulting translation may vary.

When passing documents to machineTranslation.translate(options) for translation, keep the following considerations in mind:

  • All document IDs must be unique.

    The maximum length for a single document is 5,000 characters.

  • The overall maximum length for all documents is 20,000 characters.

  • You can't pass an empty document (one where the Document.text property is empty).

  • If you pass a document that doesn't specify its source language (one where the Document.language property is null or undefined), the translation service detects the source language automatically.

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/machineTranslation Module

Methods and Properties

Document Object Members

Since

2025.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/machineTranslation Module Script Samples.

            // Add additional code
...

const myDocument1 = machineTranslation.createDocument({
    id: 'myDoc1',
    text: 'This is a document to be translated.'
});

const myDocument2 = machineTranslation.createDocument({
    id: 'myDoc2',
    text: 'This is another document to be translated.'
});

const translationResults = machineTranslation.translate({
    documents: [myDocument1, myDocument2],
    targetLanguage: machineTranslation.Language.CZECH
});

...
// Add additional code 

          

Related Topics

General Notices