David Graham wrote:

--- "Fenderbosch, Eric" <[EMAIL PROTECTED]> wrote:


The whole use-a-named-property-for-everything is great so that marketing
can change the text/copy without involving a HTML/JSP developer, as well
as the future ability to I18N a site down the road.  However some things
just get ugly.
Example:
Old line of HTML:
The FedEx Custom Critical <a href="/us/shipping/default.shtml">Shipping
Toolkit</a> enables you to:

New lines w/ tags:
<bean:message key="message.benefit.one"/>&nbsp;
<a href="<bean:message key="href.shippingToolkit"/>">
 <bean:message key="link.shippingToolkit"/>
</a>
&nbsp;<bean:message key="message.benefit.two"/>

(I know I could use a <html:link> tag)

Any ideas for making this simpler?  Should I just define one large
resource like:

message.benefits=The FedEx Custom Critical&nbsp;<a
href="/us/shipping/default.shtml">Shipping Toolkit</a>&nbsp;enables you
to:

Then simply do:
<bean:message key="message.benefits"/>



That's what I would do except use the JSTL version: <fmt:message key="message.benefits"/>




From my experience working with human translators this might be a better approach. Translators like to be able to manipulate word order and punctuation. It is a little more code but I'll argue that it is not any less readable. Most importantly it works with Struts links and will properly encode the URL:


applicationResources.properties: message.benefits=The FedEx Custom Critical&nbsp;{0}&nbsp;enables ... mainPage.shippingLinkName=Shipping Toolkit


Put this at the top of the JSP:
<fmt:setBundle basename="com.nvisia.training.struts.resources.ApplicationResources"/>
<bean:define name="stLink" scope="page">
<html:link action="/shipping">
<bean:message key="mainPage.shippingLinkName"/>
</html:link>
</bean:define>

In the body of the jsp:
<fmt:message key="message.benefits">
    <param value="stLink"/>
</fmt:message>


Regards, Evan.

--
Evan Schnell, Project Lead
nVISIA, Twin Cities  "Enterprise Architecture and Construction"
7701 France Ave. S, Edina, MN 55435
Voice: 952.837.2577 -- Fax: 952.837.2578 -- Mobile: 612.232.5972


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to