dev@jersey.java.net

How to internationalize the Response.Status?

From: exxos <hatufr_at_gmail.com>
Date: Thu, 9 Sep 2010 18:37:12 +0200

Hi,

The question is more related to JSR-311, but I'm wondering what could be the
best approach to internationalize the messages defined in the enum
Reponse.Status.

For example:

Response.Status.INTERNAL_ERROR_SERVER.getString()
returns "Internal Server Error" (RFC 2616)

I noticed that Tomcat by default does it, but it is based on your
installation. For my part, I tested a french version and if a
WebApplicationExceptionResponse.Status.INTERNAL_ERROR_SERVER.getStatusCode())
is thwon, you get
the default Tomcat display of "Error Code 500 - Internal Error Server" is
something that looks like: "Le serveur a rencontré une erreur interne () qui
l'a empêché de satisfaire la requête".
This is minimalistic but interesting.

This need comes after putting in place a ExceptionMapper that catches all
RuntimeExceptions.
The mapper is now in charge to answer in a correct format (as best as it
can) to the end user.

I'm talking here about default HTTP status messages, when the database
(internationlization) cannot achive it.
One of the basic solution, could be to create a new Enum?
Or maybe this is not a real problem and after all, if the error message does
not exist in database, the default language is "English" and the one
returned by the Reponse.Status.XXXX.getString() ? Finally, what's the
best/acceptable appraoch?
Thank you for your advises.

Regards,
exxos.