Like a lot of similar things in HTTP you do this via content negotiation.
HTTP protocol defines the header Accept-Language
that the client passes to the server. This header contains a list of the languages (as in natural language, not programming language) that it understands.
The server can then select the most appropriate language (or fall back to a default if it doesn't support any of the ones the client requests).
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
This is how you handle which language to return responses in.
As other answers point out you should still use the standard HTTP response codes, but the body of the response should be translated to the language negotiated by this process.
So request is
POST /management/departments HTTP/1.1
Host: api.domain.com
Accept-Language: en-US
Content-Type: application/json
{...JSON body here}
and response is
HTTP/1.1 201 Created
Date: Thu, 10 Oct 2019 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Language: en-US
Location: http://api.domain.com/management/departments/123
Department created successfully
and if the Accept-Language
has been say es-AR
POST /management/departments HTTP/1.1
Host: api.domain.com
Accept-Language: es-AR
Content-Type: application/json
{...JSON body here}
the response would be (apologies for the butchered Google Translate Spanish attempt)
HTTP/1.1 201 Created
Date: Thu, 10 Oct 2019 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Language: es-AR
Location: http://api.domain.com/management/departments/123
Departamento creado con éxito