Get your CodeRanch badge!*
The moose likes JSP and the fly likes internationalization in JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "internationalization in JSTL" Watch "internationalization in JSTL" New topic
Author

internationalization in JSTL

Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
Hi all!
i would like to know how pages can be internationalized using PropertiesResourceBundle in JSTL.
I had tried as shown in the fragment below, but it didn't work :

-------------------------------------------------------
<fmt:bundle basename="resources.application">
locale : ${param.local}
<fmt:setLocale value="${param.local}"/>
<title> <fmt:message key="welcome.title"/></title>
<h1><fmt:message key="welcome.heading"/></h1>
<hr>
<fmt:message key="welcome.message"/>
</fmt:bundle>
-------------------------------------------------------

Here, the base resource bundle is "application.properties",
and i've created a couple of other resource bundles, say - "application_de.properties" and "application_sh.properties".
I'm not getting the desired result even upon setting the locale to "de" or "sh".
Kindly give some suggestions, as to where I might have gone wrong and how it is actually to be done.
Regards,
Naresh
Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
Hi all!
I found that the problem occurred with the following :
---------------------------------------------------------
<B><fmt:bundle basename="resources.application"></B>
locale : ${param.local}
<B>fmt:setLocale value="${param.local}"/></B>
<title> <fmt:message key="welcome.title"/></title>
<h1><fmt:message key="welcome.heading"/></h1>
<hr>
<fmt:message key="welcome.message"/>
</fmt:bundle>
---------------------------------------------------------

The reason being :
The locale should be set prior to setting the "bundle basename".

Regards,
Naresh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: internationalization in JSTL
 
Similar Threads
fmt: tag
jstl code problem
Using resource bundle as input for a custom tag
Managing message Resource Bundle struts 1.3.8
Display ActionMessage in JSP using fmt:message