开发者

Determining user locale on server side in GWT app

开发者 https://www.devze.com 2023-01-20 22:48 出处:网络
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

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 开发者_Python百科to do this but the documentation is a little thin. Is this possible?


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

Locale userPreferredLocale = request.getLocale();


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: GWT: get locale information from server side?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消