PDA

View Full Version : Internationalizing a full page of text



krancour
Dec 18th, 2007, 10:50 AM
Hi everyone,

I've got a full page of JSP (containing mostly just HTML) that I am looking to localize in English and Spanish. I'm quite familiar with i18n and regularly use resource bundles to store short messages, field labels, error messages, etc., but I'm really not sure how to go about localizing a full page of HTML content.

The other relevant twists are that I am using Tiles (circa Struts 1.2.8) and am restricted to Spring 2.0.7. So, what I am really trying to do is localize a tile.

I found documentation in my old Struts book that claims multiple Tiles definitions files can be provided- one per locale, but I see no evidence that Spring's TileConfigurer is capable of choosing correctly among those based on the locale.

Can anyone comment on this or suggest a workable solution? Thanks-a-million in advance to anyone who can.

krancour
Dec 18th, 2007, 11:31 AM
Ok. After reading up on it more, I'm now willing to concede that the only reason i18n abilities of any kind were included in Tiles was to handle cases where layout must vary by locale- which is not what I was looking to do.

So this reduces my question to a much more generic one. How can I localize an entire JSP page fragment?

batzee
Mar 3rd, 2010, 02:33 AM
Oh come on guys, did nobody ever do this before??
Sounds like a pretty common task to me...

F.Degenaar
Mar 3rd, 2010, 05:49 AM
Write your own subclass of InternalResourceViewResolver, that takes into account the current locale when resolving the view name. It should be fairly easy, if the views are organized in folders according to their language (e.g. /pages/en/welcome.html, /pages/fr/welcome.html etc.).

vw729
Mar 3rd, 2010, 12:26 PM
If you use Tiles, you can implement your localization with the Tiles definition file which is similar with message property localization files in terms of file name such as xxx.xml xxx_en.xml etc. I can't recall whether any special configuration is requested or not.