N/machineTranslation Module
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:
-
Reduced cost – The N/machineTranslation module supports unlimited translation requests, while the N/llm module provides only a limited number of LLM requests per month. When using the N/machineTranslation module, you don't need to provide Oracle Cloud Infrastructure (OCI) credentials to get unlimited usage, which helps to reduce the cost of your solutions.
-
No prompt engineering required – When you use the N/machineTranslation module, you don't need to write a prompt to generate translations. The module detects the source language automatically and translates provided documents into the language you specify in your request.
-
More straightforward limits – The N/machineTranslation module limits the length of each provided document to 5,000 characters, and it also limits the total length of all provided documents to 20,000 characters. The N/llm module provides limits that are based on tokens and the context window of the LLM you use, which can be more difficult to estimate.
-
More supported languages – The N/machineTranslation module can translate text into additional languages that may not be supported by LLMs and the N/llm module.
-
More reliable translations – The N/machineTranslation module uses the OCI Language service, which is designed for specific natural language processing (NLP) tasks, including translation. It uses pretrained models that can offer more predictable and reliable translation results compared to the N/llm module. The N/llm module uses the OCI Generative AI service, which is designed for content generation and may provide more varied translation results compared to a dedicated translation service.
In This Help Topic
N/machineTranslation Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
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). |
|
Object |
Server scripts |
An error returned from the translation service. |
||
Object |
Server scripts |
The response from the translation service, which contains machineTranslation.Document objects with translated text. |
||
Method |
Object |
Server scripts |
Creates a document to be used as source content when calling the translation service. |
|
Object |
Server scripts |
Translates a set of documents into the specified language. |
||
void |
Server scripts |
Asynchronously translates a set of documents into the specified language. |
||
Enum |
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 |
Document Object Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string |
Server scripts |
The ID of the document. |
|
string |
Server scripts |
The language of the document. |
||
string |
Server scripts |
The content of the document. |
Error Object Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Property |
string |
Server scripts |
The ID of the document in which the error occurred. |
|
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 |
Server scripts |
The errors returned from the translation service. |
||
Server scripts |
The translated documents returned from the translation service. |