# API Translations for Articles; actual use (shopId) and advised use (localId)

**URL:** <https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904>\
**Category:** Programmierung\
**Created:** [29. Februar 2016 um 10:00 UTC](https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904 "2016-02-29T10:00:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sptest](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@sptest](https://forum.shopware.com/u/sptest)\
**Post date:** [29. Februar 2016 um 10:00 UTC](https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904/1 "2016-02-29T10:00:48Z")

</div>

Hello everybody,

I have tried to use API translation as advised by Shopware documentation (using localId).&nbsp; &nbsp; &nbsp; &nbsp;

- [devdocs/index.md at master · shopware/devdocs · GitHub](https://github.com/shopware/devdocs/blob/master/source/developers-guide/rest-api/examples/translation/index.md)
- [http://community.shopware.com/Shopware-4.2-Upgrade-Guide-fuer-Entwickler\_detail\_1436\_454.html](http://community.shopware.com/Shopware-4.2-Upgrade-Guide-fuer-Entwickler_detail_1436_454.html)
- [http://community.shopware.com/REST-API-Translation-Endpoint\_detail\_1704.html](http://community.shopware.com/REST-API-Translation-Endpoint_detail_1704.html)
- [REST API - Translations Resource](https://developers.shopware.com/developers-guide/rest-api/api-resource-translation/)

To obtain the desired effect shopId should be used instead of localId.

Do you have experienced&nbsp;&nbsp;the same problem?

Or is it&nbsp;something due to the&nbsp;Shopware 5.1.1 installation on managed hosting?

I have searched inside&nbsp;[http://forum.shopware.com/discussion/17396/rest-api-uebersetzungen](http://forum.shopware.com/discussion/17396/rest-api-uebersetzungen) but I didn’t find&nbsp;anything useful to me.  
I have created a new thread because the link above is about Shopware 4.

* * *

**localId is used as advised**

```
if($method == 'post') {
  	// single test
  	$client->post('translations',      
                        array( 'key' => 489, 
                               'type' => 'article',
                               'localeId' => 136,     
                                'data' => array(
                                'name' => 'Italian Dummy translation',)));
         

  	 $client->get('translations');
  }

```

Post (usling localId)

```
$client->put('translations/489',      
                        array(   
                               
                               'Key' => '489',
                               'type' => 'article',
                                   
                               'localeId' => 136,
                                
                                'data' => array(
                                'name' => 'Italian Dummy translation modified',)));
         

  	 $client->get('translations');

```

PUT &nbsp;(using localId)  
If it is used as explained in the links above (using localId)&nbsp;, API translations do not actually&nbsp;work.  
They return&nbsp;as answer HTTP 200 and HTTP 201 but nothing is changed (200) or created (201) in the article translations.

```
POST

HTTP: 201

Success

Array
(
    [id] = 25
    [location] = http://mirifica.de/workingSW5/api/translations/25
)

-----

PUT

HTTP: 200

Success

Array
(
    [id] = 26
    [location] = http://mirifica.de/workingSW5/api/translations/26
)

```

The creation/change are happenning inside the s\_articles\_translations database’s table&nbsp;but they are not actually integrated within Shopware.

- Changes/creations are visible
  - inside&nbsp;s\_articles\_translations database’s table

- Changes/creations are NOT&nbsp;visible
  - in the Shopware backend or
  - inside&nbsp;JSON answer/reply to&nbsp;REST API GET Translation.

* * *

**shopId is used insted od locaId**

```
 if($method == 'post') {
  	// single test
  	$client->post('translations',      
                        array( 'key' => 489, 
                               'type' => 'article',
                               'shopId' => 5,     
                                'data' => array(
                                'name' => 'Italian Dummy translation',)));
         

  	 $client->get('translations');
  }

```

POST (using shopId)

```
if($method == 'put') {
  	 // single test 
  	 $client->put('translations/489',      
                        array(   
                               
                               'Key' => '489',
                               'type' => 'article',
                                   
                               'shopId' => 5,
                                
                                'data' => array(
                                'name' => 'Italian Dummy translation modified',)));
         

  	 $client->get('translations');
  }

```

PUT (using ShopId)

If shopId is used instead of&nbsp;localId, API translations do actually&nbsp;work.  
They return&nbsp;exactly the same&nbsp;answer HTTP 200 and HTTP 201 as before.

```
POST

HTTP: 201

Success

Array
(
    [id] = 27
    [location] = http://mirifica.de/workingSW5/api/translations/27
)

-----

PUT

HTTP: 200

Success

Array
(
    [id] = 28
    [location] = http://mirifica.de/workingSW5/api/translations/28
)

```

The creation/change are happenning inside the s\_articles\_translations database’s table AND they are actually integrated within Shopware.

- Changes/creations are visible
  - inside&nbsp;s\_articles\_translations database’s table

- Changes/creations are ALSO&nbsp;visible
  - in the Shopware backend or
  - inside&nbsp;JSON answer/reply to&nbsp;REST API GET Translation.

---

<div class="post-metadata">

**Author:** ![TeichDatensysteme](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TeichDatensysteme](https://forum.shopware.com/u/TeichDatensysteme)\
**Post date:** [29. Februar 2016 um 11:23 UTC](https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904/2 "2016-02-29T11:23:24Z")

</div>

Hey.

You’re right, the shopId is used (and required) instead of the localeId - Shopware changed this with the release of 5.0.0.  
5.0.0 RC1 UPGRADE.md descripes …

> - Fix translation API, rename all&nbsp;`localeId`&nbsp;references to&nbsp;`shopId`. Create / update / delete with&nbsp;`localeId`&nbsp;are still supported as legacy.

But - localeId is still working as&nbsp;mentioned (REST api)  
The local API resource doesnt work with localeId’s, so using the shopId is the best choice to work with translations.

Greetings,  
Niklas

---

<div class="post-metadata">

**Author:** ![sptest](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@sptest](https://forum.shopware.com/u/sptest)\
**Post date:** [29. Februar 2016 um 11:59 UTC](https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904/3 "2016-02-29T11:59:40Z")

</div>

Hello&nbsp;Mr.&nbsp;Niklas,

thank you very much for your answer.

> - „Fix translation API, rename all&nbsp;`localeId`&nbsp;references to&nbsp;`shopId`. Create / update / delete with&nbsp;`localeId`&nbsp;are still supported as legacy.“

I have not see the previous&nbsp;line in the .md file.

> - „Fix translation API, rename all&nbsp;`localeId`&nbsp;references to&nbsp;`shopId`. Create / update / delete with&nbsp;`localeId`&nbsp;are still supported as legacy.“
> 
> „But - localeId is still working as&nbsp;mentioned (REST api)“

But, according to my experience with REST API Translation, even inside the&nbsp;JSON answer to REST API GET translations (List) there are&nbsp;no references to the article&nbsp;translations&nbsp;created using localeId (the references are available if created using shopId); I do not see how could be usefull to let legacy&nbsp;support to API that only create/update/delete invisible (to frontend/backend Shopware and REST API GET commad) rows.

In any case, I think that  
1)&nbsp;the following&nbsp;links&nbsp;

- [https://github.com/shopware/devdocs/blob/master/source/developers-guide/rest-api/examples/translation/index.md](https://github.com/shopware/devdocs/blob/master/source/developers-guide/rest-api/examples/translation/index.md)
- [http://community.shopware.com/Shopware-4.2-Upgrade-Guide-fuer-Entwickler\_detail\_1436\_454.html](http://community.shopware.com/Shopware-4.2-Upgrade-Guide-fuer-Entwickler_detail_1436_454.html)
- [http://community.shopware.com/REST-API-Translation-Endpoint\_detail\_1704.html](http://community.shopware.com/REST-API-Translation-Endpoint_detail_1704.html)
- [https://developers.shopware.com/developers-guide/rest-api/api-resource-translation/](https://developers.shopware.com/developers-guide/rest-api/api-resource-translation/)

should be recreated/ported to Shopware 5 because I was not able to find a single Shopware 5 page dedicated to translation.

1. an error answer to localeId REST API Translations could be better instead of the strange behaviour observed:

- REST API using localeId seem&nbsp;to be able to change database table rows but NOT&nbsp;frontend/backend text boxs (a successful answer HTTP 200/201 is returned, so no problem are expected)
- REST API using&nbsp;shopId&nbsp;seem&nbsp;to be able to change database table rows&nbsp;AND frontend/backend text boxs.

After all, I want that the&nbsp;REST API command used should be able to make change&nbsp;to both elements:

- database table rows
- frontend/backend text boxs

–

Thank you very much for your time and your answer.

Greeting,

Sergio

&nbsp;

---

<div class="post-metadata">

**Author:** ![TeichDatensysteme](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TeichDatensysteme](https://forum.shopware.com/u/TeichDatensysteme)\
**Post date:** [29. Februar 2016 um 13:22 UTC](https://forum.shopware.com/t/api-translations-for-articles-actual-use-shopid-and-advised-use-localid/34904/4 "2016-02-29T13:22:46Z")

</div>

Hi Sergio,

> should be recreated/ported to Shopware 5 because I was not able to find a single Shopware 5 page dedicated to translation.

yeah, the documentation is outdated and i reported that also a few months ago … i ran into the same situation when i upgraded our erp connector.  
Use the shopId to make shure everything works!

EDIT: I opend a pull request to fix the translation api documentation.

Greetings,  
Niklas
