machineTranslation.createDocument(options)
The content in this help topic pertains to SuiteScript 2.1.
Method Description |
Creates a document with the specified ID, source language, and text content. A document represents text to translate using machineTranslation.translate(options). When you create a document for translation, 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:
|
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2025.1 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string |
required |
The ID of the document. |
2025.1 |
|
string |
required |
The text of the document. |
2025.1 |
|
string |
optional |
The language of the document. Use values from the machineTranslation.Language enum to set the value of this parameter. If you don't specify the document language, the translation service detects the language automatically when you pass the document to machineTranslation.translate(options). |
2025.1 |
Errors
Error Code |
Thrown If |
---|---|
|
The |
Syntax
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