From 89f7aa34163023e5d2c2f388baabc3683268418f Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Wed, 25 Oct 2017 22:59:26 +0200 Subject: [PATCH] Adding language settings to configuration --- .../configuration/ArchivaConfiguration.java | 7 +++++ .../DefaultArchivaConfiguration.java | 26 +++++++++++++++++-- .../src/main/mdo/configuration.mdo | 14 ++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java index 4f6798c10..02d2b1362 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java @@ -22,6 +22,9 @@ package org.apache.archiva.configuration; import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.redback.components.registry.RegistryListener; +import java.util.List; +import java.util.Locale; + /** * Configuration holder for the model read from the registry. */ @@ -85,5 +88,9 @@ public interface ArchivaConfiguration * @since 1.4-M1 */ void reload(); + + public Locale getDefaultLocale(); + + public List getLanguagePriorities(); } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index 1dd0baeb2..6983be0ac 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -63,6 +63,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -169,6 +170,15 @@ public class DefaultArchivaConfiguration // Section used for default only configuration private static final String KEY_DEFAULT_ONLY = "org.apache.archiva_default"; + private Locale defaultLocale = Locale.getDefault(); + + private List languagePriorities = new ArrayList<>( ); + + @PostConstruct + private void init() { + languagePriorities = Locale.LanguageRange.parse( "en,fr,de" ); + } + @Override public Configuration getConfiguration() { @@ -341,8 +351,8 @@ public class DefaultArchivaConfiguration } } - - + this.defaultLocale = Locale.forLanguageTag( config.getArchivaRuntimeConfiguration().getDefaultLanguage() ); + this.languagePriorities = Locale.LanguageRange.parse(config.getArchivaRuntimeConfiguration().getLanguageRange()); return config; } @@ -869,6 +879,18 @@ public class DefaultArchivaConfiguration this.initialize(); } + @Override + public Locale getDefaultLocale( ) + { + return defaultLocale; + } + + @Override + public List getLanguagePriorities( ) + { + return languagePriorities; + } + @Override public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) { diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index d5d96cda3..b6acf5366 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -465,6 +465,7 @@ indexDir 1.0.0+ String + The directory for the indexes of this repository. @@ -473,6 +474,7 @@ description 1.0.0+ String + The description of this repository. @@ -1544,6 +1546,18 @@ String false + + defaultLanguage + String + 3.0.0+ + The default language used for setting internationalized strings. + + + languageRange + String + 3.0.0+ + Comma separated list of language patterns. Sorted by priority descending. Used for display of internationalized strings. + -- 2.39.5