[hibernate-issues] [Hibernate-JIRA] Commented: (HV-44) Make Hibernate Validator multi-lingual

Olle Hallin (JIRA) noreply at atlassian.com
Thu Jan 10 14:28:55 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-44?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29281 ] 

Olle Hallin commented on HV-44:
-------------------------------

EJB applications suffer from the same single-language problem as a servlet-only app: not all EJB clients want the validation error messages in the EJB container's default locale. Replace EJB with any remoting technology and this is still true; SOAP, RMI, REST, ...

So the client must pass the locale to the service somehow, which then makes it known to HibernateValidator.

And then we are back to my proposed solution: Each thread that uses Hibernate Validator is responsible for making the locale known to Hibernate Validator.

And the easiest possible way of doing this is IMHO to use a ThreadLocal. No custom message interpolator is needed.

In a servlet-only architecture, the web browser acts as client and sets the Accept-Locale HTTP header. The servlet is the service that sets the ThreadLocal. When remoting is involved (incl. local EJBs), the servlet must pass the Locale to the next thread, which also sets the ThreadLocal and so on ad infinitum.


> Make Hibernate Validator multi-lingual
> --------------------------------------
>
>                 Key: HV-44
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-44
>             Project: Hibernate Validator
>          Issue Type: Improvement
>    Affects Versions: 3.0.0.ga
>            Reporter: Olle Hallin
>
> Hibernate Validator 3.0.0 is unfortunately useless in a multi-lingual web app, since it uses Locale.getDefault() for locating the validation message bundle.
> Each and every HTTP request can have a different locale, in it's own thread.
> Please add something in line with Spring's LocaleContextHolder (a ThreadLocal), which can be set early in the request handling chain. If not set, it could fall back to the platform's Locale.getDefault().

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list