0

I'm adding product to cart using {baseUrl}/rest/{store_code}//V1/carts/mine/items

If requested qty not available in stock then in response you'll get The requested qty is not available I want to translate this based on store view ?

Any ideas ? Language pack doesn't work at API level where at theme level it working using language packs.

Thanks in advance.

1

I have looked into your issue this morning and I have come up with a work around it. I understand you want to use the Magento translated message in your system that consumes Magento API. I guess your concerns are not to duplicate the existing translation and instead enhance a unified system..

The translation don't seem to be built-in with the API layer in Magento; It may be reasonable to admit this is ok as loading translations has a cost and that would possibly incur api latency issues?

My solution was to add a new API that gives you the translations for the store you use; afterwards, you can cache the result of this translation API call. You can use this API in 2 ways:

retrieve a single translation:

http://<magento_url/index.php/rest/V1/gettranslation?message=The requested qty is not available&storeId=1

retrieve all the translations:

http://<magento_url/index.php/rest/V1/getalltranslations?storeId=1

to be able to consume this additional API, you will have to use the module I have come up with, it is a public repository you can access at:

https://bitbucket.org/magstaging/translationapi/src/master/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.