Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Using struts2 only for internationalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using struts2 only for internationalization" Watch "Using struts2 only for internationalization" New topic
Author

Using struts2 only for internationalization

lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi everybody,

I have an application which is not developed in any framework right now that is in English language . I want to make it internationalized by using struts2 but thing is that the struts 2 will not be used in any of the features of that application only for internationalization of that website we have to use it..Kindly Suggest.

Regards,
Lokesh Kumar Pattajoshi
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Please Ease Up. Every question on Javaranch is "urgent", at least to the person asking it.
Struts 2 is an implementation of a Front Controller. I don't see how one can use it for internationalization without using the Front Controller aspect of it. How would it get invoked?
Perhaps you should look at using resource bundles (since that's how Struts 2 accomplishes localization anyway).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Agreed--if you're not using Struts 2, don't use Struts 2--don't just use it for I18N, use resource bundles.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
can we configure front controller in web.xml file?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

lokesh pattajoshi wrote:can we configure front controller in web.xml file?


What one puts in the web.xml file tells the server to use Struts 2 for a particular context, among other things. The actual configuration of Struts 2 happens elsewhere (see here).
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Thanks joe for your valuable help.can you please tell me who decides which application resources has to call.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure what you just asked. Struts 2 I18N/localization is described here.

Again, and I cannot stress this enough, using S2 *just* for localization is silly.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

Just use resource bundles and the JSTL and be done with it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
is resource bundles and the JSTL will be easier as struts 2 i18n ? if you have any link(tutorial) then kindly send me..?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

The JSTL Specification would be the best resource.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

lokesh pattajoshi wrote:is resource bundles and the JSTL will be easier as struts 2 i18n ?

It is if you're not doing anything else with S2, since the S2 message tags requires the pages to be run through an S2 action. It'd be like using a sledge hammer to bang in a push pin into a cork board.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
i wrote an application in struts2 my application is following below steps..

1)First login Screen will appear
2)Whenever you will give userID and password and click submit button it is going to action for validation i am setting this variable in session
session.setAttribute("org.apache.struts.action.LOCALE", new Locale("fr"));
3)Afeter that from Action class i am forwarding request to success page in success page it is showing the contents in french language.
4) from success page there is another hyper link to UserDetails page in that page the contents are being shown in English language (default).
but there also session.getAttribute("org.apache.struts.action.LOCALE") is returning fr.

kindly suggest how to display french language instead of English in UserDetails page.

Thanks and Regards,
Lokesh Kumar Pattajoshi
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://struts.apache.org/2.1.8/docs/localization.html
http://struts.apache.org/2.1.8/docs/i18n-interceptor.html

Isn't that constant for Struts 1?

You've got multiple people telling you that using Struts 2 *just* for localization is a bad idea, particularly since you *already have a written application*.

Why don't you believe any of us?
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi Newton thanks for your replay.Yes that is the constant of both struts 1 and struts 2.

Hope you got tense to me..I always believe to code ranch people that's why i interact a lot with all of you also whenever i get free time i post my comment to others..Really this forum is very very nice one i want to tell thanks to all of you for providing your valuable help to us..

Thanks and Regards
Lokesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

lokesh pattajoshi wrote:Hi Newton thanks for your replay.Yes that is the constant of both struts 1 and struts 2.

No, no it's not the constant for Struts 2.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
But it is also working fine in struts 2 is there any similar constant in struts 2..?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I wrote:http://struts.apache.org/2.1.8/docs/localization.html
http://struts.apache.org/2.1.8/docs/i18n-interceptor.html

And it's *not* working fine, since the next page doesn't have French on it.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
OK.I am using below code for setting locale as fr in action class (session) but still default language is being shown in jsp is there any way to store locale in session

HttpServletRequest request=ServletActionContext.getRequest();
HttpSession session=request.getSession();
session.setAttribute("request_locale","fr");
//session.setAttribute("WW_TRANS_I18N_LOCALE","fr"); //this is also not working
//session.setAttribute("request_only_locale","fr");//this is also not working

also i have configured below code in action

<interceptor-ref name="i18n"/>
<interceptor-ref name="basicStack"/>
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi everbody,
is JSTL uses cache to store resource bundle(i am using .properties files as Resource Bundle) ?if yes how can we check..?

Thanks and Regards,
Lokesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please ask JSP/JSTL questions in the JSP forum.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Sorry Newton for my mistake..as the topic was running based on JSTL i asked this question OK i am moving it to JSP/JSTL questions.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(Since I haven't seen your new post yet, and I'm out the door, see the ResourceBundle Javadocs.)
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Not a problem Newton.thanks for your reply i have also moved this topic to JSP forums.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using struts2 only for internationalization
 
Similar Threads
Struts2
In struts2
Struts2: Localization issue with s:text tag
Styling In Struts2
Struts1 and Struts2