I'm using freemarker, SiteMesh and Spring framework. For the pages I use ${requestContext.getMessage()} to get the message from message.properties. But for the decorators this doesn't work. How should I do to get the internationalization working for sitemesh?
+2
A:
You have to use the fmt taglib.
First, add the taglib for sitemesh and fmt on the fisrt line of the decorator.
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<fmt:setBundle basename="messages" />
In my example, the i18n file is messages.properties. Then you need to use the fmt tag to use the mesages.
<fmt:message key="key_of_message" />
mathd
2008-09-19 20:13:25
A:
If you prefer templates and the freemarker servlet instead you can enter the following in your templates:
<#assign fmt=JspTaglibs["http://java.sun.com/jstl/fmt"]>
<@fmt.message key="webapp.name" />
and in your web.xml
:
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>