[cal10n-dev] branch, master, updated. v0.5.1-4-g979578b

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Wed Sep 2 19:44:26 CEST 2009


The branch, master has been updated
       via  979578bc208c3ab05206285354845e318fa1bff9 (commit)
      from  809f61077f605b6b8a2e9b3e3cb7eeca37306b0b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cal10n.git;a=commit;h=979578bc208c3ab05206285354845e318fa1bff9
http://github.com/ceki/cal10n/commit/979578bc208c3ab05206285354845e318fa1bff9

commit 979578bc208c3ab05206285354845e318fa1bff9
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Sep 2 19:41:54 2009 +0200

    - defined a simplified bundle lookup procedure

diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/MessageConveyor.java b/cal10n-api/src/main/java/ch/qos/cal10n/MessageConveyor.java
index 6f682ae..17069e2 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/MessageConveyor.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/MessageConveyor.java
@@ -27,6 +27,7 @@ import java.util.Locale;
 import java.util.ResourceBundle;
 
 import ch.qos.cal10n.util.AnnotationExtractor;
+import ch.qos.cal10n.util.PropertyResourceBundleFinder;
 
 /**
  * The default implementation for {@link IMessageConveyor} based on resource
@@ -55,9 +56,9 @@ public class MessageConveyor implements IMessageConveyor {
    * corresponding internationalized.
    * 
    * <p>
-   * The name of the resource bundle is defined via the
-   * {@link BaseName} annotation whereas the locale is specified in
-   * this MessageConveyor instance's constructor.
+   * The name of the resource bundle is defined via the {@link BaseName}
+   * annotation whereas the locale is specified in this MessageConveyor
+   * instance's constructor.
    * 
    * @param key
    *          an enum instance used as message key
@@ -66,14 +67,16 @@ public class MessageConveyor implements IMessageConveyor {
   public <E extends Enum<?>> String getMessage(E key, Object... args) {
     String keyAsStr = key.toString();
 
-    String resouceBundleName = AnnotationExtractor.getBaseName(key
-        .getDeclaringClass());
-    if (resouceBundleName == null) {
+    String baseName = AnnotationExtractor.getBaseName(key.getDeclaringClass());
+    if (baseName == null) {
       throw new IllegalArgumentException(
-          "Missing @BaseName annotation in enum type [" + key.getClass().getName()
-              + "]. See also " + Cal10nConstants.MISSING_BN_ANNOTATION_URL);
+          "Missing @BaseName annotation in enum type ["
+              + key.getClass().getName() + "]. See also "
+              + Cal10nConstants.MISSING_BN_ANNOTATION_URL);
     }
-    ResourceBundle rb = ResourceBundle.getBundle(resouceBundleName, locale);
+
+    ResourceBundle rb = PropertyResourceBundleFinder.getBundle(this.getClass()
+        .getClassLoader(), baseName, locale);
 
     String value = rb.getString(keyAsStr);
     if (value == null) {
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java b/cal10n-api/src/main/java/ch/qos/cal10n/util/CAL10NPropertyResourceBundle.java
similarity index 72%
copy from cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java
copy to cal10n-api/src/main/java/ch/qos/cal10n/util/CAL10NPropertyResourceBundle.java
index b2da013..b708cee 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/util/CAL10NPropertyResourceBundle.java
@@ -19,26 +19,21 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package ch.qos.cal10n.sample;
+package ch.qos.cal10n.util;
 
-import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
 
-import java.util.Locale;
+public class CAL10NPropertyResourceBundle extends PropertyResourceBundle {
 
-import org.junit.Test;
-
-import ch.qos.cal10n.MessageConveyor;
-
-
-public class WithDefaultTest {
-
-  @Test
-  public void smoke() {
-    MessageConveyor mc = new MessageConveyor(Locale.UK);
-    String val;
-
-    val = mc.getMessage(Furnitures.TABLE);
-    assertEquals("the table", val);
+  public CAL10NPropertyResourceBundle(InputStream is) throws IOException {
+    super(is);
+  }
 
+  public void setParent(ResourceBundle parent) {
+    super.setParent(parent);
   }
+
 }
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/util/PropertyResourceBundleFinder.java b/cal10n-api/src/main/java/ch/qos/cal10n/util/PropertyResourceBundleFinder.java
new file mode 100644
index 0000000..7ecdf89
--- /dev/null
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/util/PropertyResourceBundleFinder.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cal10n.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class PropertyResourceBundleFinder {
+
+  public static ResourceBundle getBundle(ClassLoader classLoader, String baseName,
+      Locale locale)  {
+
+    // same as the JDK convention
+    //
+    // It generates a path name from the candidate bundle name by replacing all "." 
+    // characters with "/" and appending the string ".properties".
+    /// see also   http: // tinyurl.com/ldgej8
+    baseName = baseName.replace('.', '/');
+
+    String languageAndCountryCandidate = computeLanguageAndCountryCandidate(
+        baseName, locale);
+    String languageOnlyCandidate = computeLanguageOnlyCandidate(baseName,
+        locale);
+
+    CAL10NPropertyResourceBundle cprbLanguageOnly = makePropertyResourceBundle(
+        classLoader, languageOnlyCandidate);
+    CAL10NPropertyResourceBundle cprbLanguageAndCountry = null;
+
+    if (languageAndCountryCandidate != null) {
+      cprbLanguageAndCountry = makePropertyResourceBundle(classLoader,
+          languageAndCountryCandidate);
+    }
+
+    if (cprbLanguageAndCountry != null) {
+      cprbLanguageAndCountry.setParent(cprbLanguageOnly);
+      return cprbLanguageAndCountry;
+    }
+    return cprbLanguageOnly;
+  }
+
+  private static CAL10NPropertyResourceBundle makePropertyResourceBundle(
+      ClassLoader classLoader, String resourceCandiate) {
+
+    CAL10NPropertyResourceBundle prb = null;
+
+    URL url = classLoader.getResource(resourceCandiate);
+    if (url != null) {
+      try {
+        InputStream in = openConnectionForUrl(url);
+        prb = new CAL10NPropertyResourceBundle(in);
+        in.close();
+      } catch (IOException e) {
+      }
+    }
+    return prb;
+  }
+
+  private static String computeLanguageAndCountryCandidate(String baseName,
+      Locale locale) {
+    String language = locale.getLanguage();
+    String country = locale.getCountry();
+    if (country != null && country.length() > 0) {
+      return baseName + "_" + language + "_" + country + ".properties";
+    } else {
+      return null;
+    }
+  }
+
+  private static String computeLanguageOnlyCandidate(String baseName, Locale locale) {
+    String language = locale.getLanguage();
+    return baseName + "_" + language + ".properties";
+  }
+
+  private static InputStream openConnectionForUrl(URL url) throws IOException {
+    URLConnection urlConnection = url.openConnection();
+    urlConnection.setDefaultUseCaches(false);
+    InputStream in = urlConnection.getInputStream();
+    return in;
+  }
+}
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java b/cal10n-api/src/main/java/ch/qos/cal10n/util/StringToLocale.java
similarity index 74%
rename from cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java
rename to cal10n-api/src/main/java/ch/qos/cal10n/util/StringToLocale.java
index b2da013..1e70cf8 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/WithDefaultTest.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/util/StringToLocale.java
@@ -19,26 +19,21 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-package ch.qos.cal10n.sample;
-
-import static org.junit.Assert.assertEquals;
+package ch.qos.cal10n.util;
 
 import java.util.Locale;
 
-import org.junit.Test;
-
-import ch.qos.cal10n.MessageConveyor;
-
-
-public class WithDefaultTest {
-
-  @Test
-  public void smoke() {
-    MessageConveyor mc = new MessageConveyor(Locale.UK);
-    String val;
+public class StringToLocale {
 
-    val = mc.getMessage(Furnitures.TABLE);
-    assertEquals("the table", val);
+  public static Locale toLocale(String localeName) {
+    if (localeName == null) {
 
+    }
+    if (localeName.contains("_")) {
+      String[] array = localeName.split("_");
+      return new Locale(array[0], array[1]);
+    } else {
+      return new Locale(localeName);
+    }
   }
 }
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/Cal10nError.java b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/Cal10nError.java
index 6ea790b..be8e7c2 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/Cal10nError.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/Cal10nError.java
@@ -43,16 +43,16 @@ public class Cal10nError {
   final Locale locale;
   final Class<?> enumClass;
   final String enumClassName;
-  final String resouceBundleName;
+  final String baseName;
 
   Cal10nError(ErrorType errorType, String key, Class<?> enumClass,
-      Locale locale, String resourceBundleName) {
+      Locale locale, String baseName) {
     this.errorType = errorType;
     this.key = key;
     this.enumClass = enumClass;
     this.enumClassName = enumClass.getName();
     this.locale = locale;
-    this.resouceBundleName = resourceBundleName;
+    this.baseName = baseName;
   }
 
   public ErrorType getErrorType() {
@@ -82,21 +82,21 @@ public class Cal10nError {
       // enumClassName
       // + "]";
     case FAILED_TO_FIND_RB:
-      return "Failed to locate resource bundle [" + resouceBundleName
-          + "]for locale [" + locale + "] for enum type [" + enumClassName
+      return "Failed to locate resource bundle [" + baseName
+          + "] for locale [" + locale + "] for enum type [" + enumClassName
           + "]";
     case EMPTY_RB:
-      return "Empty resource bundle named [" + resouceBundleName
+      return "Empty resource bundle named [" + baseName
           + "] for locale [" + locale + "]";
     case EMPTY_ENUM:
       return "Empty enum type [" + enumClassName + "]";
     case ABSENT_IN_ENUM:
       return "Key [" + key + "] present in resource bundle named ["
-          + resouceBundleName + "] for locale [" + locale
+          + baseName + "] for locale [" + locale
           + "] but absent in enum type [" + enumClassName + "]";
     case ABSENT_IN_RB:
       return "Key [" + key + "] present in enum type [" + enumClassName
-          + "] but absent in resource bundle named [" + resouceBundleName
+          + "] but absent in resource bundle named [" + baseName
           + "] for locale [" + locale + "]";
     default:
       throw new IllegalStateException("Impossible to reach here");
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/IMessageKeyVerifier.java b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/IMessageKeyVerifier.java
index ae4b89b..14cf610 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/IMessageKeyVerifier.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/IMessageKeyVerifier.java
@@ -15,9 +15,10 @@ import java.util.Locale;
  */
 public interface IMessageKeyVerifier {
 
+  // WARNING:
   // WARNING: The name of this class is referenced in String form
   // to do class loader tricks. Do not change the name of this class
-  // without looking at the maven-plugin.
+  // without looking at the maven-cal10n-plugin.
 
   /**
    * Get the of enum type that this verifier is related to to.
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/MessageKeyVerifier.java b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/MessageKeyVerifier.java
index ce31ace..8b78912 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/verifier/MessageKeyVerifier.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/verifier/MessageKeyVerifier.java
@@ -31,6 +31,8 @@ import java.util.ResourceBundle;
 import java.util.Set;
 
 import ch.qos.cal10n.util.AnnotationExtractor;
+import ch.qos.cal10n.util.PropertyResourceBundleFinder;
+import ch.qos.cal10n.util.StringToLocale;
 import ch.qos.cal10n.verifier.Cal10nError.ErrorType;
 
 /**
@@ -73,27 +75,28 @@ public class MessageKeyVerifier implements IMessageKeyVerifier {
   public List<Cal10nError> verify(Locale locale) {
     List<Cal10nError> errorList = new ArrayList<Cal10nError>();
 
-    String resouceBundleName = AnnotationExtractor
-        .getBaseName(enumType);
+    String baseName = AnnotationExtractor.getBaseName(enumType);
 
-    if (resouceBundleName == null) {
+    if (baseName == null) {
       errorList.add(new Cal10nError(ErrorType.MISSING_BN_ANNOTATION, "",
           enumType, locale, ""));
       // no point in continuing
       return errorList;
     }
 
-    ResourceBundle rb = ResourceBundle.getBundle(resouceBundleName, locale);
+    ResourceBundle rb = PropertyResourceBundleFinder.getBundle(this.getClass()
+        .getClassLoader(), baseName, locale);
 
-    ErrorFactory errorFactory = new ErrorFactory(enumType, locale,
-        resouceBundleName);
+    ErrorFactory errorFactory = new ErrorFactory(enumType, locale, baseName);
 
     if (rb == null) {
       errorList.add(errorFactory.buildError(ErrorType.FAILED_TO_FIND_RB, ""));
+   // no point in continuing
+      return errorList;
     }
-
-    Set<String> rbKeySet = buildKeySetFromEnumeration(rb.getKeys());
     
+    Set<String> rbKeySet = buildKeySetFromEnumeration(rb.getKeys());
+
     if (rbKeySet.size() == 0) {
       errorList.add(errorFactory.buildError(ErrorType.EMPTY_RB, ""));
     }
@@ -123,14 +126,14 @@ public class MessageKeyVerifier implements IMessageKeyVerifier {
   }
 
   private Set<String> buildKeySetFromEnumeration(Enumeration<String> e) {
-    Set<String> set = new HashSet<String>(); 
-    while(e.hasMoreElements()) {
+    Set<String> set = new HashSet<String>();
+    while (e.hasMoreElements()) {
       String s = e.nextElement();
       set.add(s);
     }
     return set;
   }
-  
+
   public List<String> typeIsolatedVerify(Locale locale) {
     List<Cal10nError> errorList = verify(locale);
     List<String> strList = new ArrayList<String>();
@@ -154,7 +157,8 @@ public class MessageKeyVerifier implements IMessageKeyVerifier {
       throw new IllegalStateException(errMsg);
     }
     for (String localeName : localeNameArray) {
-      Locale locale = new Locale(localeName);
+      Locale locale = StringToLocale.toLocale(localeName);
+      System.out.println(locale);
       List<Cal10nError> tmpList = verify(locale);
       errorList.addAll(tmpList);
     }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
index bb5e4a0..8c026bb 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
@@ -28,6 +28,7 @@ import ch.qos.cal10n.BaseName;
 @BaseName("colors")
 @LocaleNames({"en_UK", "fr"})
 public enum Colors {
+  // sub-class for testing purposes
   RED {
      
   },
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/MyAllInOneColorVerificationTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/sample/MyAllInOneColorVerificationTest.java
index 5f5014a..5af05d3 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/MyAllInOneColorVerificationTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/sample/MyAllInOneColorVerificationTest.java
@@ -44,6 +44,7 @@ public class MyAllInOneColorVerificationTest {
   public void all() {
     IMessageKeyVerifier mcv = new MessageKeyVerifier(Colors.class);
     List<Cal10nError> errorList = mcv.verifyAllLocales();
+    System.out.println(errorList);
     assertEquals(0, errorList.size());
   }
 
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/PackageTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/sample/PackageTest.java
index 6df62ba..ca1f4e2 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/PackageTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/sample/PackageTest.java
@@ -27,6 +27,7 @@ import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses( { MessageKeyVerifierTest.class, MessageConveyorTest.class, WithDefaultTest.class })
+ at SuiteClasses( { MessageKeyVerifierTest.class, MessageConveyorTest.class,
+    MyColorVerificationTest.class, MyAllInOneColorVerificationTest.class })
 public class PackageTest {
 }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java
new file mode 100644
index 0000000..323f4d2
--- /dev/null
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cal10n.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.junit.Test;
+
+public class PropertyResourceBundleFinderTest {
+  ResourceBundle rb;
+
+  @Test
+  public void smoke() throws IOException {
+    rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "colors", Locale.FRENCH);
+    assertEquals("les roses sont rouges", rb.getString("RED"));
+  }
+
+  @Test
+  public void withCountry() throws IOException {
+    rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "colors", Locale.FRENCH);
+    assertEquals("les roses sont rouges", rb.getString("RED"));
+
+    rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "colors", Locale.FRANCE);
+    assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
+  }
+
+  @Test
+  public void inDirectory() throws IOException {
+    rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "foobar/sample", Locale.ENGLISH);
+    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
+
+    rb = PropertyResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "foobar.sample", Locale.ENGLISH);
+    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
+  }
+}
diff --git a/cal10n-api/src/test/resources/colors.properties b/cal10n-api/src/test/resources/colors.properties
new file mode 100644
index 0000000..6eb4378
--- /dev/null
+++ b/cal10n-api/src/test/resources/colors.properties
@@ -0,0 +1,4 @@
+# this bundle should be ignored
+BLUE=BBBBBBB
+RED=RRRRRRRRRRR
+GREEN=GGGGGGGGG
\ No newline at end of file
diff --git a/cal10n-api/src/test/resources/colors_fr_FR.properties b/cal10n-api/src/test/resources/colors_fr_FR.properties
new file mode 100644
index 0000000..8a57918
--- /dev/null
+++ b/cal10n-api/src/test/resources/colors_fr_FR.properties
@@ -0,0 +1 @@
+RED=les roses sont rouges, et alors?
\ No newline at end of file
diff --git a/cal10n-api/src/test/resources/foobar/sample_en.properties b/cal10n-api/src/test/resources/foobar/sample_en.properties
new file mode 100644
index 0000000..a705e87
--- /dev/null
+++ b/cal10n-api/src/test/resources/foobar/sample_en.properties
@@ -0,0 +1 @@
+A=A is the first letter of the alphabet
\ No newline at end of file
diff --git a/cal10n-api/src/test/resources/foobar/sample_fr.properties b/cal10n-api/src/test/resources/foobar/sample_fr.properties
new file mode 100644
index 0000000..401665b
--- /dev/null
+++ b/cal10n-api/src/test/resources/foobar/sample_fr.properties
@@ -0,0 +1 @@
+A=A est la premiere letter de l'alphabet
\ No newline at end of file
diff --git a/cal10n-site/src/site/pages/manual.html b/cal10n-site/src/site/pages/manual.html
index 685a471..e180c46 100644
--- a/cal10n-site/src/site/pages/manual.html
+++ b/cal10n-site/src/site/pages/manual.html
@@ -152,8 +152,55 @@ String blue = mc.getMessage(Colors.BLUE);  </pre>
   comes with additional tooling support.
   </p>
 
+  <h2><a name="simplifiedLookup" href="#simplifiedLookup">Simplified
+  bundle lookup procedure</a></h2>                             
+
+  <p>The <code>ResourceBundle</code> class defines a rather involved
+  <a
+  href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29">lookup
+  procedure</a> for finding resource bundles. While formally this
+  procedure is deterministic, it is too error-prone for our taste. In
+  CAL10N, we thus took the bold initiative to define a simplified bundle look
+  up procedure.
+  </p>
+
+  <p>Given a locale, the simplified look up procedure only takes into
+  account that locale, ignoring the default locale and the resource
+  bundle corresponding to the naked base name, i.e. the default
+  resource bundle. However, if the locale has both a language
+  <b>and</b> a country, and corresponding bundle files exist, then
+  CAL10N will take into account both bundles, establishing the same
+  parent child relationship as the JDK <code>ResourceBundle</code>
+  class.
+  </p>
+
+  <p>For example, for base name "colors" if the following bundles
+  exist on the class path:
+  </p>
+
+  <pre class="source">colors.properties
+colors_en_US.properties
+colors_en.properties
+colors_fr_FR.properties</pre>
+
+
+   <p>and the system's default locale is "fr_FR", when CAL10N is asked
+   to find resource bundles corresponding to the "en_US" locale, it
+   will ignore the <em>colors.properties</em> (~ default bundle) and
+   <em>colors_fr_FR.properties</em> (~ default locale), while
+   combining the <em>colors_en_US.properties</em> and
+   <em>colors_en.properties</em> bundles in the usual parent-child
+   relationship.
+   </p>
+
+   <p>We hope that the simplified lookup procedeue, while deviating
+   from the conventions of the Java platform as defined in the
+   <code>ResourceBundle</code> class, will still cause <a
+   href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment">
+   less suprises</a>.</p>
 
-  <h2><a name="deferred" href="#deferred">Deferred localization</a></h2>
+  <h2><a name="deferred" href="#deferred">Deferred
+  localization</a></h2>
 
   <p>Under certain circumstances, the appropriate locale is
   <em>unknown</em> at the time or place where the message key and
diff --git a/cal10n-site/src/site/pages/news.html b/cal10n-site/src/site/pages/news.html
index 0e42b24..488a47f 100644
--- a/cal10n-site/src/site/pages/news.html
+++ b/cal10n-site/src/site/pages/news.html
@@ -29,13 +29,17 @@
 
     <hr width="80%" align="center" />
  
-    <h3>x of September 2009 - Release of CAL10N version 0.5.2</h3>
+    <h3>2nd of September 2009 - Release of CAL10N version 0.6</h3>
 
     <p>Fixed issue <a href="http://jira.qos.ch/browse/CAL-1">CAL-1</a>
     as reported by Takeshi Kondo. <code>MessageConveyor</code> will
     now correctly handle enums which are nested within other classes
     or enums which are nested within another enum.</p>
 
+    <p>CAI10N now uses a <a
+    href="manual.html#simplifiedLookup">simplifed bundle lookup
+    procedure</a>.</p>
+
     <hr width="80%" align="center" />
  
     <h3>1st of September 2009 - Release of CAL10N version 0.5.1</h3>

-----------------------------------------------------------------------

Summary of changes:
 .../main/java/ch/qos/cal10n/MessageConveyor.java   |   21 +++--
 .../cal10n/util/CAL10NPropertyResourceBundle.java} |   21 +++--
 .../cal10n/util/PropertyResourceBundleFinder.java  |  103 ++++++++++++++++++++
 .../java/ch/qos/cal10n/util/StringToLocale.java}   |   27 ++---
 .../java/ch/qos/cal10n/verifier/Cal10nError.java   |   16 ++--
 .../qos/cal10n/verifier/IMessageKeyVerifier.java   |    3 +-
 .../ch/qos/cal10n/verifier/MessageKeyVerifier.java |   28 +++---
 .../src/test/java/ch/qos/cal10n/sample/Colors.java |    1 +
 .../sample/MyAllInOneColorVerificationTest.java    |    1 +
 .../java/ch/qos/cal10n/sample/PackageTest.java     |    3 +-
 .../util/PropertyResourceBundleFinderTest.java     |   63 ++++++++++++
 cal10n-api/src/test/resources/colors.properties    |    4 +
 .../src/test/resources/colors_fr_FR.properties     |    1 +
 .../src/test/resources/foobar/sample_en.properties |    1 +
 .../src/test/resources/foobar/sample_fr.properties |    1 +
 cal10n-site/src/site/pages/manual.html             |   49 +++++++++-
 cal10n-site/src/site/pages/news.html               |    6 +-
 17 files changed, 293 insertions(+), 56 deletions(-)
 copy cal10n-api/src/{test/java/ch/qos/cal10n/util/PackageTest.java => main/java/ch/qos/cal10n/util/CAL10NPropertyResourceBundle.java} (73%)
 create mode 100644 cal10n-api/src/main/java/ch/qos/cal10n/util/PropertyResourceBundleFinder.java
 rename cal10n-api/src/{test/java/ch/qos/cal10n/sample/WithDefaultTest.java => main/java/ch/qos/cal10n/util/StringToLocale.java} (74%)
 create mode 100644 cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java
 create mode 100644 cal10n-api/src/test/resources/colors.properties
 create mode 100644 cal10n-api/src/test/resources/colors_fr_FR.properties
 create mode 100644 cal10n-api/src/test/resources/foobar/sample_en.properties
 create mode 100644 cal10n-api/src/test/resources/foobar/sample_fr.properties


hooks/post-receive
-- 
Compiler assisted localization library


More information about the cal10n-dev mailing list