You can use the JSTL & Struts-EL (expression language)...
You can then use these tags:
<c:set var="logoutAction"><bean:message key="logout.action"/></c:set>
<c:set var="clickHere"><html:link forward="homepage"><bean:message key="click.here"/></html:link></c:set>
<bean:message key="preferences.test" arg0="${logoutAction}" arg1="${clickHere}"/>
The <c:set> tag puts it's contents into a variable defined by var. So this allows us to capture the contents of the <html:link> tag so we can substitute it later.
I have tested it and it actually works. Here is what I had in the property files:
application.properties:
preferences.test=to {0} click {1}
click.here=here
logout.action=logoutapplication_ja.properties:
preferences.test=click {1} to {0}
click.here=HERE
logout.action=LOGOUTand now the output: default: to logout click <a href="/Homepage.do">here</a> Japanese locale: click <a href="/Homepage.do">HERE</a> to LOGOUT
I needed to adjust my taglib definitions <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean" %>
and include put the following into my /WEB_INF/lib directory: struts-el.jar jstl.jar standard.jar
and add the following tld's: c.tld struts-html-el.tld struts-bean-el.tld
These are all in Struts 1.1RC1\contrib\struts-el\lib
To read about JSTL V1.0: http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
Hope this helps...
Jason Lea
Jason Lea wrote:
This can be done in Struts using the MessageResources:
Struts Tip #4 - Formatting output with MessageResources http://husted.com/struts/tips/004.html
also have a look at the Java Internationalization Tutorial's page http://java.sun.com/docs/books/tutorial/i18n/format/messageFormat.html
You can use this to specify the format for each language and substitute in the correct values at run time.
Jason Lea
David M. Karr wrote:
"Dolf" == Dolf Starreveld <[EMAIL PROTECTED]> writes:
Dolf> On a struts based JSP is need to output something like:
Dolf> To do x, click <here>
Dolf> <here> means that words needs to be a link. Without using resource (and
Dolf> internationalization), it would look like:
Dolf> <P>To do x, click <a href="URL">here</a></P>
Dolf> Without internationalization 100% OK, it would become: Dolf> <P> Dolf> <bean:message key="click"/> Dolf> <html:link action="/clickAction">here</html:link> Dolf> </P>
Dolf> click=To do x, click
Dolf> The problem is that this is not fully localizable. In some languages the word
Dolf> "here" would have to be in a different position. I do not want to have
Dolf> different JSPs for each locale.
Dolf> I know I could make a custom tag to do this, but I am hoping somebody already
Dolf> has a solution to this problem.
It's messy, but you could define your messages that contain links to have three
pieces, being "before link", "link", and "after link". You could specify all
three in your JSP page in the same way for every locale. Some locales would
have all three pieces defined, but some locales might just have the "before
link" and "link", and the "after link" would be empty.
If your locale-specific arrangements are any more complicated than this, then
you should use different JSP pages for each locale. You might be able to get
away with using a smaller include file for just the locale-specific part, and
have the rest of the page just use resources and simple tricks like as
described above.
-- Jason Lea Email: [EMAIL PROTECTED] Phone/Fax: +64 3 381 2907 Mobile: +64 21 040 2708 Address: 9a Tabart Street, Christchurch, New Zealand
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

