You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by RobotDan <dj...@gmail.com> on 2011/04/05 16:22:54 UTC

Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles

I'm running Jetspeed 2.2.0, and Velocity tools 1.3.

In my header.vm decorator, I'm using ResourceTool to retrieve translated
text.

Here is my tool configuration.

    <tool>
        <key>text</key>
        <class>org.apache.velocity.tools.generic.ResourceTool</class>
        <parameter name="bundles" value="com.sometranslatedresources"/>
        <parameter name="locale" value="en_US"/>
    </tool>

Both

   com.sometranslatedresources.properties
   com.sometranslatedresources_ja.properties

exist, but the only way I can get the Japanese translation to work is to
modify the velocity tool to have a default locale of "ja".

According to the documentation for ResourceTool
 (
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
 )

     *"and the default locale is either: the result of
HttpServletRequest.getLocale() (if used in request scope of a VelocityView
app)"*

The request has the correct locale from the browser configuration.

Here is my workaround in my velocity template.

     #set($tt = $text.locale($request.getLocale()))

This seems like it should not be necessary.  Has anyone else experienced
this problem and found a resolution?


Thanks.
Daniel

Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles

Posted by robotdan <dj...@gmail.com>.
Thank you. I realize now my mistake.

@ Velocity Tools 1.3, the ResourceTool does not use the locale in the
request, it only does so in version 2 or greater.
I must have been viewing a newer version of the javadoc.

I was able to utilize ViewResourceTool @ 1.3 to accomplish the same goal.
Once we move to a newer version of Velocity Tools I can then utilize
ResourceTool again.

Thanks.


On Tue, Apr 5, 2011 at 5:42 PM, Woonsan Ko <wo...@yahoo.com> wrote:

> In the v1.3 javadoc, it doesn't say anything about scope:
>
> http://velocity.apache.org/tools/releases/1.3/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
>
> So, the feature may be introduced later (since 2.0?).
>
> Woonsan
>
> --- On Tue, 4/5/11, Daniel DeGroff <dj...@gmail.com> wrote:
>
> > From: Daniel DeGroff <dj...@gmail.com>
> > Subject: Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't
> load translated bundles
> > To: "Jetspeed Users List" <je...@portals.apache.org>
> > Date: Tuesday, April 5, 2011, 11:34 PM
> > Yes.   Sorry, I left
> > that out.  I have tried it both ways.
> >
> >     <tool>
> >         <key>text</key>
> >
> > <scope>request</scope>
> >
> > <class>org.apache.velocity.tools.generic.ResourceTool</class>
> >         <parameter name="bundles"
> > value="com.sometranslatedresources"/>
> >
> >         <parameter name="locale"
> > value="en_US"/>
> >     </tool>
> >
> > On Tue, Apr 5, 2011 at 2:13 PM, Woonsan Ko <wo...@yahoo.com>
> > wrote:
> >
> > > Hi Daniel,
> > >
> > > According to the javadoc, the toolbox should be scoped
> > as 'request' in the
> > > configuration.
> > > Did you have that?
> > >
> > > Regards,
> > >
> > > Woonsan
> > >
> > > --- On Tue, 4/5/11, RobotDan <dj...@gmail.com>
> > wrote:
> > >
> > > > From: RobotDan <dj...@gmail.com>
> > > > Subject: Using ResourceTool out of the velocity
> > toolbox 1.3 doesn't load
> > > translated bundles
> > > > To: jetspeed-user@portals.apache.org
> > > > Date: Tuesday, April 5, 2011, 4:22 PM
> > > > I'm running Jetspeed 2.2.0, and
> > > > Velocity tools 1.3.
> > > >
> > > > In my header.vm decorator, I'm using ResourceTool
> > to
> > > > retrieve translated
> > > > text.
> > > >
> > > > Here is my tool configuration.
> > > >
> > > >     <tool>
> > > >
> >    <key>text</key>
> > > >
> > > >
> > <class>org.apache.velocity.tools.generic.ResourceTool</class>
> > > >
> >    <parameter name="bundles"
> > > > value="com.sometranslatedresources"/>
> > > >
> >    <parameter name="locale"
> > > > value="en_US"/>
> > > >     </tool>
> > > >
> > > > Both
> > > >
> > > >
> > com.sometranslatedresources.properties
> > > >
> > com.sometranslatedresources_ja.properties
> > > >
> > > > exist, but the only way I can get the Japanese
> > translation
> > > > to work is to
> > > > modify the velocity tool to have a default locale
> > of "ja".
> > > >
> > > > According to the documentation for ResourceTool
> > > >  (
> > > >
> > >
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
> > > >  )
> > > >
> > > >      *"and the default locale is
> > > > either: the result of
> > > > HttpServletRequest.getLocale() (if used in
> > request scope of
> > > > a VelocityView
> > > > app)"*
> > > >
> > > > The request has the correct locale from the
> > browser
> > > > configuration.
> > > >
> > > > Here is my workaround in my velocity template.
> > > >
> > > >      #set($tt =
> > > > $text.locale($request.getLocale()))
> > > >
> > > > This seems like it should not be necessary.
> > Has
> > > > anyone else experienced
> > > > this problem and found a resolution?
> > > >
> > > >
> > > > Thanks.
> > > > Daniel
> > > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles

