# Image Translation Standard Version API Reference

### Image Translation

<mark style="color:green;">`GET/POST`</mark> `/ai/image/translation`

{% tabs %}
{% tab title="Description" %}
Image Translation is specially designed for e-commerce images, supporting 198 languages. It accurately handles complex text layouts within images and ensures that the translated content matches the image content. This helps e-commerce platforms and developers easily achieve multilingual conversion and presentation of image content.
{% endtab %}
{% endtabs %}

### Request Parameter

<table><thead><tr><th width="149.33334350585938">Parameter</th><th width="110.851806640625">Type</th><th width="107.1851806640625">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>imageUrl</code></td><td>String</td><td>Yes</td><td><p>Source image URL</p><p>Image requirements：No more than 4000x4000 pixel. Size up to 10MB. Supporting png, jpeg, jpgm, bmp, webp.</p><p><code>Sample:</code> <a href="http://example.jpg/"><code>http://example.jpg/</code></a></p></td></tr><tr><td><code>sourceLanguage</code></td><td>String</td><td>Yes</td><td><p>Source language code. Supporting languages as the appendix shows.</p><p><code>Sample: en</code></p></td></tr><tr><td><code>targetLanguage</code></td><td>String</td><td>Yes</td><td><p>Target language code. Supporting languages as the appendix shows.</p><p><code>Sample: ko</code></p></td></tr><tr><td><code>translatingTextInTheProduct</code></td><td>Boolean</td><td>No</td><td><p>Choose whether to translate the text within the main subject of images; this allows you to protect and avoid translating embedded information such as product names.</p><p>As shown in the example image, the text in the red box represents the text on the main subject, while the text in the blue box represents text not on the main subject.</p><p><img src="https://3421660005-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcXGtrD26wbOKouIXD83g%2Fuploads%2FGjpvtz8t9B7fiXEpzVRg%2F10.png?alt=media&#x26;token=90a496fb-9971-4a95-9c22-5be365c3b34e" alt="" data-size="original"></p><p><code>Sample：false</code></p></td></tr><tr><td><code>useImageEditor</code></td><td>Boolean</td><td>No</td><td><p>Whether it return layout information such as the position, font, and color of the text.  This is used to obtain data for secondary editing when integrating with the image editor. After receiving the returned ID, you can call <a href="https://docs.aidc-ai.com/aidge-resource/api-reference/e-commerce-information-translation/image-translation/image-translation-data-for-editing-api-reference">image translation data for editing API</a> to get the complete parameter information.</p><p><code>Sample: false</code></p></td></tr><tr><td><code>translatingBrandInTheProduct</code></td><td>Boolean</td><td>No</td><td><p>Choose whether to translate brand names in images. This can help you protect brand name information and avoid translation.</p><p>Default: false (which means brand names will not be translated)</p><p>For example, in the sample image, "懒角落" represents a brand name.<img src="https://3421660005-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcXGtrD26wbOKouIXD83g%2Fuploads%2F99JgkhyPuxUqdjBUxQ9V%2Fimage.png?alt=media&#x26;token=ec58c88b-287a-4da7-b584-34c96b1ba83b" alt=""><br><img src="https://3421660005-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcXGtrD26wbOKouIXD83g%2Fuploads%2F4JZBuCs7zpd6Rt3cufjZ%2Fimage.png?alt=media&#x26;token=d6a8eca6-7549-452f-8a17-f791155411cd" alt=""><br><code>Sample: false</code></p></td></tr><tr><td><code>glossary</code></td><td>String</td><td>No</td><td><p>Intervention glossary ID.</p><p>The intervention glossary ID needs to be created separately and its ID provided in the input parameters. If the provided intervention glossary ID is empty, the translation results will not be modified.</p><p>Address for creating the intervention glossary:<br><a href="https://aidge.com/intervention">https://aidge.com/intervention</a><br><code>Sample:“glossary_1“</code></p></td></tr></tbody></table>

### Sample Request

{% tabs %}
{% tab title="Java SDK" %}

```javascript
IopClient client = new IopClientImp(url, appkey, appSecret);
IopRequest request = new IopRequest();
// Adding this trial tag in header means using the trial resource to test, 
// request.addHeaderParameter("x-iop-trial","true")
request.setApiName("/ai/image/translation");
request.addApiParameter("imageUrl", "https://ae01.alicdn.com/kf/S68468a838ad04cc081a4bd2db32745f1y/M3-Light-emitting-Bluetooth-Headset-Folding-LED-Card-Wireless-Headset-TYPE-C-Charging-Multi-scene-Use.jpg_.webp");
request.addApiParameter("sourceLanguage", "en");
request.addApiParameter("targetLanguage", "fr");
request.addApiParameter("translatingTextInTheProduct", "false");
request.addApiParameter("useImageEditor", "false");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);
```

{% endtab %}

{% tab title="Non-SDK and other languages" %}
We provide http based sample codes in the git code repository.

<https://github.com/Aidge-AI>
{% endtab %}
{% endtabs %}

### Response Parameters

