• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Internationalization Problen

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
In my application am using struts framework, to build internationalization.
The Appln will be started by taking the computer Locale like ex:en_US(english). And the Home Page wil allow the user to choose any lang. Like Chinese or German in the drop down menu. If the user selects the Chinese lang. then rest of the appl. should display in chinese lang. only.
For this mine code is.....
----------This code wil go in home.jsp ------
<html:form action="/Home" method="post">

<nobr><select name="tname" style="font-size:0.8em;" tabindex="1" class="button">

<option value="en" ><bean:message key="en"/></option>
<option value="de" ><bean:message key="de"/></option>
<option value="zh" ><bean:message key="zh"/></option>
</select>
</nobr>

<html:submit><bean:message key="selectlang"/></html:submit>

</html:form>


------This code wil go in homeForm.java ------
String tname=null;

public String getTname() {
return (this.tname);
}

public void setTname(String tname) {
this.tname = tname;
}

------This code wil go in homeAction.java ------

if(rEBHomeSearchForm.getTname()==null)
{
session.setAttribute("org.apache.struts.action.LOCALE", currentLocale.toString());
}
// For English Language selection
else if(rEBHomeSearchForm.getTname().equals("en"))
{
session.setAttribute("org.apache.struts.action.LOCALE", new Locale("en"));
}
// For Chinese language selection
{
session.setAttribute("org.apache.struts.action.LOCALE", new Locale("zh"));
}



// For German Language selection
else if(rEBHomeSearchForm.getTname().equals("de"))
{
session.setAttribute("org.apache.struts.action.LOCALE", new Locale("de"));
}
========
The problem is, am not able to mentain the session value of particular lang assigned by the user. If the user selects the chinese then the home wil be display but for next further pages its again displaying in english only.
Please tel me how to rectify my code.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Couple of things

- Replace "org.apache.struts.action.LOCALE" with Globals.LOCALE_KEY (though it's not critical)
- Try configuring controller not to process setting locale.
<controller ... locale="false" />

Try debugging to see when the locale is reset and where it's happening if the above option didn't work.
 
Anand Nuchchi
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I tried for Global.LOCALE_KEY but its showing error.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try putting the following in your struts-config.xml file.

<controller locale="false" />

This will tell Struts not to set the locale. I assume you'd want to do this since you're already setting it yourself.
[ July 31, 2006: Message edited by: Merrill Higginson ]
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's Globals.LOCALE_KEY not Global.LOCALE_KEY. Try the controller option and see if it works otherwise you need to find out when the session attribute is updated. You can write a listener to log the updates (though it's long shot and will not be required
 
Anand Nuchchi
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Purushothamann,
I got the solution.
Thanks a lot!!!
 
I was born with webbed fish toes. This tiny ad is my only friend:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic