]> source.dussan.org Git - archiva.git/commitdiff
Adding language settings to configuration
authorMartin Stockhammer <martin_s@apache.org>
Wed, 25 Oct 2017 20:59:26 +0000 (22:59 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Wed, 25 Oct 2017 20:59:26 +0000 (22:59 +0200)
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo

index 4f6798c10a4021060fa328c49deebf34e3a2bb80..02d2b1362615733ed06478119dfd41a80025bd16 100644 (file)
@@ -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<Locale.LanguageRange> getLanguagePriorities();
 }
 
index 1dd0baeb24000b1f6b0aa9bf4664334a81da4bf6..6983be0ac0e9470036d3c93f7d22e2a5db0e566f 100644 (file)
@@ -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<Locale.LanguageRange> 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<Locale.LanguageRange> getLanguagePriorities( )
+    {
+        return languagePriorities;
+    }
+
     @Override
     public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
     {
index d5d96cda379877c876c58e57c31d31e2808c7cf1..b6acf5366c54c543c6cbfe6beb68b6c6b5122046 100644 (file)
           <name>indexDir</name>
           <version>1.0.0+</version>
           <type>String</type>
+          <defaultValue></defaultValue>
           <description>
             The directory for the indexes of this repository.
           </description>
           <name>description</name>
           <version>1.0.0+</version>
           <type>String</type>
+          <defaultValue></defaultValue>
           <description>
             The description of this repository.
           </description>
           <type>String</type>
           <required>false</required>
         </field>
+        <field>
+          <name>defaultLanguage</name>
+          <type>String</type>
+          <version>3.0.0+</version>
+          <description>The default language used for setting internationalized strings.</description>
+        </field>
+        <field>
+          <name>languageRange</name>
+          <type>String</type>
+          <version>3.0.0+</version>
+          <description>Comma separated list of language patterns. Sorted by priority descending. Used for display of internationalized strings.</description>
+        </field>
       </fields>
     </class>