machineTranslation.translate(options)
The content in this help topic pertains to SuiteScript 2.1.
Method Description |
Translates the provided documents into the specified language. Unlike methods in the N/llm Module, this method supports unlimited translation requests and doesn't use a shared free usage pool. You also don't need to provide Oracle Cloud Infrastructure (OCI) credentials to get unlimited usage. When passing documents (created using machineTranslation.createDocument(options)) to this method for translation, keep the following considerations in mind:
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. As a best practice, you should create documents using machineTranslation.createDocument(options) and pass those documents to this method. However, you can also provide an ad hoc object that includes values for the
|
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
100 |
Module |
|
Since |
2025.1 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
required |
The documents to translate. |
2025.1 |
|
|
string |
required |
The language to translate the specified documents into. Use values from the machineTranslation.Language enum to set the value of this parameter. |
2025.1 |
|
number |
optional |
The timeout period to wait for a response from the translation service, in milliseconds. The default value is 30,000 (30 seconds). |
2025.1 |
Errors
Error Code |
Thrown If |
---|---|
|
One of the documents specified in the |
|
Two or more documents specified in the |
|
One of the documents specified in the |
|
The total length of all documents specified in the |
|
One of the documents specified in 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