views:

178

answers:

1

I am trying to setup Spring MVC 3.0 to support localization. The messages are in messages_en.properties and messages_fr.properties. It works, but I cannot figure out how to support localized JSP pages. I have tried naming them sample_en.jsp for example, but it does not work.

I use ControllerClassNameHandlerMapping, BeanNameViewResolver & InternalResourceViewResolver, LocaleChangeInterceptor and SessionLocaleResolver.

Any idea?

+1  A: 

The typical approach for JSP localization is to use fmt:message (or spring:message) to render localized strings from .properties files. It doesn't require to maintain different versions of page markup for different locales.

The approcah with localized JSP files is not supported out of the box, though it can be implemented by subclassing InternalResourceViewResolver and overriding loadView().

axtavt
This part with the message formatting works. But sometimes, it is more natural to have one JSP page per language.
Francois
I am not sure what you mean with "natural", but I wouldn't create 200+ syntactically identical JSP files with only a different **content** for every self-respected language the world is aware of. There the i18n APIs/tags are for.
BalusC
You make a good point here.
Francois