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

Hello everybody,

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

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

Do you have experienced  the same problem?

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

I have searched inside http://forum.shopware.com/discussion/17396/rest-api-uebersetzungen but I didn’t find 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  (using localId)
If it is used as explained in the links above (using localId) , API translations do not actually work.
They return 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 but they are not actually integrated within Shopware.

  • Changes/creations are visible
    • inside s_articles_translations database’s table
  • Changes/creations are NOT visible
    • in the Shopware backend or
    • inside JSON answer/reply to 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 localId, API translations do actually work.
They return exactly the same 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 s_articles_translations database’s table
  • Changes/creations are ALSO visible
    • in the Shopware backend or
    • inside JSON answer/reply to REST API GET Translation.

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 localeId references to shopId. Create / update / delete with localeId are still supported as legacy.

But - localeId is still working as 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

Hello Mr. Niklas,

thank you very much for your answer.

  • „Fix translation API, rename all localeId references to shopId. Create / update / delete with localeId are still supported as legacy.“

I have not see the previous line in the .md file.

  • „Fix translation API, rename all localeId references to shopId. Create / update / delete with localeId are still supported as legacy.“

„But - localeId is still working as mentioned (REST api)“

But, according to my experience with REST API Translation, even inside the JSON answer to REST API GET translations (List) there are no references to the article translations created using localeId (the references are available if created using shopId); I do not see how could be usefull to let legacy 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) the following links 

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 to be able to change database table rows but NOT frontend/backend text boxs (a successful answer HTTP 200/201 is returned, so no problem are expected)
  • REST API using shopId seem to be able to change database table rows AND frontend/backend text boxs.

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

  • database table rows
  • frontend/backend text boxs

Thank you very much for your time and your answer.

Greeting,

Sergio

 

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