Posted by Woonsan Ko <wo...@yahoo.com>.
In the v1.3 javadoc, it doesn't say anything about scope:
http://velocity.apache.org/tools/releases/1.3/javadoc/org/apache/velocity/tools/generic/ResourceTool.html

So, the feature may be introduced later (since 2.0?).

Woonsan

--- On Tue, 4/5/11, Daniel DeGroff <dj...@gmail.com> wrote:

> From: Daniel DeGroff <dj...@gmail.com>
> Subject: Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles
> To: "Jetspeed Users List" <je...@portals.apache.org>
> Date: Tuesday, April 5, 2011, 11:34 PM
> Yes.   Sorry, I left
> that out.  I have tried it both ways.
> 
>     <tool>
>         <key>text</key>
>        
> <scope>request</scope>
>        
> <class>org.apache.velocity.tools.generic.ResourceTool</class>
>         <parameter name="bundles"
> value="com.sometranslatedresources"/>
> 
>         <parameter name="locale"
> value="en_US"/>
>     </tool>
> 
> On Tue, Apr 5, 2011 at 2:13 PM, Woonsan Ko <wo...@yahoo.com>
> wrote:
> 
> > Hi Daniel,
> >
> > According to the javadoc, the toolbox should be scoped
> as 'request' in the
> > configuration.
> > Did you have that?
> >
> > Regards,
> >
> > Woonsan
> >
> > --- On Tue, 4/5/11, RobotDan <dj...@gmail.com>
> wrote:
> >
> > > From: RobotDan <dj...@gmail.com>
> > > Subject: Using ResourceTool out of the velocity
> toolbox 1.3 doesn't load
> > translated bundles
> > > To: jetspeed-user@portals.apache.org
> > > Date: Tuesday, April 5, 2011, 4:22 PM
> > > I'm running Jetspeed 2.2.0, and
> > > Velocity tools 1.3.
> > >
> > > In my header.vm decorator, I'm using ResourceTool
> to
> > > retrieve translated
> > > text.
> > >
> > > Here is my tool configuration.
> > >
> > >     <tool>
> > >     
>    <key>text</key>
> > >
> > >
> <class>org.apache.velocity.tools.generic.ResourceTool</class>
> > >     
>    <parameter name="bundles"
> > > value="com.sometranslatedresources"/>
> > >     
>    <parameter name="locale"
> > > value="en_US"/>
> > >     </tool>
> > >
> > > Both
> > >
> > >   
> com.sometranslatedresources.properties
> > >   
> com.sometranslatedresources_ja.properties
> > >
> > > exist, but the only way I can get the Japanese
> translation
> > > to work is to
> > > modify the velocity tool to have a default locale
> of "ja".
> > >
> > > According to the documentation for ResourceTool
> > >  (
> > >
> > http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
> > >  )
> > >
> > >      *"and the default locale is
> > > either: the result of
> > > HttpServletRequest.getLocale() (if used in
> request scope of
> > > a VelocityView
> > > app)"*
> > >
> > > The request has the correct locale from the
> browser
> > > configuration.
> > >
> > > Here is my workaround in my velocity template.
> > >
> > >      #set($tt =
> > > $text.locale($request.getLocale()))
> > >
> > > This seems like it should not be necessary. 
> Has
> > > anyone else experienced
> > > this problem and found a resolution?
> > >
> > >
> > > Thanks.
> > > Daniel
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >
> >
> 

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


Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles

