Translate
Note:
- Each time the Translate task is executed, it triggers an API request to the back-end. This call is deducted from the external calls limit available for the service from which the task is executed, based on your pricing plan.
- Only actual executions that receive a response are counted, not the number of times the task appears in the script. For example, if Translate task is placed inside a for each task that iterates five times, the number of external API calls consumed will be five, even though the task appears only once in the script.
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:
- "af" - Afrikaans
- "sq" - Albanian
- "ar" - Arabic
- "hy" - Armenian
- "as" - Assamese
- "az" - Azerbaijani
- "eu" - Basque
- "be" - Belarusian
- "bn" - Bengali
- "bg" - Bulgarian
- "ca" - Catalan
- "zh" - Chinese
- "zh-CN" - Chinese (Simplified)
- "zh-TW" - Chinese (Traditional)
- "hr" - Croatian
- "cs" - Czech
- "da" - Danish
- "nl" - Dutch
- "en" - English
- "eo" - Esperanto
- "et" - Estonian
- "fil" - Filipino
- "fi" - Finnish
- "fr" - French
- "gl" - Galician
- "ka" - Georgian
- "de" - German
- "el" - Greek
- "gu" - Gujarati
- "he" - Hebrew
- "hi" - Hindi
- "hu" - Hungarian
- "is" - Icelandic
- "id" - Indonesian
- "ga" - Irish
- "it" - Italian
- "ja" - Japanese
- "kn" - Kannada
- "km" - Khmer
- "ko" - Korean
- "lo" - Lao
- "lv" - Latvian
- "lt" - Lithuanian
- "mk" - Macedonian
- "mg" - Malagasy
- "ms" - Malay
- "ml" - Malayalam
- "mt" - Maltese
- "mr" - Marathi
- "no" - Norwegian
- "or" - Oriya
- "fa" - Persian
- "pl" - Polish
- "pt" - Portuguese
- "pa" - Punjabi
- "ro" - Romanian
- "ru" - Russian
- "sr" - Serbian
- "si" - Sinhala
- "sk" - Slovak
- "sl" - Slovenian
- "es" - Spanish
- "su" - Sundanese
- "sw" - Swahili
- "sv" - Swedish
- "tl" - Tagalog
- "ta" - Tamil
- "te" - Telugu
- "th" - Thai
- "tr" - Turkish
- "uk" - Ukrainian
- "ur" - Urdu
- "vi" - Vietnamese
- "yi" - Yiddish
Example
The following script translates the given English text into Spanish.
response = zoho.ai.translate("I will collect the package tomorrow", "es");
where:
responseThe 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");