I have a custom API whose response message is in English. I wanted to convert it to french language when it reaches the frontend. e.g now my API is sending a message as:

if (!strcmp($gcode,$giftcode)) {
         $result['message']='Gift card already redeemed';
         echo json_encode($result);

My backend is Magento 2(English) and the frontend is in Vue Js storefront (French language).

I have used some built-in APIs also, so how can I change their language.

Or the language will be changed by Vue Js storefront when any API (built-in, custom) response is received. Or it should be handled in the backend (Magento 2)?

1 Answer 1


First you need to change 'Gift card already redeemed' to __('Gift card already redeemed') then you need to add store code before /V1/rest e.g


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.