Posted by Daniel DeGroff <dj...@gmail.com>.
Yes.   Sorry, I left that out.  I have tried it both ways.

    <tool>
        <key>text</key>
        <scope>request</scope>
        <class>org.apache.velocity.tools.generic.ResourceTool</class>
        <parameter name="bundles" value="com.sometranslatedresources"/>

        <parameter name="locale" value="en_US"/>
    </tool>

On Tue, Apr 5, 2011 at 2:13 PM, Woonsan Ko <wo...@yahoo.com> wrote:

> Hi Daniel,
>
> According to the javadoc, the toolbox should be scoped as 'request' in the
> configuration.
> Did you have that?
>
> Regards,
>
> Woonsan
>
> --- On Tue, 4/5/11, RobotDan <dj...@gmail.com> wrote:
>
> > From: RobotDan <dj...@gmail.com>
> > Subject: Using ResourceTool out of the velocity toolbox 1.3 doesn't load
> translated bundles
> > To: jetspeed-user@portals.apache.org
> > Date: Tuesday, April 5, 2011, 4:22 PM
> > I'm running Jetspeed 2.2.0, and
> > Velocity tools 1.3.
> >
> > In my header.vm decorator, I'm using ResourceTool to
> > retrieve translated
> > text.
> >
> > Here is my tool configuration.
> >
> >     <tool>
> >         <key>text</key>
> >
> > <class>org.apache.velocity.tools.generic.ResourceTool</class>
> >         <parameter name="bundles"
> > value="com.sometranslatedresources"/>
> >         <parameter name="locale"
> > value="en_US"/>
> >     </tool>
> >
> > Both
> >
> >    com.sometranslatedresources.properties
> >    com.sometranslatedresources_ja.properties
> >
> > exist, but the only way I can get the Japanese translation
> > to work is to
> > modify the velocity tool to have a default locale of "ja".
> >
> > According to the documentation for ResourceTool
> >  (
> >
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
> >  )
> >
> >      *"and the default locale is
> > either: the result of
> > HttpServletRequest.getLocale() (if used in request scope of
> > a VelocityView
> > app)"*
> >
> > The request has the correct locale from the browser
> > configuration.
> >
> > Here is my workaround in my velocity template.
> >
> >      #set($tt =
> > $text.locale($request.getLocale()))
> >
> > This seems like it should not be necessary.  Has
> > anyone else experienced
> > this problem and found a resolution?
> >
> >
> > Thanks.
> > Daniel
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles

Posted by Woonsan Ko <wo...@yahoo.com>.
Hi Daniel,

According to the javadoc, the toolbox should be scoped as 'request' in the configuration.
Did you have that?

Regards,

Woonsan

--- On Tue, 4/5/11, RobotDan <dj...@gmail.com> wrote:

> From: RobotDan <dj...@gmail.com>
> Subject: Using ResourceTool out of the velocity toolbox 1.3 doesn't load translated bundles
> To: jetspeed-user@portals.apache.org
> Date: Tuesday, April 5, 2011, 4:22 PM
> I'm running Jetspeed 2.2.0, and
> Velocity tools 1.3.
> 
> In my header.vm decorator, I'm using ResourceTool to
> retrieve translated
> text.
> 
> Here is my tool configuration.
> 
>     <tool>
>         <key>text</key>
>        
> <class>org.apache.velocity.tools.generic.ResourceTool</class>
>         <parameter name="bundles"
> value="com.sometranslatedresources"/>
>         <parameter name="locale"
> value="en_US"/>
>     </tool>
> 
> Both
> 
>    com.sometranslatedresources.properties
>    com.sometranslatedresources_ja.properties
> 
> exist, but the only way I can get the Japanese translation
> to work is to
> modify the velocity tool to have a default locale of "ja".
> 
> According to the documentation for ResourceTool
>  (
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
>  )
> 
>      *"and the default locale is
> either: the result of
> HttpServletRequest.getLocale() (if used in request scope of
> a VelocityView
> app)"*
> 
> The request has the correct locale from the browser
> configuration.
> 
> Here is my workaround in my velocity template.
> 
>      #set($tt =
> $text.locale($request.getLocale()))
> 
> This seems like it should not be necessary.  Has
> anyone else experienced
> this problem and found a resolution?
> 
> 
> Thanks.
> Daniel
> 

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