• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using struts2 only for internationalization

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we configure front controller in web.xml file?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks joe for your valuable help.can you please tell me who decides which application resources has to call.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use resource bundles and the JSTL and be done with it.
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSTL Specification would be the best resource.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it is also working fine in struts 2 is there any similar constant in struts 2..?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ask JSP/JSTL questions in the JSP forum.
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Since I haven't seen your new post yet, and I'm out the door, see the ResourceBundle Javadocs.)
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a problem Newton.thanks for your reply i have also moved this topic to JSP forums.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic