[Schmitzm-commits] r1260 - trunk/src/schmitzm/lang

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Nov 11 00:21:06 CET 2010


Author: mojays
Date: 2010-11-11 00:21:06 +0100 (Thu, 11 Nov 2010)
New Revision: 1260

Modified:
   trunk/src/schmitzm/lang/ResourceProviderOperator.java
Log:


Modified: trunk/src/schmitzm/lang/ResourceProviderOperator.java
===================================================================
--- trunk/src/schmitzm/lang/ResourceProviderOperator.java	2010-11-10 22:38:08 UTC (rev 1259)
+++ trunk/src/schmitzm/lang/ResourceProviderOperator.java	2010-11-10 23:21:06 UTC (rev 1260)
@@ -60,8 +60,7 @@
 public class ResourceProviderOperator  {
   private static final String CFG_KEY_RESOURCE_BUNDLES_SEP = ";";
   private static final String CFG_KEY_RESOURCE_BUNDLES = "resource.bundles";
-  private static final String CFG_KEY_RESOURCE_BUNDLES_ROOT_LOCALE = "resource.bundles.root.locale";
-  private static final String CFG_KEY_RESOURCE_BUNDLES_ROOT_FOLDER = "resource.bundles.root.folder";
+  private static final String CFG_KEY_RESOURCE_BUNDLES_ROOT_FOLDER = "resource.bundles.src.root.folder";
   private static final String CFG_KEY_REMOVE_KEYS_INDICATOR_PREFIX = "remove.keys.indicator.prefix";
 
   
@@ -85,15 +84,17 @@
   /**
    * Sets the resource bundles to perform the operations on.
    */
-  public void setResourceBundles(String[] resourceBundleNames, Locale rootLocale) {
+  public void setResourceBundles(String[] resourceBundleNames) {
     if ( resourceBundleNames == null ) {
       setResourceBundles((ResourceProvider[])null);
       return;
     }
     this.resourceBundles = new ResourceProvider[resourceBundleNames.length];
     for (int i=0; i<resourceBundleNames.length; i++) {
+      // Create a new resource provider for the given bundle
+      // Note: the root locale is not necessary for our purpose!
       this.resourceBundles[i] = ResourceProvider.newInstance(
-          resourceBundleNames[i], rootLocale
+          resourceBundleNames[i], null
       );
     }
   }
@@ -141,8 +142,9 @@
   
   /**
    * Removes all keys from the resource bundle files, which are marked with the
-   * special prefix. The mark is only needed in the root resource bundle.
-   * The keys are automatically removed from the sub-language bundles, too. 
+   * special prefix. It is not necessary, that the mark is set in all languages.
+   * The keys are automatically removed from all (sub-)language bundles, either
+   * the mark is set in the root locale or in a sub-language. 
    * @see #setRemoveIndicatorPrefix(String)
    */
   public void processRemoveUnusedKeys() throws Exception {
@@ -151,7 +153,10 @@
   }
   
   /**
-   * 
+   * Removes all marked keys from all locales of the given {@link ResourceProvider}.
+   * The bundle files in the source folder are rewritten. The removed key/value pairs are
+   * archived in {@code .removedKeys} files.
+   * @param rp resource provider to process
    */
   protected void processRemoveUnusedKeys(ResourceProvider rp) throws Exception {
     // First: Determine all keys which must be removed, either with
@@ -176,7 +181,12 @@
   }
   
   /**
-   * 
+   * Removes a set of keys from only the specified locale and rewrites the
+   * bundle file in the source folder. The removed key/value pairs are
+   * archived in a {@code .removedKeys} file.
+   * @param rp resource provider to process
+   * @param locale locale to process
+   * @param set of keys to remove
    */
   protected void processRemoveUnusedKeys(ResourceProvider rp, Locale locale, Set<String> keysToRemove) throws Exception {
     if ( locale == null )
@@ -330,11 +340,7 @@
       String resourceBundlesList = parameters.getProperty(CFG_KEY_RESOURCE_BUNDLES);
       if ( resourceBundlesList != null ) {
         String[] resourceBundles = resourceBundlesList.split(CFG_KEY_RESOURCE_BUNDLES_SEP);
-        String   rootLocale      = parameters.getProperty(CFG_KEY_RESOURCE_BUNDLES_ROOT_LOCALE);
-        rpo.setResourceBundles(
-            resourceBundles,
-            rootLocale != null ? new Locale(rootLocale) : null
-        );
+        rpo.setResourceBundles(resourceBundles);
       }
     } catch (IOException err) {
       LOGGER.error(err.getMessage());
@@ -377,10 +383,6 @@
       if ( rpo.getResourceBundles().length > 0 ) {
         config.put(CFG_KEY_RESOURCE_BUNDLES, LangUtil.stringConcatWithSep(CFG_KEY_RESOURCE_BUNDLES_SEP, rpo.getResourceBundles()));
         ResourceProvider sample = rpo.getResourceBundles()[0];
-        if ( sample.getRootLocale() != null )
-          config.put(CFG_KEY_RESOURCE_BUNDLES_ROOT_LOCALE, sample.getRootLocale().toString());
-        
-        ClassLoader.getSystemResource(sample.getBundlePackage());
       }
         
       config.store(output, "Configuration for ResourceProviderOperator");



More information about the Schmitzm-commits mailing list