PL-7113 Remember last used choosen language on web client

This commit is contained in:
Nikita Petunin 2016-06-20 19:22:25 +04:00
parent 163b4af1b4
commit 887dd9707a

View File

@ -199,11 +199,13 @@ public class LoginWindow extends UIView {
} }
protected Locale resolveLocale(App app) { protected Locale resolveLocale(App app) {
String lastLocale = app.getCookieValue(COOKIE_LOCALE); if (globalConfig.getLocaleSelectVisible()) {
if (lastLocale != null) { String lastLocale = app.getCookieValue(COOKIE_LOCALE);
for (Locale locale : locales.values()) { if (lastLocale != null) {
if (locale.toLanguageTag().equals(lastLocale)) { for (Locale locale : locales.values()) {
return locale; if (locale.toLanguageTag().equals(lastLocale)) {
return locale;
}
} }
} }
} }
@ -472,7 +474,9 @@ public class LoginWindow extends UIView {
// locale could be set on the server // locale could be set on the server
if (connection.getSession() != null) { if (connection.getSession() != null) {
app.setLocale(connection.getSession().getLocale()); app.setLocale(connection.getSession().getLocale());
app.addCookie(COOKIE_LOCALE, locale.toLanguageTag()); if (globalConfig.getLocaleSelectVisible()) {
app.addCookie(COOKIE_LOCALE, locale.toLanguageTag());
}
} }
} catch (LoginException e) { } catch (LoginException e) {
log.info("Login failed: " + e.toString()); log.info("Login failed: " + e.toString());