diff --git a/forms/common-freemarker/src/main/java/org/keycloak/freemarker/ExtendingThemeManager.java b/forms/common-freemarker/src/main/java/org/keycloak/freemarker/ExtendingThemeManager.java index 0e98f1147f..020d349150 100644 --- a/forms/common-freemarker/src/main/java/org/keycloak/freemarker/ExtendingThemeManager.java +++ b/forms/common-freemarker/src/main/java/org/keycloak/freemarker/ExtendingThemeManager.java @@ -224,10 +224,15 @@ public class ExtendingThemeManager implements ThemeProvider { @Override public Properties getMessages(Locale locale) throws IOException { + return getMessages("messages", locale); + } + + @Override + public Properties getMessages(String baseBundlename, Locale locale) throws IOException { Properties messages = new Properties(); ListIterator itr = themes.listIterator(themes.size()); while (itr.hasPrevious()) { - Properties m = itr.previous().getMessages(locale); + Properties m = itr.previous().getMessages(baseBundlename, locale); if (m != null) { messages.putAll(m); } diff --git a/forms/common-freemarker/src/main/java/org/keycloak/freemarker/Theme.java b/forms/common-freemarker/src/main/java/org/keycloak/freemarker/Theme.java index 6a12a49f00..43107ce723 100644 --- a/forms/common-freemarker/src/main/java/org/keycloak/freemarker/Theme.java +++ b/forms/common-freemarker/src/main/java/org/keycloak/freemarker/Theme.java @@ -29,8 +29,27 @@ public interface Theme { public InputStream getResourceAsStream(String path) throws IOException; + /** + * Same as getMessages(baseBundlename, locale), but uses a default baseBundlename + * such as "messages". + * + * @param locale The locale of the desired message bundle. + * @return The localized messages from the bundle. + * @throws IOException If bundle can not be read. + */ public Properties getMessages(Locale locale) throws IOException; + /** + * Retrieve localized messages from a message bundle. + * + * @param baseBundlename The base name of the bundle, such as "messages" in + * messages_en.properties. + * @param locale The locale of the desired message bundle. + * @return The localized messages from the bundle. + * @throws IOException If bundle can not be read. + */ + public Properties getMessages(String baseBundlename, Locale locale) throws IOException; + public Properties getProperties() throws IOException; } diff --git a/forms/common-themes/src/main/java/org/keycloak/theme/ClassLoaderTheme.java b/forms/common-themes/src/main/java/org/keycloak/theme/ClassLoaderTheme.java index 3e92be880b..68ac7caca1 100755 --- a/forms/common-themes/src/main/java/org/keycloak/theme/ClassLoaderTheme.java +++ b/forms/common-themes/src/main/java/org/keycloak/theme/ClassLoaderTheme.java @@ -100,12 +100,17 @@ public class ClassLoaderTheme implements Theme { @Override public Properties getMessages(Locale locale) throws IOException { + return getMessages("messages", locale); + } + + @Override + public Properties getMessages(String baseBundlename, Locale locale) throws IOException { if(locale == null){ return null; } Properties m = new Properties(); - URL url = classLoader.getResource(this.messageRoot + "messages_" + locale.toString() + ".properties"); + URL url = classLoader.getResource(this.messageRoot + baseBundlename + "_" + locale.toString() + ".properties"); if (url != null) { m.load(url.openStream()); } diff --git a/forms/common-themes/src/main/java/org/keycloak/theme/FolderTheme.java b/forms/common-themes/src/main/java/org/keycloak/theme/FolderTheme.java index d1593fe99d..77a65a8e59 100644 --- a/forms/common-themes/src/main/java/org/keycloak/theme/FolderTheme.java +++ b/forms/common-themes/src/main/java/org/keycloak/theme/FolderTheme.java @@ -93,13 +93,18 @@ public class FolderTheme implements Theme { @Override public Properties getMessages(Locale locale) throws IOException { + return getMessages("messages", locale); + } + + @Override + public Properties getMessages(String baseBundlename, Locale locale) throws IOException { if(locale == null){ return null; } Properties m = new Properties(); - File file = new File(themeDir, "messages" + File.separator + "messages_" + locale.toString() + ".properties"); + File file = new File(themeDir, "messages" + File.separator + baseBundlename + "_" + locale.toString() + ".properties"); if (file.isFile()) { m.load(new FileInputStream(file)); }