Best practice regarding REST services and I18N

Viewed 8689

I have a client app that communicates with a server using REST services. The client app is multilingual which means the server must be aware of the user's locale during calls. I want to use the "post for location" approach as that has a nice and restful feel to it. When data gets posted to say the actions resource then the uri is:

/actions/{language}

The language is important so that I can localize error messages (or sometimes the returning data) for a GET. Now when the server responds it needs to send back the URI of the resource. If I send back

/actions/{id}

where id is the id of the newly created resource, this isn't entirely correct as

/actions/{language}/{id}

would be the URI of the localized resource. However the actual resource is without the language context.

Any opinions on best practice for this scenario?

4 Answers

In my opinion, you need NOT support Internationalization/Localization in your RESTful Server side.

For a app with a backend RESTful server, the internationalization should be done in Client Side (Your Android App, your web 2.0 Web Page, etc ).

But you should format your error response, for example:

{
    "code": "NET.001",
    "message": "The remote host can't reach"
}
Related