From 7e6932b27785d8dd9309c9a4d7a5fa9824c6b9cf Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 9 Jun 2014 11:28:08 -0400 Subject: [PATCH] Fix locale preference storing --- src/main/java/com/gitblit/ConfigUserService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java index 0c5b2a58..d7d6c14f 100644 --- a/src/main/java/com/gitblit/ConfigUserService.java +++ b/src/main/java/com/gitblit/ConfigUserService.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -712,8 +713,14 @@ public class ConfigUserService implements IUserService { config.setBoolean(USER, model.username, DISABLED, true); } if (model.getPreferences() != null) { - if (model.getPreferences().getLocale() != null) { - String val = model.getPreferences().getLocale().getLanguage() + "_" + model.getPreferences().getLocale().getCountry(); + Locale locale = model.getPreferences().getLocale(); + if (locale != null) { + String val; + if (StringUtils.isEmpty(locale.getCountry())) { + val = locale.getLanguage(); + } else { + val = locale.getLanguage() + "_" + locale.getCountry(); + } config.setString(USER, model.username, LOCALE, val); } -- 2.39.5