O'Reilly logo

RESTful Java Patterns and Best Practices by Bhakti Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Internationalization and localization

Often, services need to operate in a global environment and responses need to be tailored based on the country and locale. Localization parameters can be specified in one of the following fields:

  • HTTP headers
  • Query parameters
  • Content of the REST response

Language negotiation is similar to content negotiation; the HTTP header Accept-Language can take different language codes based on any two-letter initial for ISO-3166 country codes (http://www.iso.org/iso/country_codes.htm). The Content-Language header is similar to the Content-Type header and can specify the language for the response.

For example, here is a Content-Language header sent in the response to a request sent by a client:

HTTP/1.1 200 OK X-Powered-By: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required