Translate
Table of Contents
Description
The zoho.ai.translate task translates the input text into the specified language.
- The prediction results may not be accurate, which is also the case with any AI prediction. However, we are working on improving this.
- The prediction results are dynamic. The same script may produce different outcomes at different times based on how much the machine has learned.
Syntax
<response> = zoho.ai.translate(<input_text>, <target_language>, [source_language]);
where:
Params | Data type | Description |
<response> | KEY-VALUE | Holds the translated text. |
<input_text> | TEXT | The input text that needs to be translated |
<target_language> | TEXT | The two-letter ISO code representing the language to which the input text needs to be translated. |
[source_language] (optional) | TEXT | The two-letter ISO code representing the language in which the input text is supplied. If no value is supplied to this parameter it assumes "en" representing English. |
- "en" - English
- "de" - German
- "zh" - Chinese
- "ru" - Russian
- "it" - Italian
- "pt" - Portuguese
- "es" - Spanish
- "fr" - French
- "ar" - Arabic
- "cs" - Czech
- "hu" - Hungarian
- "nl" - Dutch
- "pl" - Polish
- "sv" - Swedish
- "ja" - Japanese
- "ro" - Romanian
Example
The following script translates the given English text into Spanish.
response = zoho.ai.translate("I will collect the package tomorrow", "es");
where:
response
"I will collect the package tomorrow"
"es"
Example 2
The following script translates the given French text into Chinese.
response = zoho.ai.translate("Je vous remercie de la session", "zh","fr");
where:
"Je vous remercie de la session"
"zh"
"fr"
Response Format
Success Response
The success response will be returned in the following format:.
{
"source_language": "fr",
"status": {
"code": 200,
"message": "success"
},
"target_language": "zh",
"translation": [
{
"source": "Je vous remercie de la session",
"translate": "谢谢本届会议。"
}
]
}
Note: To fetch the translated text from the response, use the following script:info response.get("translation").get(0).get("translate");