Output key to localized message returning 0

366 views Asked by At

I'm trying to output a key to a localized message in a jsp template in the following way:

    <c:set var="logo-tooltip-title">
        <fmt:message key="logo.tooltip.title"/>
    </c:set> 
    <c:out value="${logo-tooltip-title}"/>

With the following in my messages.properties file:

logo.tooltip.title=Test

Does anyone know what I'm doing wrong here? Why does it return 0 instead of Test?

My goal is to output that message as title of the following link:

    <a class="logo" href="/site/" title="${logo-tooltip-title}">
        <img src="<hst:link path="/img/logo.png"/>" alt="logo" class="headlogo" width="80" height="100" />
    </a>

Any thoughts on the best approach to do this?

Thanks!

EDIT:

yes I have set the context param in web.xml:

  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>messages</param-value>
  </context-param>

resource

Update:

This seems to work:

<fmt:message key="logo.tooltip.title" var="tooltip"/>

<c:out value="${tooltip}"/>
2

There are 2 answers

0
Jasha On

JSTL tries to do math for "logo - tooltip - title" which results in 0. You've already found out that replacing the - by . solved the issue.

0
Eddy On

I don't think your problem is specific to HippoCMS.

I tried your syntax and I think you're missing a bundle declaration. If I add an org/ecausarano/Example.properties file to the war resources and:

<fmt:setBundle basename="org.ecausarano.Example" />

<c:set var="message">
   <fmt:message key="message.message" />
</c:set>

<c:out value="${message}" />

it works for me.