# Localization Services

All services related to Localization are listed in this page.

### `GET` Translations List

This method is used to get list of translations for given content type.

**Path:** `/api/v1/oms/localization/translations_list/`

**Query Paremeters**

| Parameter     | Data Type | In    | Description                         |
| ------------- | --------- | ----- | ----------------------------------- |
| content\_type | string    | query | The content type of the translation |

**Example Request**

To get list of translations, a GET request should be sent to `/api/v1/oms/localization/translations_list/` endpoint.

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/localization/get_translations/?content_type=2"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers)

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of 200 OK, the API returns list of translations information.

| Parameter     | Data Type | Description                                    |
| ------------- | --------- | ---------------------------------------------- |
| pk            | integer   | The primary key of the translation             |
| translations  | object    | Translations of the given content\_type object |
| content\_type | object    | Content type info of the translations.         |

This example response serves as a reference to understand the structure and data format of translations list.

```json
{
    "count": 2,
    "next": "http://testserver/api/v1/oms/localization/translations_list/?content_type=64&limit=1&page=2",
    "previous": null,
    "results": [
        {
            "pk": 2,
            "translations": {
                "ar": {
                    "name": "\u0645\u062b\u064a\u0644 \u062c\u062f\u064a\u062f"
                },
                "tr": {
                    "name": "Yeni Nesne"
                }
            },
            "content_type": {
                "id": 64,
                "app_label": "packages",
                "model": "testmodel97ac97"
            }
        }
    ]
}
```

### `GET` Localization Detail

This method is used to retrieve details of the translations for given content\_type and object\_id parameter.

**Path:** `/api/v1/oms/localization/get_translations/`

**Query Paremeters**

| Parameter     | Data Type | In    | Description                         |
| ------------- | --------- | ----- | ----------------------------------- |
| content\_type | string    | query | The content type of the translation |
| object\_id    | string    | query | The object id of the translation    |

**Example Request**

To retrieve localization detail, a GET request should be sent to `/api/v1/oms/localization/get_translations/` endpoint.

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/localization/get_translations/?content_type=2&object_id=21"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers)

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of 200 OK, the API returns translation detail information.

| Parameter        | Data Type | Description                                       |
| ---------------- | :-------: | ------------------------------------------------- |
| {language\_code} |    str    | The language code, for example, tr\_tr or en\_us. |

This example response serves as a reference to understand the structure and data format of translations detail.

```json
{
    "tr_tr": {
        "name": "Turkce String"
    },
    "en_us": {
        "name": "English String" }  
}

```

### `POST` Translate

This method is used to create a translation for given content\_type and object\_id parameter.

**Path:** `/api/v1/oms/localization/translate/`

**Body Paremeters**

| Parameter     | Data Type | In    | Description                         |
| ------------- | --------- | ----- | ----------------------------------- |
| content\_type | string    | query | The content type of the translation |
| object\_id    | string    | query | The object id of the translation    |
| translation   | object    | body  | The translation object              |

**Example Request**

To create translation a `POST` request should send to `/api/v1/oms/localization/translate/` endpoint.

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/localization/translate/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = {
  "content_type" : 2,
  "object_id" : 21,
  "translation" : {
    "tr_tr" : {
      "name" : "Turkce String"
    },
    "en_us" : {
      "name" : "English String"
    }
  }
}

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of 200 OK, the API returns translation detail information.

| Parameter        | Data Type | Description                                       |
| ---------------- | --------- | ------------------------------------------------- |
| {language\_code} | str       | The language code, for example, tr\_tr or en\_us. |

This example response serves as a reference to understand the structure and data format of translations detail.

```json
{
    "tr_tr": {
        "name": "Turkce String"
    },
    "en_us": {
        "name": "English String" }  
}

```

### `GET` Translatable Models

This method is used to get a list of translatable models.

**Path:** `/api/v1/oms/localization/translatable_models/`

**Example Request**

To get translatable models list, a `GET` request should be sent to `/api/v1/oms/localization/translatable_models/` endpoint. No query parameter or body required.

```python

import requests

url = "https://{oms_base_url}//api/v1/oms/localization/translatable_models/ "
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers)

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of 200 OK, the API returns list of translatable models.

| Parameter            | Data Type | Description                                               |
| -------------------- | --------- | --------------------------------------------------------- |
| content\_type\_id    | integer   | The primary key of the translatable model content type id |
| model                | string    | Translatable model name                                   |
| translatable\_fields | array     | Translatable fields of the model                          |

This example response serves as a reference to understand the structure and data format of translatable models list.

```json
{
    "count": 3,
    "next": null,
    "previous": null,
    "results": [
        {
            "content_type_id": 11,
            "model": "statetransition",
            "translatable_fields": [
                "label"
            ]
        },
        {
            "content_type_id": 64,
            "model": "testmodel022c12",
            "translatable_fields": [
                "name"
            ]
        },
        {
            "content_type_id": 20,
            "model": "state",
            "translatable_fields": [
                "name"
            ]
        }
    ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/oms/localization-services.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
