Skip to main content

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

ParameterData TypeInDescription
content_typestringqueryThe 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.

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.

ParameterData TypeDescription
pkintegerThe primary key of the translation
translationsobjectTranslations of the given content_type object
content_typeobjectContent type info of the translations.

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

{
"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

ParameterData TypeInDescription
content_typestringqueryThe content type of the translation
object_idstringqueryThe 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.

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.

ParameterData TypeDescription
{language_code}strThe 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.

{
"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

ParameterData TypeInDescription
content_typestringqueryThe content type of the translation
object_idstringqueryThe object id of the translation
translationobjectbodyThe translation object

Example Request

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

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.

ParameterData TypeDescription
{language_code}strThe 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.

{
"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.


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.

ParameterData TypeDescription
content_type_idintegerThe primary key of the translatable model content type id
modelstringTranslatable model name
translatable_fieldsarrayTranslatable fields of the model

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

{
"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"
]
}
]
}