• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

i18n

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been playing around with i18n and Struts and have gotten it to work via changing my Regional Settings and restarting Tomcat. However it is my understanding I should be able to update the Tools->Internet Options->Languages->Add... Add a Language and then move it up in priority. I've tested this out using Google and it works just fine. However I can't seem to get my struts application to work the same way. I've also looked at the struts tutorial on i18n and have had no luck with that example also. Is there anyone I can send a war files to that has worked with i18n and point out the error in my ways?
Thanks,
jb
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,
the Locale is the important factor here:
struts will automatically generate the right Locale in the users' sessions, depending on what locale the browser specifies in its http request. Changing the internet explorer options or your windows OS options will affect that.
The default Locale that struts will generate if it finds nothing in the http request depends on the language settings of the machine running the appserver, presumably windows with tomcat in your case.
Now the important thing is that you program the response using the Locale generated by struts. The application resources strings (messages) should be taken care of automatically if you have ApplicationResources_DE.properties, ApplicationResources_SP.properties etc etc for each language.
With date, numeric & currency formats and so on you have to pass the Locale from the session to the Java functions.
Does that cover what you were attempting to do?
Adam
 
Jeff Born
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes except what I have isn't working. I think I'm close because I can swith the locale via the regional settings and have spanish served.
Like you said though I shouldn't have to do this. I should be able select the language from IE.
Any ideas on where to look if changing the regional settings causes spanish to be served, but not changing the language vi IE?
PS I am using Tomcat 4.1 and Windows 2000.
Another question/request anyone have a war file they can send me that does i18n correctly that I can drop into the webapps directory in Tomcat and trace through how that works.
Thanks for the info,
jb
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry but the wars I've got are all huge and have to have their database up and running. Have you tried looking at the examples that come with struts, or in their resources links?
I'm not clear what you are looking at when you say ".. causes spanish to be served ...". Do you mean you have got hold of the Locale from the session and do Locale.getCountry()? That should show whatever you have set your browser locale to. Struts picks it up automatically from the request.
Adam
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have yet practical knowledge in struts i18n.
Maybe it is cached in the session? What about trying to invalidate the session?
Axel
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are currently working on a multi-lingual, Struts application for a major food chain.
The issues we've had implementing i18n were very problematic at first.
If you are just looking to display multi-lingual, static text, Struts is great and picks up Resource bundle and displays properly.
However, if you have forms and the user enters, say, French text, then how do you handle validation in a multi-lingual manner?
What about numbers entered as "2,00" versus "2.00", how do you do computations?
What we came up with was to extend the text tags within Struts to include a "key" attribute.
This key points to a resource bundle value like:
i18n.date={0,date}
i18n.number=(0,number}
i18n.currency={0,currency}
Using this method, your custom tag formats (according to the Struts locale) the information in the text box automatically.
To deal with posting multi-lingual data, we have a custom class that is called in the applicable "set" methods (of the form bean) to automatically convert the information, according to local.
Then in the "get" method (of form bean), the locale is once again applied to the values.
Using these processes, your code always deals with data in the same format whether in the Action, Form Bean, or other code.
 
Jeff Born
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Been out of the office for a while, but finally figured out my problem. I'm no where near ready to try to input data from different locales, but will reference your reply when I get there.
My solution was adding the following line

to the top of the wrapper.jsp (in my case it is actually main.jsp)
I had added the first 2 lines to the included jsps without the html:html locale="true" tag. This just doesn't work. I finally added the top line to the wrapper file. This file always included the html:html locale="true" tag. I concluded (incorrectly) that This file didn't need the UTF-8 line just the files that actually use <bean:message>
Thanks for all the help guys!
jb
 
David Yutzy
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One last thing to keep in mind...
The local="true" attrib. only effects struts "tags" that read from the resource bundle, NOT actual field values.
So your input field, dates, numbers, etc. will not be i18n using the locale="true".
 
Get me the mayor's office! I need to tell him about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic