diff --git a/server/src/main/java/org/gluu/oxtrust/LanguageBean.java b/server/src/main/java/org/gluu/oxtrust/LanguageBean.java index 04c2a16c6..b7755fc56 100644 --- a/server/src/main/java/org/gluu/oxtrust/LanguageBean.java +++ b/server/src/main/java/org/gluu/oxtrust/LanguageBean.java @@ -1,10 +1,9 @@ package org.gluu.oxtrust; import java.io.Serializable; -import java.util.LinkedHashMap; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; -import java.util.Map; - import javax.enterprise.context.SessionScoped; import javax.faces.context.FacesContext; import javax.faces.event.ValueChangeEvent; @@ -15,8 +14,9 @@ import org.gluu.oxtrust.model.GluuCustomAttribute; import org.gluu.oxtrust.model.GluuCustomPerson; import org.gluu.oxtrust.security.Identity; +import org.gluu.oxtrust.service.JsonConfigurationService; import org.gluu.oxtrust.service.PersonService; -import org.gluu.util.StringHelper; +import org.gluu.model.LocaleSupported; /** * Created by eugeniuparvan on 3/6/17. @@ -35,18 +35,23 @@ public class LanguageBean implements Serializable { @Inject private HomeAction homeAction; + + @Inject + private JsonConfigurationService jsonConfigurationService; - private static Map countries; + private List adminUiLocaleSupported; - static { - countries = new LinkedHashMap(); - countries.put("English", Locale.ENGLISH); // label, value - countries.put("Russian", new Locale("ru")); - countries.put("French", new Locale("fr")); - } + + + public List getCountriesInMap() { + adminUiLocaleSupported = jsonConfigurationService.getOxTrustappConfiguration().getAdminUiLocaleSupported(); + if(adminUiLocaleSupported == null) { + adminUiLocaleSupported = new ArrayList(); + adminUiLocaleSupported.add(new LocaleSupported("en","English")); + } + + return adminUiLocaleSupported; - public Map getCountriesInMap() { - return countries; } public String getLocaleCode() { @@ -89,11 +94,7 @@ public void setLocaleCode(String localeCode) { public void countryLocaleCodeChanged(ValueChangeEvent e) { String newLocaleValue = e.getNewValue().toString(); - for (Map.Entry entry : countries.entrySet()) { - if (entry.getValue().toString().equals(newLocaleValue)) { - FacesContext.getCurrentInstance().getViewRoot().setLocale((Locale) entry.getValue()); - } - } + FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale( newLocaleValue)); homeAction.init(); } @@ -112,4 +113,12 @@ private void addLocale(GluuCustomPerson gluuCustomPerson, String localeCode) { locale.setValue(localeCode); gluuCustomPerson.getCustomAttributes().add(locale); } + + public List getAdminUiLocaleSupported() { + return adminUiLocaleSupported; + } + + public void setAdminUiLocaleSupported(List adminUiLocaleSupported) { + this.adminUiLocaleSupported = adminUiLocaleSupported; + } } diff --git a/server/src/main/webapp/WEB-INF/incl/layout/topmenu.xhtml b/server/src/main/webapp/WEB-INF/incl/layout/topmenu.xhtml index 2aa7ad54a..8430c2f84 100644 --- a/server/src/main/webapp/WEB-INF/incl/layout/topmenu.xhtml +++ b/server/src/main/webapp/WEB-INF/incl/layout/topmenu.xhtml @@ -27,12 +27,14 @@