From 1d2d6591b29147c50cdd1b96695f23ab7f1b6279 Mon Sep 17 00:00:00 2001 From: rmartinc Date: Fri, 12 Jul 2019 15:28:28 +0200 Subject: [PATCH] KEYCLOAK-10826: Provide the locale name in the LocaleBean to be used in themes --- .../org/keycloak/theme/beans/LocaleBean.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/services/src/main/java/org/keycloak/theme/beans/LocaleBean.java b/services/src/main/java/org/keycloak/theme/beans/LocaleBean.java index ce3910f1db..ad4062d2e1 100755 --- a/services/src/main/java/org/keycloak/theme/beans/LocaleBean.java +++ b/services/src/main/java/org/keycloak/theme/beans/LocaleBean.java @@ -30,16 +30,18 @@ import java.util.Properties; public class LocaleBean { private String current; + private String currentLanguageTag; private List supported; public LocaleBean(RealmModel realm, java.util.Locale current, UriBuilder uriBuilder, Properties messages) { - this.current = messages.getProperty("locale_" + current.toLanguageTag(), current.toLanguageTag()); + this.currentLanguageTag = current.toLanguageTag(); + this.current = messages.getProperty("locale_" + this.currentLanguageTag, this.currentLanguageTag); supported = new LinkedList<>(); for (String l : realm.getSupportedLocales()) { String label = messages.getProperty("locale_" + l, l); String url = uriBuilder.replaceQueryParam("kc_locale", l).build().toString(); - supported.add(new Locale(label, url)); + supported.add(new Locale(l, label, url)); } } @@ -47,20 +49,30 @@ public class LocaleBean { return current; } + public String getCurrentLanguageTag() { + return currentLanguageTag; + } + public List getSupported() { return supported; } public static class Locale { + private String languageTag; private String label; private String url; - public Locale(String label, String url) { + public Locale(String languageTag, String label, String url) { + this.languageTag = languageTag; this.label = label; this.url = url; } + public String getLanguageTag() { + return languageTag; + } + public String getUrl() { return url; }