Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
eschleb committed Oct 4, 2024
2 parents b8a4fe7 + 05142a4 commit 5db35af
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 86 deletions.
2 changes: 1 addition & 1 deletion json2properties-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-dictionary-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>json2properties-generator</artifactId>
Expand Down
6 changes: 1 addition & 5 deletions magnolia-dictionary/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-dictionary-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</parent>

<artifactId>magnolia-dictionary</artifactId>
Expand All @@ -24,10 +24,6 @@
<groupId>info.magnolia.site</groupId>
<artifactId>magnolia-site</artifactId>
</dependency>
<dependency>
<groupId>info.magnolia.site</groupId>
<artifactId>magnolia-site-jcr</artifactId>
</dependency>
<dependency>
<groupId>info.magnolia.publishing</groupId>
<artifactId>magnolia-publishing-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
package com.namics.oss.magnolia.dictionary.i18nsystem;

import com.namics.oss.magnolia.dictionary.util.DictionaryUtils;
import info.magnolia.cms.i18n.DefaultMessagesManager;
import info.magnolia.cms.i18n.I18nContentSupport;
import info.magnolia.context.MgnlContext;
import info.magnolia.i18nsystem.DefaultMessageBundlesLoader;
import info.magnolia.i18nsystem.I18nText;
import info.magnolia.i18nsystem.LocaleProvider;
import info.magnolia.i18nsystem.TranslationService;
import info.magnolia.i18nsystem.TranslationServiceImpl;
import info.magnolia.i18nsystem.I18nText;
import info.magnolia.i18nsystem.module.I18nModule;
import info.magnolia.module.site.ExtendedAggregationState;
import info.magnolia.module.site.Site;
import info.magnolia.module.site.SiteManager;
import info.magnolia.objectfactory.ComponentProvider;
import info.magnolia.objectfactory.Components;
import info.magnolia.resourceloader.ResourceOrigin;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;
import java.lang.invoke.MethodHandles;
import java.util.*;

import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.namics.oss.magnolia.dictionary.util.DictionaryUtils;

/**
* @author mrauch, Namics AG
Expand Down Expand Up @@ -131,32 +136,7 @@ private Locale getSiteFallbackLocale() {
}

private Optional<I18nContentSupport> getSiteI18n() {
try {
if (isSitePresent()) {
Site currentSite = Components.getComponent(SiteManager.class).getCurrentSite();
return Optional.of(currentSite.getI18n());
}
} catch (RuntimeException e) {
LOG.debug("Error while getting I18nContentSupport: '{}'", e.getMessage());
LOG.trace("Error while getting I18nContentSupport", e);
}
return Optional.empty();
}

private boolean isSitePresent() {
// If a translation is requested before the site is
// set in the aggregationState, the SiteManager will
// log a warning (see info.magnolia.module.site.DefaultSiteManager.getCurrentSite).
// This happens, if the translation is requested in a
// filter which is located before the info.magnolia.multisite.filters.MultiSiteFilter.
// This is the case in Magnolia 5.7 info.magnolia.personalization.visitor.VisitorDetectorFilter.
if (MgnlContext.isWebContext()) {
return Optional.ofNullable(MgnlContext.getAggregationState())
.filter(state -> state instanceof ExtendedAggregationState)
.map(state -> ((ExtendedAggregationState) state).getSite())
.isPresent();
}
return Boolean.FALSE;
return Optional.of(Components.getComponent(SiteManager.class).getCurrentSite()).map(Site::getI18n);
}

private Locale getFallbackLocale() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@
</component>
</components>

<dependencies>
<dependency>
<name>core</name>
<version>*</version>
</dependency>
<dependency>
<name>site</name>
<version>*</version>
<optional>true</optional>
</dependency>
<dependency>
<name>multisite</name>
<version>*</version>
<optional>true</optional>
</dependency>
</dependencies>

<repositories>
<repository>
<name>magnolia</name>
Expand All @@ -58,5 +41,4 @@
<nodeTypeFile>/mgnl-nodetypes/magnolia-dictionary-nodetypes.xml</nodeTypeFile>
</repository>
</repositories>

</module>

This file was deleted.

6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-dictionary-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>pom</packaging>

<name>${project.artifactId}</name>
Expand Down Expand Up @@ -41,8 +41,8 @@
<jsr305.nullable.version>3.0.2</jsr305.nullable.version>

<!--Test dependency versions-->
<junit.version>5.11.0</junit.version>
<mockito.version>5.13.0</mockito.version>
<junit.version>5.11.1</junit.version>
<mockito.version>5.14.1</mockito.version>

<!-- Maven Plugins -->
<mvn.compiler.plugin.version>3.11.0</mvn.compiler.plugin.version>
Expand Down

0 comments on commit 5db35af

Please sign in to comment.