You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Manoj Dhore <ma...@sword-soft.com> on 2009/03/30 16:06:45 UTC

Localization in Struts 2.0

Can someone please provide me with some information about localization
in struts 2.

 

I am basically trying to have 2 locale : English and German for which I
have created two different properties file. viz : index_en.properties
and index_de.properties. I have put both these file in the same working
directory as that for my Action class.

 

My action class execute method is as follows : 

 

public String execute() throws Exception {

        setMessage(getText(TITLE));             // TITLE is a final
static string refering to a key in properties file 

        return SUCCESS;

    }

 

However when I try to access the title field in my jsp  using
<s:property value="title"/>, it displays as title instead of the value
of this key.

 

 I am not sure if its able to pick up the properties files.  Any help
would be much appreciated.

 

Thanks in advance.

 

Regards,

Manoj

 

 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this email in error please notify the
originator of the message. This footer also confirms that this
email message has been scanned for the presence of computer viruses.

Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Sword Intech.

Scanning of this message and addition of this footer is performed
by Websense Email Security software in conjunction with 
virus detection software.


Re:RE: Localization in Struts 2.0

Posted by xnpeng <xn...@163.com>.
I think the properties files are sequenced like:
1,ActionName.properties;
2,PackageName.properties;
3,Default.paroperties(you can tell struts2 in config file);




在2009-03-30,"Manoj Dhore" <ma...@sword-soft.com> 写道:
>Hi Poul,
>
> Thanks for your help. It worked fine. The problem was with the properties file name. The property file name was different from the Action name.
>
>But, I had a quick question here. Does this mean that in real world, I would have to create the same number of property file as that of the actions anticipating the request or do we have some inbuilt action is struts-default to take care of.
>
> Your help is much appreciated.
>
>Regards,
>Manoj
>
>
>
>-----Original Message-----
>From: Paweł Wielgus [mailto:poulwiel@gmail.com] 
>Sent: 30 March 2009 15:27
>To: Struts Users Mailing List
>Subject: Re: Localization in Struts 2.0
>
>Hi Manoj,
>when You are accesing <s:property value="title"/> You are asking for
>Action.getTitle() method (or any other on the stack by that name).
>
>Simply try s:text or read:
>http://struts.apache.org/2.x/docs/text.html
>and
>http://struts.apache.org/2.x/docs/localization.html
>
>Best greetings,
>Paweł Wielgus.
>
>
>
>
>2009/3/30 Manoj Dhore <ma...@sword-soft.com>:
>> Can someone please provide me with some information about localization
>> in struts 2.
>>
>>
>>
>> I am basically trying to have 2 locale : English and German for which I
>> have created two different properties file. viz : index_en.properties
>> and index_de.properties. I have put both these file in the same working
>> directory as that for my Action class.
>>
>>
>>
>> My action class execute method is as follows :
>>
>>
>>
>> public String execute() throws Exception {
>>
>>        setMessage(getText(TITLE));             // TITLE is a final
>> static string refering to a key in properties file
>>
>>        return SUCCESS;
>>
>>    }
>>
>>
>>
>> However when I try to access the title field in my jsp  using
>> <s:property value="title"/>, it displays as title instead of the value
>> of this key.
>>
>>
>>
>>  I am not sure if its able to pick up the properties files.  Any help
>> would be much appreciated.
>>
>>
>>
>> Thanks in advance.
>>
>>
>>
>> Regards,
>>
>> Manoj
>>
>>
>>
>>
>>
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>>
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom
>> they are addressed.
>> If you have received this email in error please notify the
>> originator of the message. This footer also confirms that this
>> email message has been scanned for the presence of computer viruses.
>>
>> Any views expressed in this message are those of the individual
>> sender, except where the sender specifies and with authority,
>> states them to be the views of Sword Intech.
>>
>> Scanning of this message and addition of this footer is performed
>> by Websense Email Security software in conjunction with
>> virus detection software.
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
>This email and any files transmitted with it are confidential and
>intended solely for the use of the individual or entity to whom
>they are addressed.
>If you have received this email in error please notify the
>originator of the message. This footer also confirms that this
>email message has been scanned for the presence of computer viruses.
>
>Any views expressed in this message are those of the individual
>sender, except where the sender specifies and with authority,
>states them to be the views of Sword Intech.
>
>Scanning of this message and addition of this footer is performed
>by Websense Email Security software in conjunction with 
>virus detection software.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

