You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Howard Moore <Ho...@Datapulse.com> on 2001/02/15 19:20:32 UTC

Internationalised 'alt' text

Can anybody suggest how I can add internationalised alt text to the
<html:img> tag?

If it were legal I would like to do something like the following;

<html:img src="someImage.png" alt="<bean:message
key='someImage.alt.text'/>"/>

but you can't nest tags like this.

If not does anybody think it would be useful to add an optional 'id'
attribute to the <bean:message> tag which, if set, causes the translated
message to be stored in a page context bean with the given name rather than
being written out? This would allow me to write something like;

<bean:message id="altTxt" key="someImage.alt.text"/>
<html:img src="someImage.png" alt="<%= altTxt %>"/>

It would also allow translated strings to be cached in the page if they are
going to be used repeatedly (inside a <logic:iterate> tag, for example).
This may improve performance considerably.

Any comments?

-------------------------------------------
Howard Moore
Senior Software Engineer
Datapulse CTI
Tel : +44 (0)1491 418000
Fax : +44 (0)1491 411459
E-mail: Howard.Moore@datapulse.com

Re: Internationalised 'alt' text

Posted by Oleg V Alexeev <go...@penza.net>.
Hello Howard,

I have fixed version of this tag with support of i18n. I can send it
to you.

Thursday, February 15, 2001, 9:20:32 PM, you wrote:

HM> Can anybody suggest how I can add internationalised alt text to the
HM> <html:img> tag?

HM> If it were legal I would like to do something like the following;

HM> <html:img src="someImage.png" alt="<bean:message
HM> key='someImage.alt.text'/>"/>

HM> but you can't nest tags like this.

HM> If not does anybody think it would be useful to add an optional 'id'
HM> attribute to the <bean:message> tag which, if set, causes the translated
HM> message to be stored in a page context bean with the given name rather than
HM> being written out? This would allow me to write something like;

HM> <bean:message id="altTxt" key="someImage.alt.text"/>
HM> <html:img src="someImage.png" alt="<%= altTxt %>"/>

HM> It would also allow translated strings to be cached in the page if they are
HM> going to be used repeatedly (inside a <logic:iterate> tag, for example).
HM> This may improve performance considerably.

HM> Any comments?

HM> -------------------------------------------
HM> Howard Moore
HM> Senior Software Engineer
HM> Datapulse CTI
HM> Tel : +44 (0)1491 418000
HM> Fax : +44 (0)1491 411459
HM> E-mail: Howard.Moore@datapulse.com



-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



Re: Internationalised 'alt' text

Posted by Craig Tataryn <Cr...@msdw.com>.
How about this:

<!-- MyResources would be replaced with whatever class name you used in the
application
        init-param you setup for the ActionServlet
-->
<jsp:useBean id="resouces" class="MyResources" />

<html:img src="someImage.png" alt='<%= resources.getString("someImage.alt.text")
%>'/>

Craig T.

Peter Alfors wrote:

> scratch that.  You would need to have a bean that had access to the messages.
>
> Peter Alfors wrote:
>
> > I think that <bean:define>  does what you want.
> >
> > <bean:define id="altTxt" property="someImage.alt.text"/>
> > <html:img src="someImage.png" alt="<%= altTxt %>"/>
> >
> > HTH,
> >     Pete
> >
> > Howard Moore wrote:
> >
> > > Can anybody suggest how I can add internationalised alt text to the
> > > <html:img> tag?
> > >
> > > If it were legal I would like to do something like the following;
> > >
> > > <html:img src="someImage.png" alt="<bean:message
> > > key='someImage.alt.text'/>"/>
> > >
> > > but you can't nest tags like this.
> > >
> > > If not does anybody think it would be useful to add an optional 'id'
> > > attribute to the <bean:message> tag which, if set, causes the translated
> > > message to be stored in a page context bean with the given name rather than
> > > being written out? This would allow me to write something like;
> > >
> > > <bean:message id="altTxt" key="someImage.alt.text"/>
> > > <html:img src="someImage.png" alt="<%= altTxt %>"/>
> > >
> > > It would also allow translated strings to be cached in the page if they are
> > > going to be used repeatedly (inside a <logic:iterate> tag, for example).
> > > This may improve performance considerably.
> > >
> > > Any comments?
> > >
> > > -------------------------------------------
> > > Howard Moore
> > > Senior Software Engineer
> > > Datapulse CTI
> > > Tel : +44 (0)1491 418000
> > > Fax : +44 (0)1491 411459
> > > E-mail: Howard.Moore@datapulse.com

--
I've been trying to change the world for years, but they just won't give me the
source code....


Re: Internationalised 'alt' text

Posted by Peter Alfors <pe...@irista.com>.
scratch that.  You would need to have a bean that had access to the messages.


Peter Alfors wrote:

> I think that <bean:define>  does what you want.
>
> <bean:define id="altTxt" property="someImage.alt.text"/>
> <html:img src="someImage.png" alt="<%= altTxt %>"/>
>
> HTH,
>     Pete
>
> Howard Moore wrote:
>
> > Can anybody suggest how I can add internationalised alt text to the
> > <html:img> tag?
> >
> > If it were legal I would like to do something like the following;
> >
> > <html:img src="someImage.png" alt="<bean:message
> > key='someImage.alt.text'/>"/>
> >
> > but you can't nest tags like this.
> >
> > If not does anybody think it would be useful to add an optional 'id'
> > attribute to the <bean:message> tag which, if set, causes the translated
> > message to be stored in a page context bean with the given name rather than
> > being written out? This would allow me to write something like;
> >
> > <bean:message id="altTxt" key="someImage.alt.text"/>
> > <html:img src="someImage.png" alt="<%= altTxt %>"/>
> >
> > It would also allow translated strings to be cached in the page if they are
> > going to be used repeatedly (inside a <logic:iterate> tag, for example).
> > This may improve performance considerably.
> >
> > Any comments?
> >
> > -------------------------------------------
> > Howard Moore
> > Senior Software Engineer
> > Datapulse CTI
> > Tel : +44 (0)1491 418000
> > Fax : +44 (0)1491 411459
> > E-mail: Howard.Moore@datapulse.com

Re: Internationalised 'alt' text

Posted by Peter Alfors <pe...@irista.com>.
I think that <bean:define>  does what you want.

<bean:define id="altTxt" property="someImage.alt.text"/>
<html:img src="someImage.png" alt="<%= altTxt %>"/>

HTH,
    Pete

Howard Moore wrote:

> Can anybody suggest how I can add internationalised alt text to the
> <html:img> tag?
>
> If it were legal I would like to do something like the following;
>
> <html:img src="someImage.png" alt="<bean:message
> key='someImage.alt.text'/>"/>
>
> but you can't nest tags like this.
>
> If not does anybody think it would be useful to add an optional 'id'
> attribute to the <bean:message> tag which, if set, causes the translated
> message to be stored in a page context bean with the given name rather than
> being written out? This would allow me to write something like;
>
> <bean:message id="altTxt" key="someImage.alt.text"/>
> <html:img src="someImage.png" alt="<%= altTxt %>"/>
>
> It would also allow translated strings to be cached in the page if they are
> going to be used repeatedly (inside a <logic:iterate> tag, for example).
> This may improve performance considerably.
>
> Any comments?
>
> -------------------------------------------
> Howard Moore
> Senior Software Engineer
> Datapulse CTI
> Tel : +44 (0)1491 418000
> Fax : +44 (0)1491 411459
> E-mail: Howard.Moore@datapulse.com