From 1439f82205df46126de571bc0e8c5fca16fc0402 Mon Sep 17 00:00:00 2001 From: eschleb Date: Thu, 21 Nov 2024 15:17:49 +0100 Subject: [PATCH] Lazy load dictionary message bundles (sites not registered upon module startup) --- .../oss/magnolia/dictionary/DictionaryModule.java | 1 - .../i18nsystem/DictionaryMessageBundlesLoader.java | 5 ++++- .../META-INF/magnolia/magnolia-dictionary.xml | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/DictionaryModule.java b/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/DictionaryModule.java index 812a549..47f2606 100644 --- a/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/DictionaryModule.java +++ b/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/DictionaryModule.java @@ -55,7 +55,6 @@ public void start(ModuleLifecycleContext moduleLifecycleContext) { LOG.info("Start Dictionary module: Load labels to dictionary"); messagesInstaller.loadLabelsToDictionary(); } - dictionaryMessageBundlesLoader.reload(); } @Override diff --git a/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/i18nsystem/DictionaryMessageBundlesLoader.java b/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/i18nsystem/DictionaryMessageBundlesLoader.java index 5c9e86a..5bb8822 100644 --- a/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/i18nsystem/DictionaryMessageBundlesLoader.java +++ b/magnolia-dictionary/src/main/java/com/namics/oss/magnolia/dictionary/i18nsystem/DictionaryMessageBundlesLoader.java @@ -37,7 +37,7 @@ public class DictionaryMessageBundlesLoader implements EventListener { private static final Logger LOG = LoggerFactory.getLogger(DictionaryMessageBundlesLoader.class); private final Provider systemContextProvider; - private Map messages = Collections.emptyMap(); + private Map messages; @Inject public DictionaryMessageBundlesLoader(final Provider systemContextProvider) { @@ -84,6 +84,9 @@ private Stream> streamMessages(final Locale locale, fi } public Map getMessages() { + if(messages == null) { + reload(); + } return messages; } diff --git a/magnolia-dictionary/src/main/resources/META-INF/magnolia/magnolia-dictionary.xml b/magnolia-dictionary/src/main/resources/META-INF/magnolia/magnolia-dictionary.xml index f118ac9..a6e8af6 100644 --- a/magnolia-dictionary/src/main/resources/META-INF/magnolia/magnolia-dictionary.xml +++ b/magnolia-dictionary/src/main/resources/META-INF/magnolia/magnolia-dictionary.xml @@ -43,6 +43,16 @@ i18n */* + + site + * + true + + + multisite + * + true +