Re: Localization in Struts 2.0

Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
i use only one package.properties file,
but read again Localization guide.

Best greetings,
Pawel Wielgus.


2009/3/30, Manoj Dhore <ma...@sword-soft.com>:
> Hi Poul,
>
>  Thanks for your help. It worked fine. The problem was with the properties
> file name. The property file name was different from the Action name.
>
> But, I had a quick question here. Does this mean that in real world, I would
> have to create the same number of property file as that of the actions
> anticipating the request or do we have some inbuilt action is struts-default
> to take care of.
>
>  Your help is much appreciated.
>
> Regards,
> Manoj
>
>
>
> -----Original Message-----
> From: Paweł Wielgus [mailto:poulwiel@gmail.com]
> Sent: 30 March 2009 15:27
> To: Struts Users Mailing List
> Subject: Re: Localization in Struts 2.0
>
> Hi Manoj,
> when You are accesing <s:property value="title"/> You are asking for
> Action.getTitle() method (or any other on the stack by that name).
>
> Simply try s:text or read:
> http://struts.apache.org/2.x/docs/text.html
> and
> http://struts.apache.org/2.x/docs/localization.html
>
> Best greetings,
> Paweł Wielgus.
>
>
>
>
> 2009/3/30 Manoj Dhore <ma...@sword-soft.com>:
>> Can someone please provide me with some information about localization
>> in struts 2.
>>
>>
>>
>> I am basically trying to have 2 locale : English and German for which I
>> have created two different properties file. viz : index_en.properties
>> and index_de.properties. I have put both these file in the same working
>> directory as that for my Action class.
>>
>>
>>
>> My action class execute method is as follows :
>>
>>
>>
>> public String execute() throws Exception {
>>
>>        setMessage(getText(TITLE));             // TITLE is a final
>> static string refering to a key in properties file
>>
>>        return SUCCESS;
>>
>>    }
>>
>>
>>
>> However when I try to access the title field in my jsp  using
>> <s:property value="title"/>, it displays as title instead of the value
>> of this key.
>>
>>
>>
>>  I am not sure if its able to pick up the properties files.  Any help
>> would be much appreciated.
>>
>>
>>
>> Thanks in advance.
>>
>>
>>
>> Regards,
>>
>> Manoj
>>
>>
>>
>>
>>
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>> _
>>
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom
>> they are addressed.
>> If you have received this email in error please notify the
>> originator of the message. This footer also confirms that this
>> email message has been scanned for the presence of computer viruses.
>>
>> Any views expressed in this message are those of the individual
>> sender, except where the sender specifies and with authority,
>> states them to be the views of Sword Intech.
>>
>> Scanning of this message and addition of this footer is performed
>> by Websense Email Security software in conjunction with
>> virus detection software.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed.
> If you have received this email in error please notify the
> originator of the message. This footer also confirms that this
> email message has been scanned for the presence of computer viruses.
>
> Any views expressed in this message are those of the individual
> sender, except where the sender specifies and with authority,
> states them to be the views of Sword Intech.
>
> Scanning of this message and addition of this footer is performed
> by Websense Email Security software in conjunction with
> virus detection software.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


RE: Localization in Struts 2.0

Posted by Manoj Dhore <ma...@sword-soft.com>.
Hi Poul,

 Thanks for your help. It worked fine. The problem was with the properties file name. The property file name was different from the Action name.

