2013-10-17 73 views
2

我使用vaadin框架,並在我的應用程序有:的HttpServletRequest的getLocale返回操作系統語言環境不是瀏覽器語言環境

@Override 
public void onRequestStart(HttpServletRequest request, 
     HttpServletResponse response) { 
    currentIP = request.getRemoteAddr(); 
    setLocale(request.getLocale()); 
    handle.set(this);  
    this.request = request;  
    this.response = response; 
} 

然而,request.getLocale()返回en_US,這是我的操作系統語言環境。但是,在用於切換語言環境的Firefox插件(https://addons.mozilla.org/cs/firefox/addon/quick-locale-switcher/?src=userprofile)中,我已將其設置爲cs_CZ,但getLocale()仍將返回en_US

+0

你可以發佈你從瀏覽器發送的Accept-Language頭嗎?我認爲Quick Locale Switcher只會更改Firefox UI,而不會更改HTTP標頭。 – chrylis

+0

'en-us,ja; q = 0.7,en; q = 0.3'。嗯,我認爲插件改變了這個事情,因爲我想測試出不同的語言環境以支持我的翻譯...... – Enerccio

+1

嘗試使用Preferences-> Content-> Languages。 – chrylis

回答

1

嘗試讓會議現場:

UI.getCurrent().getSession().getLocale(); 

爲我工作。