| Parameter            | Type    | Description                                                                                                                        |
| -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `resCode`            | Number  | Response code;200 indicates a successful call. For other response codes,please refer to the error code information.                |
| `data`               | Object  | Result data that generated.                                                                                                        |
| `data.imageUrl`      | String  | The image URL of the translation result.                                                                                           |
| `data.imageEditorId` | String  | The parameter protocol query ID required by the image editor (exposed when the request parameter  useImageEditor  is set to true). |
| `requestId`          | String  | Request ID;Used to identify a unique request call.                                                                                 |
| `success`            | Boolean | Whether successful;true is successful,false is unsuccessful.                                                                       |
| `resMessage`         | String  | Error message,e.g. "content has sensitive data, please try other input".                                                           |

### Sample Response

{% tabs %}
{% tab title="JSON" %}

```javascript
{
  "data": {
    "imageUrl": "https://nhci-image.oss-ap-southeast-1.aliyuncs.com/tufan%2F512506ce-32a5-11ef-9dd3-00163e08a26f.png?OSSAccessKeyId=LTAI5tCv9DpB7gYic1oGsAyv&Expires=4935959108&Signature=vf2a7lOn8uvvsfDfyeJNiYMls9Y%3D"
  },
  "requestId": "2140c5a117192871068067414ee3ad",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "2140cc8017192871068088228",
  "_trace_id_": "2140c5a117192871068067414ee3ad"
}
```

{% endtab %}
{% endtabs %}

### Errors

| Error Code | Error Message                                      | Description                                                                                                                                                                                                |
| ---------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 501        | rate limit exceed                                  | The current interface has reached the current limit. Please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>) to increase the current limit value. |
| 700        | invalid input                                      | The format of the input parameters does not meet the requirements, and resMessage will return detailed fields that do not meet the requirements.                                                           |
| 703        | image size exceeds the limit                       | The image size in the request parameters exceeds the limit; the dimensions of the image must not exceed 4000x4000 pixels.                                                                                  |
| 704        | invalid image form                                 | The image format in the request parameters is invalid.                                                                                                                                                     |
| 705        | image file size exceeds the limit                  | The image size in the request parameters exceeds the limit; the image size must not exceed 10MB.                                                                                                           |
| 801        | model failed                                       | Internal call exception, please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>) for troubleshooting.                                             |
| 900        | tpp url error                                      | Internal call exception, please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>) for troubleshooting.                                             |
| 1000       | content has sensitive data, please try other input | Content has sensitive data, please try other input.                                                                                                                                                        |
| 1001       | content control failed, please retry               | Content control failed, please retry. If the error persists, please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>).                             |
| 1002       | content risk filter failed, please contact us      | Content risk filter failed, please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>).                                                              |

### Appendix

#### Supported Language Pairs

The image translation API supports translation between the language pairs listed in the following table. More language pairs are continuously being added. Please contact us via [Discord](https://discord.gg/tvU7GFmpQR) or email us (<aidge_support@service.alibaba.com>).

The Image Translation Standard version supports source language to:

| Language            | Language Code |
| ------------------- | ------------- |
| Chinese(Simplified) | zh            |
| Traditional         | zh-tw         |
| English             | en            |
| French              | fr            |
| Italian             | it            |
| Japanese            | ja            |
| Korean              | ko            |
| Portuguese          | pt            |
| Russian             | ru            |
| Spanish             | es            |
| Thai                | th            |
| Turkish             | tr            |
| Vietnamese          | vi            |

The Image Translation Standard version supports target language to:

| Language                                                                                                                                | Language Code |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| Arabic                                                                                                                                  | ar            |
| Bengali                                                                                                                                 | bn            |
| Chinese(Simplified)                                                                                                                     | zh            |
| <p>Chinese (Traditional)<br><mark style="color:blue;">only Chinese(Simplified) and English as source languages are supported</mark></p> | zh-tw         |
| Czech                                                                                                                                   | cs            |
| Danish                                                                                                                                  | da            |
| Dutch                                                                                                                                   | nl            |
| English                                                                                                                                 | en            |
| Finnish                                                                                                                                 | fi            |
| French                                                                                                                                  | fr            |
| German                                                                                                                                  | de            |
| <p>Greek<br><mark style="color:blue;">only English and Turkish as source languages are supported</mark></p>                             | el            |
| Hebrew                                                                                                                                  | he            |
| Hungarian                                                                                                                               | hu            |
| Indonesian                                                                                                                              | id            |
| Italian                                                                                                                                 | it            |
| Japanese                                                                                                                                | ja            |
| <p>Kazakh<br><mark style="color:blue;">only Chinese as source language is supported</mark></p>                                          | kk            |
| Korean                                                                                                                                  | ko            |
| Malay                                                                                                                                   | ms            |
| Polish                                                                                                                                  | pl            |
| Portuguese                                                                                                                              | pt            |
| Russian                                                                                                                                 | ru            |
| Spanish                                                                                                                                 | es            |
| Swedish                                                                                                                                 | sv            |
| Thai                                                                                                                                    | th            |
| Tagalog                                                                                                                                 | tl            |
| Turkish                                                                                                                                 | tr            |
| Ukrainian                                                                                                                               | uk            |
| Urdu                                                                                                                                    | ur            |
| Vietnamese                                                                                                                              | vi            |

#### Language Code

The language code uses [ISO 639-1](https://www.loc.gov/standards/iso639-2/php/code_list.php) two-digit language codes. For a country/region variant of a language, the table follows the [RFC 5646](https://www.rfc-editor.org/rfc/rfc5646.html) format of appending a dash followed by an [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) 2-digit country code. For example, the language code for Traditional Chinese is `zh-tw`.