But, I had a quick question here. Does this mean that in real world, I would have to create the same number of property file as that of the actions anticipating the request or do we have some inbuilt action is struts-default to take care of.

 Your help is much appreciated.

Regards,
Manoj



-----Original Message-----
From: Paweł Wielgus [mailto:poulwiel@gmail.com] 
Sent: 30 March 2009 15:27
To: Struts Users Mailing List
Subject: Re: Localization in Struts 2.0

Hi Manoj,
when You are accesing <s:property value="title"/> You are asking for
Action.getTitle() method (or any other on the stack by that name).

Simply try s:text or read:
http://struts.apache.org/2.x/docs/text.html
and
http://struts.apache.org/2.x/docs/localization.html

Best greetings,
Paweł Wielgus.




2009/3/30 Manoj Dhore <ma...@sword-soft.com>:
> Can someone please provide me with some information about localization
> in struts 2.
>
>
>
> I am basically trying to have 2 locale : English and German for which I
> have created two different properties file. viz : index_en.properties
> and index_de.properties. I have put both these file in the same working
> directory as that for my Action class.
>
>
>
> My action class execute method is as follows :
>
>
>
> public String execute() throws Exception {
>
>        setMessage(getText(TITLE));             // TITLE is a final
> static string refering to a key in properties file
>
>        return SUCCESS;
>
>    }
>
>
>
> However when I try to access the title field in my jsp  using
> <s:property value="title"/>, it displays as title instead of the value
> of this key.
>
>
>
>  I am not sure if its able to pick up the properties files.  Any help
> would be much appreciated.
>
>
>
> Thanks in advance.
>
>
>
> Regards,
>
> Manoj
>
>
>
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed.
> If you have received this email in error please notify the
> originator of the message. This footer also confirms that this
> email message has been scanned for the presence of computer viruses.
>
> Any views expressed in this message are those of the individual
> sender, except where the sender specifies and with authority,
> states them to be the views of Sword Intech.
>
> Scanning of this message and addition of this footer is performed
> by Websense Email Security software in conjunction with
> virus detection software.
>
>

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


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this email in error please notify the
originator of the message. This footer also confirms that this
email message has been scanned for the presence of computer viruses.

Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Sword Intech.

Scanning of this message and addition of this footer is performed
by Websense Email Security software in conjunction with 
virus detection software.



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


Re: Localization in Struts 2.0

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Manoj,
when You are accesing <s:property value="title"/> You are asking for
Action.getTitle() method (or any other on the stack by that name).

Simply try s:text or read:
http://struts.apache.org/2.x/docs/text.html
and
http://struts.apache.org/2.x/docs/localization.html

Best greetings,
Paweł Wielgus.




2009/3/30 Manoj Dhore <ma...@sword-soft.com>:
> Can someone please provide me with some information about localization
> in struts 2.
>
>
>
> I am basically trying to have 2 locale : English and German for which I
> have created two different properties file. viz : index_en.properties
> and index_de.properties. I have put both these file in the same working
> directory as that for my Action class.
>
>
>
> My action class execute method is as follows :
>
>
>
> public String execute() throws Exception {
>
>        setMessage(getText(TITLE));             // TITLE is a final
> static string refering to a key in properties file
>
>        return SUCCESS;
>
>    }
>
>
>
> However when I try to access the title field in my jsp  using
> <s:property value="title"/>, it displays as title instead of the value
> of this key.
>
>
>
>  I am not sure if its able to pick up the properties files.  Any help
> would be much appreciated.
>
>
>
> Thanks in advance.
>
>
>
> Regards,
>
> Manoj
>
>
>
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed.
> If you have received this email in error please notify the
> originator of the message. This footer also confirms that this
> email message has been scanned for the presence of computer viruses.
>
> Any views expressed in this message are those of the individual
> sender, except where the sender specifies and with authority,
> states them to be the views of Sword Intech.
>
> Scanning of this message and addition of this footer is performed
> by Websense Email Security software in conjunction with
> virus detection software.
>
>

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