为什么GWT忽略浏览器的语言环境? [英] Why does GWT ignore browser locale?
问题描述
GWT无论从区域设置属性或区域设置查询字符串得到的语言环境。如果不指定,它使用默认(即EN_US)区域。
GWT gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie en_US) locale.
为什么不从浏览器设置得到它?
Why doesn't it get it from the browser settings?
这似乎这个唯一的办法就是像一个JSP读取浏览器语言环境并设置区域设置或使用查询字符串重定向soemthing,以取代静态html启动页。必须有比这更好的解决方案,或者干脆硬编码的语言环境,肯定?
It seems the only solution to this is to replace your static html launch page with soemthing like a JSP that reads the browser locales and sets the locale or redirects using the query string. There has to be a better solution than this or simply hard-coding a locale, surely?
推荐答案
您也可以把这个开关在* .gwt.xml
You can also put this switch in your *.gwt.xml
<set-configuration-property name="locale.useragent" value="Y"/>
这将根据在浏览器中选择语言添加的语言选择。您也可以通过设置控制搜索顺序区域
this will add language selecting based on language selected in browser. You can also control search order for locale by setting
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>
但要注意,在IE浏览器这不起作用 - 您应该制定服务器端语言挑基于接受语言头由IE发送
But beware that in IE this doesn't work - you should develop server-side language pick based on 'Accept-Language' header send by the IE.
这篇关于为什么GWT忽略浏览器的语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!