You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ed Smith <ed...@yahoo.com> on 2003/06/05 06:02:49 UTC

Tiles Internationalization with Definitions

I want to internationalize definitions in Tiles. 
Consider the following definitions in a tiles
configuation file:

 <definition name="layout" path="/layout.jsp">
    <put name="title" value="Default" />
    <put name="header" value="/header.jsp" />
 </definition>

<definition name="index" extends="layout">
  <put name="title" value="Index" />
</definition>

I would like to internationalize the title values.  I
know I can create a tiles configuration file for each
language; however, these files would mostly be
duplicates of one another with only the titles changed
so maintenance would be difficult.  What's the best
way to solve this?  Is there some way to make
something like the following work?

 <definition name="layout" path="/layout.jsp">
    <put name="title" value=<bean:message
key="tile.layout">/>
    <put name="header" value="/header.jsp" />
 </definition>

Thanks.

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Tiles Internationalization with Definitions

Posted by Paweł Rzepa <rz...@icslab.agh.edu.pl>.

Jason Lea wrote:

> Ed Smith wrote:
>
>> I want to internationalize definitions in Tiles. Consider the 
>> following definitions in a tiles
>> configuation file:
>>
>>  <definition name="layout" path="/layout.jsp">
>>     <put name="title" value="Default" />
>>     <put name="header" value="/header.jsp" />
>>  </definition>
>>
>> <definition name="index" extends="layout">
>>   <put name="title" value="Index" />
>> </definition>
>>
>> I would like to internationalize the title values.  I
>> know I can create a tiles configuration file for each
>> language; however, these files would mostly be
>> duplicates of one another with only the titles changed
>> so maintenance would be difficult.  What's the best
>> way to solve this?  Is there some way to make
>> something like the following work?
>>
>>  <definition name="layout" path="/layout.jsp">
>>     <put name="title" value=<bean:message
>> key="tile.layout">/>
>>     <put name="header" value="/header.jsp" />
>>  </definition>
>
>
> You obviously cannot put the <bean:message> tag in the tiles-defs.xml.
>
> You can probably do it this way:
>
> tiles-defs.xml:
> <definition name="layout" path="/layout.jsp">
>    <put name="title" value="tile.layout" />
>    <put name="header" value="/header.jsp" />
> </definition>
>
> <definition name="index" extends="layout">
>   <put name="title" value="index.title" />
> </definition>
>
> <definition name="otherpage" extends="layout">
>   <put name="title" value="otherpage.title" />
> </definition>
>
>
> header.jsp:
> <bean:define id="pageTitle">
>     <tiles:getAsString name="title"/>
> </bean:define>
> <head>
>     <title><bean:message name="pageTitle" /></title>
> </head>

or, to simplify:
 <tiles:importAttribute name="title"/>
...
<title><bean:message name="title"/></title>

>
>
>
> application.properties:
> index.title=Index
> otherpage.title=Other Page
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Tiles Internationalization with Definitions

Posted by Jason Lea <ja...@kumachan.net.nz>.
Ed Smith wrote:
> I want to internationalize definitions in Tiles. 
> Consider the following definitions in a tiles
> configuation file:
> 
>  <definition name="layout" path="/layout.jsp">
>     <put name="title" value="Default" />
>     <put name="header" value="/header.jsp" />
>  </definition>
> 
> <definition name="index" extends="layout">
>   <put name="title" value="Index" />
> </definition>
> 
> I would like to internationalize the title values.  I
> know I can create a tiles configuration file for each
> language; however, these files would mostly be
> duplicates of one another with only the titles changed
> so maintenance would be difficult.  What's the best
> way to solve this?  Is there some way to make
> something like the following work?
> 
>  <definition name="layout" path="/layout.jsp">
>     <put name="title" value=<bean:message
> key="tile.layout">/>
>     <put name="header" value="/header.jsp" />
>  </definition>

You obviously cannot put the <bean:message> tag in the tiles-defs.xml.

You can probably do it this way:

tiles-defs.xml:
<definition name="layout" path="/layout.jsp">
    <put name="title" value="tile.layout" />
    <put name="header" value="/header.jsp" />
</definition>

<definition name="index" extends="layout">
   <put name="title" value="index.title" />
</definition>

<definition name="otherpage" extends="layout">
   <put name="title" value="otherpage.title" />
</definition>


header.jsp:
<bean:define id="pageTitle">
     <tiles:getAsString name="title"/>
</bean:define>
<head>
     <title><bean:message name="pageTitle" /></title>
</head>


application.properties:
index.title=Index
otherpage.title=Other Page


-- 
Jason Lea


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org