This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Internationalization Problen

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi Purushothamann,
I got the solution.
Thanks a lot!!!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic