Im trying to find a way to honour the locale for the response depending on the Accept-Language header on the request. Im using Jersey implementation. This would be for the Restful side of the application. We already have it covered for the WebApplication side (JSF) but Jersey/JAXRS isnt cooperating.
So basically say I need to return an error response, I would like to send a string back saying "Problem" for an English locale and "Problema" for a Spanish locale.
So far i found this similar post but no concrete answer was given - Implementing a Locale provider that works in JSF and JAX-RS
Your help is appreciated
update:
So far I can get the locale by doing this:
@Controller @Path("/test")
@Produces("plain/text")
public class TestRouteController implements Serializable{
@GET
@RestrictedRoute(permissions={SCConstant.PERMISSION_SEARCH_VIEW_CLIENT})
public Response testMethong(@Context HttpServletRequest request){
String message = "Locale in request is " + request.getLocale();
return ResponseGenerator.response(message);
}
}
Then I would like to honour the locale of the String message that I;m sending back. If have seen this:
if(request.getLocale() == "sp-VE")
message = "El locale en la requesta es " + request.getLocale();
else if(request.getLocale() == "sp-MX")
message = "La localizacion en la requesta es " + request.getLocale();
I cant do this because I want to be localize many things.