Translate
Table of Contents
Description
The zoho.ai.translate task translates the input text into the specified language.
Note:
- 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. |
Note: The following are the supported languages and their language codes:
- "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
- "he" - Hebrew
Example
The following script translates the given English text into Spanish.
response = zoho.ai.translate("I will collect the package tomorrow", "es");
where:
response
The KEY-VALUE response that holds the translated text.
"I will collect the package tomorrow"
The TEXT that represents the input that needs to be translated.
"es"
The TEXT that represents language code to which the input text that needs to be translated. "es" represents Spanish.
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"
The TEXT that represents the input that needs to be translated.
"zh"
The TEXT that represents language code of the target language. "zh" represents Chinese.
"fr"
The TEXT that represents language code of the source language. "fr" represents French.
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");