You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Grish <gi...@hotmail.com> on 2008/02/12 08:58:53 UTC

Using il8n text in an interceptor

I'm studying how interceptors work and made a login interceptor based on Mark
Menard's great tutorial:
http://www.vitarara.org/cms/struts_2_cookbook/creating_a_login_interceptor

I managed to integrate the interceptor in my sample application but I want
to access my resource bundle for the localized error message. Is there a
method similar to the getText method for Interceptors? What would be  the
best approach for adding localized action error messages from an
interceptor?
-- 
View this message in context: http://www.nabble.com/Using-il8n-text-in-an-interceptor-tp15427096p15427096.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Using il8n text in an interceptor

Posted by Grish <gi...@hotmail.com>.
Well I read this:

"package.properties (of the directory where class is located and every
parent directory all the way to the root directory)"

and  tried moving around the package.properties around but findDefaultText
always returns null. My actions though are still able to retrieve the proper
text, but when my interceptor needs to access the resource bundle it can't
seem to find it. Anyone encountered a similar problem and figured it out? :(


Grish wrote:
> 
> Thanks for the suggestion! I tried integrating it to my code but the
> problem is findDefaultText always returns null. I traced the name and the
> locale that I am passing and they are correct. 
> 
> my package_en_US.properties is in my org.test.app.action package. My
> interceptor is in the org.test.app.interceptor package. Would the location
> of the property file be the problem? 
> 
> I read the API and I had the impression that if I moved up the properties
> up one level the properties file will still be seen. 
> 
> I tried moving it to org.test.app package  but i still seem to be getting
> null. Is there something wrong with my setup perhaps?
> 
> 
> Pablo Vazquez wrote:
>> 
>> // For future i18n purpose
>>      private String translate(String name) {
>>         
>>          String i18Name = LocalizedTextUtil.findDefaultText(name,
>> locale);
>>         
>>          if (i18Name == null) {
>>              i18Name = name;
>>          }
>>         
>>          return i18Name;
>>      }
>> 
>> Grish escribió:
>>> I'm studying how interceptors work and made a login interceptor based on
>>> Mark
>>> Menard's great tutorial:
>>> http://www.vitarara.org/cms/struts_2_cookbook/creating_a_login_interceptor
>>>
>>> I managed to integrate the interceptor in my sample application but I
>>> want
>>> to access my resource bundle for the localized error message. Is there a
>>> method similar to the getText method for Interceptors? What would be 
>>> the
>>> best approach for adding localized action error messages from an
>>> interceptor?
>>>   
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-il8n-text-in-an-interceptor-tp15427096p15473716.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Using il8n text in an interceptor

Posted by Grish <gi...@hotmail.com>.
Thanks for the suggestion! I tried integrating it to my code but the problem
is findDefaultText always returns null. I traced the name and the locale
that I am passing and they are correct. 

my package_en_US.properties is in my org.test.app.action package. My
interceptor is in the org.test.app.interceptor package. Would the location
of the property file be the problem? 

I read the API and I had the impression that if I moved up the properties up
one level the properties file will still be seen. 

I tried moving it to org.test.app package  but i still seem to be getting
null. Is there something wrong with my setup perhaps?


Pablo Vazquez wrote:
> 
> // For future i18n purpose
>      private String translate(String name) {
>         
>          String i18Name = LocalizedTextUtil.findDefaultText(name, locale);
>         
>          if (i18Name == null) {
>              i18Name = name;
>          }
>         
>          return i18Name;
>      }
> 
> Grish escribió:
>> I'm studying how interceptors work and made a login interceptor based on
>> Mark
>> Menard's great tutorial:
>> http://www.vitarara.org/cms/struts_2_cookbook/creating_a_login_interceptor
>>
>> I managed to integrate the interceptor in my sample application but I
>> want
>> to access my resource bundle for the localized error message. Is there a
>> method similar to the getText method for Interceptors? What would be  the
>> best approach for adding localized action error messages from an
>> interceptor?
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-il8n-text-in-an-interceptor-tp15427096p15429285.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Using il8n text in an interceptor

Posted by Pablo Vázquez Blázquez <pv...@denodo.com>.
// For future i18n purpose
     private String translate(String name) {
        
         String i18Name = LocalizedTextUtil.findDefaultText(name, locale);
        
         if (i18Name == null) {
             i18Name = name;
         }
        
         return i18Name;
     }

Grish escribió:
> I'm studying how interceptors work and made a login interceptor based on Mark
> Menard's great tutorial:
> http://www.vitarara.org/cms/struts_2_cookbook/creating_a_login_interceptor
>
> I managed to integrate the interceptor in my sample application but I want
> to access my resource bundle for the localized error message. Is there a
> method similar to the getText method for Interceptors? What would be  the
> best approach for adding localized action error messages from an
> interceptor?
>   


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