[cai18n-dev] [GIT] Compiler assisted internalization library branch, master, updated. ef9dc9ce5085e3ec30f727c65337ba0b5ab3ae2b

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


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted internalization library".

The branch, master has been updated
       via  ef9dc9ce5085e3ec30f727c65337ba0b5ab3ae2b (commit)
      from  0936b519106c49b17130fb6de8f0af9789ab1dd1 (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=cai18n.git;a=commit;h=ef9dc9ce5085e3ec30f727c65337ba0b5ab3ae2b
http://github.com/ceki/cai18n/commit/ef9dc9ce5085e3ec30f727c65337ba0b5ab3ae2b

commit ef9dc9ce5085e3ec30f727c65337ba0b5ab3ae2b
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Aug 26 00:16:45 2009 +0200

    - IMessageConveyor is the interface, MessageConveyor is the default impl.

diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleBasedMessageConveyor.java b/cai18n-api/src/main/java/ch/qos/cai18n/IMessageConveyor.java
similarity index 61%
rename from cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleBasedMessageConveyor.java
rename to cai18n-api/src/main/java/ch/qos/cai18n/IMessageConveyor.java
index 402f7a9..7a98e2e 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleBasedMessageConveyor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/IMessageConveyor.java
@@ -20,37 +20,13 @@
  * SOFTWARE.
  */
 
-
 package ch.qos.cai18n;
 
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-public class ResourceBundleBasedMessageConveyor implements MessageConveyor {
-
-  Locale locale;
-
-  public ResourceBundleBasedMessageConveyor(Locale locale) {
-    this.locale = locale;
-  }
-
-
-  public <E extends Enum<?>> String getMessage(E e, Object... args) {
-  String code = e.toString();
-    ResourceBundle rb = ResourceBundle
-        .getBundle(e.getClass().getName(), locale);
 
-    String value = rb.getString(code);
-    if (value == null) {
-      return "No key found for " + code;
-    } else {
-      if (args.length == 0) {
-        return value;
-      } else {
-        return MessageFormat.format(value, args);
-      }
-    }
-  }
+// note that the getMessage method does not take a Locale.
+// It is supposed that the MessageConveyor instance knows
+// which locale to use.
 
+public interface IMessageConveyor {
+	<E extends Enum<?>> String getMessage(E e, Object... args);
 }
diff --git a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
index e8722cc..1edc794 100644
--- a/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
+++ b/cai18n-api/src/main/java/ch/qos/cai18n/MessageConveyor.java
@@ -20,13 +20,37 @@
  * SOFTWARE.
  */
 
+
 package ch.qos.cai18n;
 
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class MessageConveyor implements IMessageConveyor {
+
+  Locale locale;
+
+  public MessageConveyor(Locale locale) {
+    this.locale = locale;
+  }
+
+
+  public <E extends Enum<?>> String getMessage(E e, Object... args) {
+  String code = e.toString();
+    ResourceBundle rb = ResourceBundle
+        .getBundle(e.getClass().getName(), locale);
 
-// note that the getMessage method does not take a Locale.
-// It is supposed that the MessageConveyor instance knows
-// which locale to use.
+    String value = rb.getString(code);
+    if (value == null) {
+      return "No key found for " + code;
+    } else {
+      if (args.length == 0) {
+        return value;
+      } else {
+        return MessageFormat.format(value, args);
+      }
+    }
+  }
 
-public interface MessageConveyor {
-	<E extends Enum<?>> String getMessage(E e, Object... args);
 }
diff --git a/cai18n-api/src/test/java/ch/qos/cai18n/sample/ResourceBunleBasedMC_Test.java b/cai18n-api/src/test/java/ch/qos/cai18n/sample/ResourceBunleBasedMC_Test.java
index 743b299..829bc25 100644
--- a/cai18n-api/src/test/java/ch/qos/cai18n/sample/ResourceBunleBasedMC_Test.java
+++ b/cai18n-api/src/test/java/ch/qos/cai18n/sample/ResourceBunleBasedMC_Test.java
@@ -28,13 +28,13 @@ import java.util.Locale;
 
 import org.junit.Test;
 
-import ch.qos.cai18n.ResourceBundleBasedMessageConveyor;
+import ch.qos.cai18n.MessageConveyor;
 
 public class ResourceBunleBasedMC_Test {
 
   @Test
   public void smoke_EN() {
-    ResourceBundleBasedMessageConveyor rbbmc = new ResourceBundleBasedMessageConveyor(
+    MessageConveyor rbbmc = new MessageConveyor(
         Locale.UK);
 
     {
@@ -52,7 +52,7 @@ public class ResourceBunleBasedMC_Test {
   
   @Test
   public void smoke_FR() {
-    ResourceBundleBasedMessageConveyor rbbmc = new ResourceBundleBasedMessageConveyor(
+    MessageConveyor rbbmc = new MessageConveyor(
         Locale.FRANCE);
 
     {
diff --git a/cai18n-api/src/test/resources/ch/qos/cai18n/sample/Colors_fr.properties b/cai18n-api/src/test/resources/ch/qos/cai18n/sample/Colors_fr.properties
index 968a87c..0ea9e8c 100644
--- a/cai18n-api/src/test/resources/ch/qos/cai18n/sample/Colors_fr.properties
+++ b/cai18n-api/src/test/resources/ch/qos/cai18n/sample/Colors_fr.properties
@@ -1,3 +1,3 @@
-BLUE=les violettes sont blues
+BLUE=les violettes sont bleues
 RED=les roses sont rouges
 GREEN=les {0} sont verts
\ No newline at end of file
diff --git a/cai18n-site/src/site/pages/manual.html b/cai18n-site/src/site/pages/manual.html
index 4218a29..7c6060c 100644
--- a/cai18n-site/src/site/pages/manual.html
+++ b/cai18n-site/src/site/pages/manual.html
@@ -24,21 +24,21 @@
 
    <h1>CAI18N Manual</h1>
 
-   <p>The goal of CAI18N is to augment the internationalization
-   functionality offered by the Java platform with consistency and
-   verification operations. It is assumed that you are somewhat
-   familiar with <a
+   <p>The goal of CAI18N project is to enhance the existing
+   internationalization functionality offered by the Java platform
+   with consistency and verification primitives. It is assumed that
+   you are already somewhat familiar with <a
    href="http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/">using
    ResourceBundles</a>.
    </p>
 
+   <h3>Core idea</h3>
 
    <p>Instead of using values of type String as the key each message,
-   CAI18N uses <code>enums</code>.
-   </p>
+   CAI18N uses <code>enums</code>.</p>
 
-   <p>Assume you wish to internationalize color names, you could write
-   a color enum.</p>
+   <p>For the sake of argument, assume you wish to internationalize
+   color names, in CAI18N you could write a color enum.</p>
 
    <pre class="prettyprint source">
 package com.foo.somePackage;
@@ -67,7 +67,7 @@ GREEN={0} are green  </pre>
   <em>Colors_fr.properties</em>. Here are possible contents.</p>
 
   <pre class="source">
-BLUE=les violettes sont blues
+BLUE=les violettes sont bleues
 RED=les roses sont rouges
 GREEN=les {0} sont verts</pre>
 
@@ -77,22 +77,34 @@ GREEN=les {0} sont verts</pre>
   <p>In your application, you would retreive the localized message as
   follows: </p>
 
-  <pre  class="prettyprint source">//Obtain a resource bundle based message conveyor
-ResourceBundleBasedMessageConveyor rbbmc = 
-                       new ResourceBundleBasedMessageConveyor(Locale.FRANCE);
+  <pre  class="prettyprint source">// obtain a message convetor for France
+MessageConveyor mc = new MessageConveyor(Locale.FRANCE);
+
 // use it to retrieve internationalized messages
-String red = rbbmc.getMessage(Colors.RED);
-String blue = rbbmc.getMessage(Colors.BLUE);  </pre>
+String red = mc.getMessage(Colors.RED);
+String blue = mc.getMessage(Colors.BLUE);  </pre>
 
   <p>CAI18N leverages the existing resource bundle infrastructure you
   have been accustomed to, but adds compiler verification on top.</p>
 
 
-  <p>An astute reader will comment even if the messages codes are now
+  <p>An astute reader will comment that even if the messages codes are now
   verified by the compiler, it is still possible to have mismatching
   message codes in the resources bundles. For this reason, CAI18N
   comes with additional tooling support.
   </p>
+
+
+  <h2>Maven Plugin</h2>
+
+  <p>Already implemented. Needs to be documented.</p>
+
+  <h2>Ant task</h2>
+
+  <p>We are looking for volunteers to implement an Ant task to verify
+  resource bundles. If interested please contact the cai18n-dev
+  mailing list.</p>
+
   <script src="templates/footer.js" type="text/javascript"></script>
 </div>
 </body>

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

Summary of changes:
 ...{MessageConveyor.java => IMessageConveyor.java} |    2 +-
 .../main/java/ch/qos/cai18n/MessageConveyor.java   |   34 ++++++++++--
 .../cai18n/ResourceBundleBasedMessageConveyor.java |   56 --------------------
 .../cai18n/sample/ResourceBunleBasedMC_Test.java   |    6 +-
 .../ch/qos/cai18n/sample/Colors_fr.properties      |    2 +-
 cai18n-site/src/site/pages/manual.html             |   42 +++++++++-----
 6 files changed, 61 insertions(+), 81 deletions(-)
 copy cai18n-api/src/main/java/ch/qos/cai18n/{MessageConveyor.java => IMessageConveyor.java} (95%)
 delete mode 100644 cai18n-api/src/main/java/ch/qos/cai18n/ResourceBundleBasedMessageConveyor.java


hooks/post-receive
-- 
Compiler assisted internalization library



More information about the cal10n-dev mailing list