You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/12/14 12:59:27 UTC
[isis] branch master updated: ISIS-2920: [i18n] replaces LocaleProvider with LanguageProvider
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 77b02d2 ISIS-2920: [i18n] replaces LocaleProvider with LanguageProvider
77b02d2 is described below
commit 77b02d2e7e1390665b2b216a02abcee71dade53c
Author: andi-huber <ah...@apache.org>
AuthorDate: Tue Dec 14 13:59:17 2021 +0100
ISIS-2920: [i18n] replaces LocaleProvider with LanguageProvider
- default LanguageProvider implementation is based on current
InteractionContext's locale, rather than on locale provided by the http
request
---
.../{LocaleProvider.java => LanguageProvider.java} | 21 ++++----
.../applib/services/message/MessageService.java | 6 +--
.../IsisModuleCoreRuntimeServices.java | 2 +
.../core/runtimeservices/i18n/po/PoReader.java | 18 +++----
.../i18n/po/TranslationServicePo.java | 17 +++----
.../i18n/po/TranslationServicePoMenu.java | 6 ++-
.../isis/core/runtimeservices/i18n/po/Util.java | 35 -------------
.../locale/LanguageProviderDefault.java | 38 ++++++++++++++
.../locale/LocaleChoiceProviderDefault.java | 3 +-
.../core/runtimeservices/i18n/po/PoReaderTest.java | 31 ++++++------
.../scalars/ScalarPanelTextFieldAbstract.java | 5 +-
.../isis/viewer/wicket/ui/panels/PanelBase.java | 8 +--
.../viewer/IsisModuleViewerWicketViewer.java | 2 -
.../viewer/services/LocaleProviderWicket.java | 59 ----------------------
14 files changed, 98 insertions(+), 153 deletions(-)
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java b/api/applib/src/main/java/org/apache/isis/applib/services/i18n/LanguageProvider.java
similarity index 69%
rename from api/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java
rename to api/applib/src/main/java/org/apache/isis/applib/services/i18n/LanguageProvider.java
index e3660d9..bae6001 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/i18n/LocaleProvider.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/i18n/LanguageProvider.java
@@ -19,21 +19,24 @@
package org.apache.isis.applib.services.i18n;
import java.util.Locale;
+import java.util.Optional;
/**
- * One of a number of services that work together to provide support for i18n,
- * its responsibility being simply to return the {@link Locale} of the current
- * user.
+ * Provides the preferred language {@link Locale} of the current user.
+ * <p>
+ * One of a number of services that work together to provide support for i18n.
*
- * @since 1.x {@index}
+ * @see TranslationService
+ * @see TranslationsResolver
+ *
+ * @since 2.x {@index}
*/
-public interface LocaleProvider {
+public interface LanguageProvider {
/**
- * Returns the {@link Locale} of the current user.
- *
- * @return the {@link Locale} of the current user.
+ * Optionally returns the preferred language {@link Locale} of the current user,
+ * based on whether there is a context with a current user object.
*/
- Locale getLocale();
+ Optional<Locale> getPreferredLanguage();
}
diff --git a/api/applib/src/main/java/org/apache/isis/applib/services/message/MessageService.java b/api/applib/src/main/java/org/apache/isis/applib/services/message/MessageService.java
index a410064..ea62adb 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/services/message/MessageService.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/services/message/MessageService.java
@@ -55,7 +55,7 @@ public interface MessageService {
*
* <p>
* More precisely, the locale is as provided by the configured
- * {@link org.apache.isis.applib.services.i18n.LocaleProvider} service.
+ * {@link org.apache.isis.applib.services.i18n.LanguageProvider} service.
* This should be the {@link java.util.Locale} of the user making the
* current request.
* </p>
@@ -105,7 +105,7 @@ public interface MessageService {
*
* <p>
* More precisely, the locale is as provided by the configured
- * {@link org.apache.isis.applib.services.i18n.LocaleProvider} service.
+ * {@link org.apache.isis.applib.services.i18n.LanguageProvider} service.
* This should be the {@link java.util.Locale} of the user making the
* current request.
* </p>
@@ -154,7 +154,7 @@ public interface MessageService {
*
* <p>
* More precisely, the locale is as provided by the configured
- * {@link org.apache.isis.applib.services.i18n.LocaleProvider} service.
+ * {@link org.apache.isis.applib.services.i18n.LanguageProvider} service.
* This should be the {@link java.util.Locale} of the user making the
* current request.
* </p>
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/IsisModuleCoreRuntimeServices.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/IsisModuleCoreRuntimeServices.java
index a3f5ae0..adf5298 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/IsisModuleCoreRuntimeServices.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/IsisModuleCoreRuntimeServices.java
@@ -43,6 +43,7 @@ import org.apache.isis.core.runtimeservices.icons.ObjectIconServiceDefault;
import org.apache.isis.core.runtimeservices.interaction.InteractionDtoFactoryDefault;
import org.apache.isis.core.runtimeservices.jaxb.JaxbServiceDefault;
import org.apache.isis.core.runtimeservices.locale.LocaleChoiceProviderDefault;
+import org.apache.isis.core.runtimeservices.locale.LanguageProviderDefault;
import org.apache.isis.core.runtimeservices.memento.ObjectMementoServiceDefault;
import org.apache.isis.core.runtimeservices.menubars.MenuBarsLoaderServiceDefault;
import org.apache.isis.core.runtimeservices.menubars.bootstrap3.MenuBarsServiceBS3;
@@ -94,6 +95,7 @@ import org.apache.isis.core.runtimeservices.xmlsnapshot.XmlSnapshotServiceDefaul
InteractionServiceDefault.class,
JaxbServiceDefault.class,
LocaleChoiceProviderDefault.class,
+ LanguageProviderDefault.class,
ObjectMementoServiceDefault.class,
TranslationServicePo.class,
MemberExecutorServiceDefault.class,
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/PoReader.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/PoReader.java
index 19efe38..9ff5979 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/PoReader.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/PoReader.java
@@ -25,7 +25,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.apache.isis.applib.services.i18n.LocaleProvider;
+import org.apache.isis.applib.services.i18n.LanguageProvider;
import org.apache.isis.applib.services.i18n.Mode;
import org.apache.isis.applib.services.i18n.TranslationContext;
import org.apache.isis.applib.services.i18n.TranslationsResolver;
@@ -62,7 +62,7 @@ class PoReader extends PoAbstract {
*/
private final String basename = "translations";
private final Can<TranslationsResolver> translationsResolver;
- private final Can<LocaleProvider> localeProvider;
+ private final LanguageProvider languageProvider;
private List<String> fallback;
@@ -72,10 +72,7 @@ class PoReader extends PoAbstract {
if(translationsResolver.isEmpty()) {
log.warn("No TranslationsResolver available");
}
- localeProvider = translationServicePo.getLocaleProvider();
- if(localeProvider.isEmpty()) {
- log.warn("No LocaleProvider available");
- }
+ languageProvider = translationServicePo.getLanguageProvider();
}
// -- init, shutdown
@@ -92,7 +89,7 @@ class PoReader extends PoAbstract {
}
@Override
- public String translate(TranslationContext context, final String msgId) {
+ public String translate(final TranslationContext context, final String msgId) {
if(translationsResolver == null) {
// already logged as WARN (in constructor) if null.
return msgId;
@@ -101,7 +98,7 @@ class PoReader extends PoAbstract {
}
@Override
- String translate(TranslationContext context, final String msgId, final String msgIdPlural, final int num) {
+ String translate(final TranslationContext context, final String msgId, final String msgIdPlural, final int num) {
final String msgIdToUse;
final ContextAndMsgId.Type type;
@@ -122,12 +119,11 @@ class PoReader extends PoAbstract {
init();
}
- private String translate(TranslationContext context, final String msgId, final ContextAndMsgId.Type type) {
+ private String translate(final TranslationContext context, final String msgId, final ContextAndMsgId.Type type) {
final Locale targetLocale;
try {
- targetLocale = localeProvider.getFirst()
- .map(LocaleProvider::getLocale)
+ targetLocale = languageProvider.getPreferredLanguage()
.orElse(null);
if(targetLocale == null) {
// eg if request from RO viewer and the (default) LocaleProviderWicket is being used.
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
index 5070ebf..6a84f4e 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
@@ -30,7 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.apache.isis.applib.annotation.PriorityPrecedence;
-import org.apache.isis.applib.services.i18n.LocaleProvider;
+import org.apache.isis.applib.services.i18n.LanguageProvider;
import org.apache.isis.applib.services.i18n.Mode;
import org.apache.isis.applib.services.i18n.TranslationContext;
import org.apache.isis.applib.services.i18n.TranslationService;
@@ -41,6 +41,7 @@ import org.apache.isis.commons.internal.base._Lazy;
import org.apache.isis.core.config.IsisConfiguration;
import org.apache.isis.core.config.environment.IsisSystemEnvironment;
+import lombok.Getter;
import lombok.val;
@Service
@@ -73,7 +74,7 @@ public class TranslationServicePo implements TranslationService {
return;
}
- if(getLocaleProvider() == null || getTranslationsResolver() == null) {
+ if(getTranslationsResolver() == null) {
// remain in write mode
return;
}
@@ -173,6 +174,9 @@ public class TranslationServicePo implements TranslationService {
@Inject private ServiceRegistry serviceRegistry;
@Inject private IsisConfiguration configuration;
+ @Getter
+ @Inject private LanguageProvider languageProvider;
+
private _Lazy<Can<TranslationsResolver>> translationsResolvers = _Lazy.threadSafe(()->
serviceRegistry.select(TranslationsResolver.class) );
@@ -180,13 +184,4 @@ public class TranslationServicePo implements TranslationService {
return translationsResolvers.get();
}
- private _Lazy<Can<LocaleProvider>> localeProviders = _Lazy.threadSafe(()->
- serviceRegistry.select(LocaleProvider.class) );
-
- Can<LocaleProvider> getLocaleProvider() {
- return localeProviders.get();
- }
-
-
-
}
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
index 77ea057..69c3ed5 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
@@ -32,6 +32,7 @@ import org.apache.isis.applib.annotation.PriorityPrecedence;
import org.apache.isis.applib.annotation.RestrictTo;
import org.apache.isis.applib.annotation.SemanticsOf;
import org.apache.isis.applib.value.Clob;
+import org.apache.isis.commons.internal.base._Strings;
import lombok.RequiredArgsConstructor;
@@ -67,8 +68,9 @@ public class TranslationServicePoMenu {
final String potFileName) {
return translationService.toPot()
- .map(chars->new Clob(Util.withSuffix(potFileName, "pot"), "text/plain", chars))
- .orElse(null);
+ .map(chars->new Clob(
+ _Strings.asFileNameWithExtension(potFileName, "pot"), "text/plain", chars))
+ .orElse(null);
}
@MemberSupport public String default0DownloadTranslations() {
return "translations.pot";
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/Util.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/Util.java
deleted file mode 100644
index 364ec88..0000000
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/Util.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.core.runtimeservices.i18n.po;
-
-class Util {
-
- private Util(){}
-
- static String withSuffix(String fileName, String suffix) {
- if(!suffix.startsWith(".")) {
- suffix = "." + suffix;
- }
- if(!fileName.endsWith(suffix)) {
- fileName += suffix;
- }
- return fileName;
- }
-
-}
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LanguageProviderDefault.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LanguageProviderDefault.java
new file mode 100644
index 0000000..eaa007a
--- /dev/null
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LanguageProviderDefault.java
@@ -0,0 +1,38 @@
+package org.apache.isis.core.runtimeservices.locale;
+
+import java.util.Locale;
+import java.util.Optional;
+
+import javax.annotation.Priority;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.annotation.PriorityPrecedence;
+import org.apache.isis.applib.locale.UserLocale;
+import org.apache.isis.applib.services.i18n.LanguageProvider;
+import org.apache.isis.applib.services.iactn.InteractionProvider;
+import org.apache.isis.applib.services.iactnlayer.InteractionContext;
+
+import lombok.RequiredArgsConstructor;
+
+@Service
+@Named("isis.runtimeservices.LanguageProviderDefault")
+@Priority(PriorityPrecedence.MIDPOINT)
+@Qualifier("Default")
+@RequiredArgsConstructor(onConstructor_ = {@Inject})
+public class LanguageProviderDefault
+implements LanguageProvider {
+
+ private final InteractionProvider interactionProvider;
+
+ @Override
+ public Optional<Locale> getPreferredLanguage() {
+ return interactionProvider.currentInteractionContext()
+ .map(InteractionContext::getLocale)
+ .map(UserLocale::getLanguageLocale);
+ }
+
+}
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LocaleChoiceProviderDefault.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LocaleChoiceProviderDefault.java
index 02cc640..94f9caf 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LocaleChoiceProviderDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/locale/LocaleChoiceProviderDefault.java
@@ -42,7 +42,8 @@ import lombok.RequiredArgsConstructor;
@Priority(PriorityPrecedence.MIDPOINT)
@Qualifier("Default")
@RequiredArgsConstructor(onConstructor_ = {@Inject})
-public class LocaleChoiceProviderDefault implements LocaleChoiceProvider {
+public class LocaleChoiceProviderDefault
+implements LocaleChoiceProvider {
@Override
public List<Locale> getAvailableLocales() {
diff --git a/core/runtimeservices/src/test/java/org/apache/isis/core/runtimeservices/i18n/po/PoReaderTest.java b/core/runtimeservices/src/test/java/org/apache/isis/core/runtimeservices/i18n/po/PoReaderTest.java
index 6b6b6ca..2283458 100644
--- a/core/runtimeservices/src/test/java/org/apache/isis/core/runtimeservices/i18n/po/PoReaderTest.java
+++ b/core/runtimeservices/src/test/java/org/apache/isis/core/runtimeservices/i18n/po/PoReaderTest.java
@@ -18,12 +18,9 @@
*/
package org.apache.isis.core.runtimeservices.i18n.po;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
import java.util.List;
import java.util.Locale;
+import java.util.Optional;
import org.jmock.Expectations;
import org.jmock.auto.Mock;
@@ -32,13 +29,17 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.apache.isis.applib.services.i18n.LocaleProvider;
+import org.apache.isis.applib.services.i18n.LanguageProvider;
import org.apache.isis.applib.services.i18n.TranslationContext;
import org.apache.isis.applib.services.i18n.TranslationsResolver;
import org.apache.isis.commons.collections.Can;
import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.core.internaltestsupport.jmocking.JUnitRuleMockery2;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class PoReaderTest {
@Rule public JUnitRuleMockery2 context = JUnitRuleMockery2
@@ -46,7 +47,7 @@ public class PoReaderTest {
@Mock TranslationServicePo mockTranslationServicePo;
@Mock TranslationsResolver mockTranslationsResolver;
- @Mock LocaleProvider mockLocaleProvider;
+ @Mock LanguageProvider mockLanguageProvider;
PoReader poReader;
@@ -54,25 +55,25 @@ public class PoReaderTest {
public void setUp() throws Exception {
context.checking(new Expectations() {{
- allowing(mockTranslationServicePo).getLocaleProvider();
- will(returnValue(Can.ofSingleton(mockLocaleProvider)));
+ allowing(mockTranslationServicePo).getLanguageProvider();
+ will(returnValue(mockLanguageProvider));
allowing(mockTranslationServicePo).getTranslationsResolver();
will(returnValue(Can.ofSingleton(mockTranslationsResolver)));
- allowing(mockLocaleProvider).getLocale();
- will(returnValue(Locale.UK));
+ allowing(mockLanguageProvider).getPreferredLanguage();
+ will(returnValue(Optional.of(Locale.UK)));
}});
}
@Test
public void properMockeryOfNonPublicMethods() {
- //[ahuber] with update of byte-buddy 1.8.0 -> 1.9.2, Apache Isis runs on JDK 11+,
- // we explicitly test proper mockery of non-public methods here ...
- Assert.assertNotNull(mockTranslationServicePo.getLocaleProvider());
+ //[ahuber] with update of byte-buddy 1.8.0 -> 1.9.2, Apache Isis runs on JDK 11+,
+ // we explicitly test proper mockery of non-public methods here ...
+ Assert.assertNotNull(mockTranslationServicePo.getLanguageProvider());
Assert.assertNotNull(mockTranslationServicePo.getTranslationsResolver());
- Assert.assertNotNull(mockLocaleProvider.getLocale());
+ Assert.assertNotNull(mockLanguageProvider.getPreferredLanguage());
}
public static class Translate extends PoReaderTest {
@@ -236,7 +237,7 @@ public class PoReaderTest {
return _Lists.newArrayList();
}
};
-
+
TranslationContext context = TranslationContext.ofName("someContext");
// when
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
index c612a00..8590aef 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
@@ -19,6 +19,7 @@
package org.apache.isis.viewer.wicket.ui.components.scalars;
import java.io.Serializable;
+import java.util.Locale;
import java.util.Optional;
import org.apache.wicket.AttributeModifier;
@@ -311,7 +312,9 @@ implements TextFieldValueModel.ScalarModelProvider {
val adapter = scalarModel.getObject();
val value = ManagedObjects.UnwrapUtil.single(adapter);
final String str = value != null
- ? converter.convertToString(_Casts.uncheckedCast(value), getLocaleProvider().getLocale())
+ ? converter.convertToString(
+ _Casts.uncheckedCast(value),
+ getLanguageProvider().getPreferredLanguage().orElseGet(Locale::getDefault))
: null;
return str;
}
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelBase.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelBase.java
index d65d30d..71df83a 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelBase.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelBase.java
@@ -25,7 +25,7 @@ import org.springframework.lang.Nullable;
import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.IModel;
-import org.apache.isis.applib.services.i18n.LocaleProvider;
+import org.apache.isis.applib.services.i18n.LanguageProvider;
import org.apache.isis.applib.services.i18n.TranslationService;
import org.apache.isis.applib.services.iactnlayer.InteractionService;
import org.apache.isis.applib.services.userreg.EmailNotificationService;
@@ -69,7 +69,7 @@ implements HasCommonContext {
private transient IsisAppCommonContext commonContext;
private transient InteractionService interactionService;
private transient TranslationService translationService;
- private transient LocaleProvider localeProvider;
+ private transient LanguageProvider localeProvider;
private transient TreeThemeProvider treeThemeProvider;
private transient EmailNotificationService emailNotificationService;
private transient EmailVerificationUrlService emailVerificationUrlService;
@@ -121,8 +121,8 @@ implements HasCommonContext {
return translationService = computeIfAbsent(TranslationService.class, translationService);
}
- public LocaleProvider getLocaleProvider() {
- return localeProvider = computeIfAbsent(LocaleProvider.class, localeProvider);
+ public LanguageProvider getLanguageProvider() {
+ return localeProvider = computeIfAbsent(LanguageProvider.class, localeProvider);
}
protected TreeThemeProvider getTreeThemeProvider() {
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisModuleViewerWicketViewer.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisModuleViewerWicketViewer.java
index 79f4521..b917bf6 100644
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisModuleViewerWicketViewer.java
+++ b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisModuleViewerWicketViewer.java
@@ -32,7 +32,6 @@ import org.apache.isis.viewer.wicket.viewer.services.BookmarkUiServiceWicket;
import org.apache.isis.viewer.wicket.viewer.services.DeepLinkServiceWicket;
import org.apache.isis.viewer.wicket.viewer.services.HintStoreUsingWicketSession;
import org.apache.isis.viewer.wicket.viewer.services.ImageResourceCacheClassPath;
-import org.apache.isis.viewer.wicket.viewer.services.LocaleProviderWicket;
import org.apache.isis.viewer.wicket.viewer.services.TranslationsResolverWicket;
import org.apache.isis.viewer.wicket.viewer.services.WicketViewerSettingsDefault;
import org.apache.isis.viewer.wicket.viewer.webmodule.WebModuleWicket;
@@ -51,7 +50,6 @@ import org.apache.isis.viewer.wicket.viewer.webmodule.WebModuleWicket;
ComponentFactoryRegistryDefault.class,
DeepLinkServiceWicket.class,
ImageResourceCacheClassPath.class,
- LocaleProviderWicket.class,
HintStoreUsingWicketSession.class,
PageClassListDefault.class,
PageClassRegistryDefault.class,
diff --git a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/LocaleProviderWicket.java b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/LocaleProviderWicket.java
deleted file mode 100644
index 0533d81..0000000
--- a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/services/LocaleProviderWicket.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.wicket.viewer.services;
-
-import java.util.Locale;
-
-import javax.inject.Named;
-
-import org.apache.isis.applib.annotation.PriorityPrecedence;
-import org.apache.wicket.Application;
-import org.apache.wicket.Session;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Service;
-
-import org.apache.isis.applib.services.i18n.LocaleProvider;
-
-
-/**
- * An implementation that provides the locale of the current session.
- */
-@Service
-@Named("isis.viewer.wicket.LocaleProviderWicket")
-@javax.annotation.Priority(PriorityPrecedence.MIDPOINT)
-@Qualifier("Wicket")
-public class LocaleProviderWicket implements LocaleProvider {
-
- @Override
- public Locale getLocale() {
- // Request Cycle can be null, e.g. during the start of an application
- RequestCycle requestCycle = RequestCycle.get();
-
- if (!Application.exists() || requestCycle == null) {
- // eg if request from RO viewer
- return null;
- }
- return RequestCycle.get().getRequest().getLocale();
- }
-
- protected Session getSession() {
- return Session.get();
- }
-}