Skip to content

Latest commit

 

History

History
154 lines (133 loc) · 3.6 KB

File metadata and controls

154 lines (133 loc) · 3.6 KB
layout title github_link menu_title menu_order indexed menu_style group subgroup
default
REST API - Examples using the translation resource
developers-guide/rest-api/examples/translation/index.md
Translation examples
240
true
bullet
Developer Guides
REST API

Introduction

In this article you can read more about using the translation resource. The following part will show you examples including provided data and data you need to provide if you want to use this resource. Please read the page covering the translation API resource if you did not yet, to get more information about the translation resource and the data it provides.

Example 1 - Creating a new translation

This example shows how to create a new article translation

{% include 'api_badge.twig' with {'route': '/api/translations', 'method': 'POST', 'body': true} %}

{
    "key": 200,
    "type": "article",
    "shopId": 2,
    "data": {
        "name": "Dummy translation",
        "__attribute_attr1": "Dummy attribute translation"
    }
}

Example 2 - Updating a translation

{% include 'api_badge.twig' with {'route': '/api/translations/200', 'method': 'PUT', 'body': true} %}

{
    "type": "article",
    "shopId": 2,
    "data": {
        "name": "Dummy translation",
        "__attribute_attr1": "Dummy attribute translation"
    }
}

Example 3 - Creating a property group translation

{% include 'api_badge.twig' with {'route': '/api/translations', 'method': 'POST', 'body': true} %}

{
    "key": 6,
    "type": "propertygroup",
    "shopId": 2,
    "data": {
        "groupName": "Dummy translation"
    }
}

Example 4 - Updating a property group translation

{% include 'api_badge.twig' with {'route': '/api/translations/6', 'method': 'POST', 'body': true} %}

{
    "type": "propertygroup",
    "shopId": 2,
    "data": {
        "groupName": "Dummy translation edited"
    }
}

Example 5 - Creating a property option translation

{% include 'api_badge.twig' with {'route': '/api/translations', 'method': 'POST', 'body': true} %}

{
    "key": 1,
    "type": "propertyoption",
    "shopId": 2,
    "data": {
        "optionName": "Dummy translation"
    }
}

Example 6 - Updating a property option translation

{% include 'api_badge.twig' with {'route': '/api/translations/1', 'method': 'POST', 'body': true} %}

{
    "type": "propertyoption",
    "shopId": 2,
    "data": {
        "optionName": "Dummy translation edited"
    }
}

Example 7 - Creating a property value translation

{% include 'api_badge.twig' with {'route': '/api/translations', 'method': 'POST', 'body': true} %}

{
    "key": 166,
    "type": "propertyvalue",
    "shopId": 2,
    "data": {
        "optionValue": "Dummy translation"
    }
}

Example 8 - Updating a property value translation

{% include 'api_badge.twig' with {'route': '/api/translations/166', 'method': 'POST', 'body': true} %}

{
    "type": "propertyvalue",
    "shopId": 2,
    "data": {
        "optionValue": "Dummy translation edited"
    }
}

Example 9 - Updating multiple translations (batch mode)

{% include 'api_badge.twig' with {'route': '/api/translations', 'method': 'PUT', 'body': true} %}

[
    {
        "key": 177,
        "type": "propertyvalue",
        "shopId": 2,
        "data": {
            "optionValue": "Dummy translation edited"
        }
    },
    {
        "key": 178,
        "type": "propertyvalue",
        "shopId": 2,
        "data": {
            "optionValue": "Another dummy translation edited"
        }
    }
]