Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

internationalization in JSTL

 
Vasudhaiv Naresh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic