views:

35

answers:

3

I have implemented i18n on a GWT application to internationalize labels, buttons etc. Is there a way to determine the user locale on the server side of a GWT application. I have found a library called gwt_i18n_server_1.0.jar which I suspect allows me to do this but the documentation is a little thin. Is this possible?

+1  A: 

I don't know about GWT particularly, but if you can access request Object then you can retrieve like

Locale userPreferredLocale = request.getLocale();
org.life.java
A: 

Have a look at LocaleInfo.getCurrentLocale().

EDIT:

I'm sorry, didn't see the

user locale on the server side

What you could do is send the information from above to the server.

Or have a look at: http://stackoverflow.com/questions/1956299/gwt-get-locale-information-from-server-side

z00bs
Tried using this, but get the following error: java.lang.NoClassDefFoundError: Could not initialize class com.google.gwt.i18n.client.LocaleInfo I assumed it was because this was a CLIENT ONLY class?
Clinton Bosch
I updated my answer. I skipped the 'on the server side' part of your question. Sorry for that.
z00bs
A: 

If you can determine the Locale on the client side, you could stuff it into a cookie, then it should be made available to the server on all subsequent requests? The downside to that would be that you couldn't server a different "first" page depending on locale - you'd have your first page do the detection, then request the content asyncronously.

Curtis