[cal10n-dev] branch, master, updated. v0.6.5-7-gbdbdcf6
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Fri Sep 4 14:34:08 CEST 2009
The branch, master has been updated
via bdbdcf62a24bef203a59f9c7db0715c0d550d9f1 (commit)
from 57cfb3ec63a9637602e4d70396acc2517967c41b (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=bdbdcf62a24bef203a59f9c7db0715c0d550d9f1
http://github.com/ceki/cal10n/commit/bdbdcf62a24bef203a59f9c7db0715c0d550d9f1
commit bdbdcf62a24bef203a59f9c7db0715c0d550d9f1
Author: Ceki Gulcu <ceki at qos.ch>
Date: Fri Sep 4 14:31:31 2009 +0200
Documenting changes in annotations, charset support, new tests
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/BaseName.java b/cal10n-api/src/main/java/ch/qos/cal10n/BaseName.java
index 46fa24c..eb78246 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/BaseName.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/BaseName.java
@@ -22,7 +22,6 @@
package ch.qos.cal10n;
import java.lang.annotation.ElementType;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -37,8 +36,8 @@ import ch.qos.cal10n.verifier.MessageKeyVerifier;
* Typical usage is:
*
* <pre>
- * @LocaleNames({"en", "jp"})
* @BaseName("colors");
+ * @LocaleData( { @Locale("en"), @Locale("jp") } )
* public class enum Colors {
* RED, WHITE, BLUE;
* }
@@ -47,8 +46,9 @@ import ch.qos.cal10n.verifier.MessageKeyVerifier;
* <p>
* In the above example, @BaseName("colors") means that there exists a family of
* resource bundle files with the base name "colors". In conjunction with the
- * information provided in the @LocaleNames annotation, we can assume that the
- * files <em>colors_en.properties</em> and <em>colors_jp.properties</em> exist.
+ * information provided in the @{@link LocaleData} annotation, we can assume
+ * that the files <em>colors_en.properties</em> and
+ * <em>colors_jp.properties</em> exist.
*
* <p>
* Verification tools such as {@link MessageKeyVerifier} can then proceed to
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/Locale.java b/cal10n-api/src/main/java/ch/qos/cal10n/Locale.java
index f655d39..cd9da5d 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/Locale.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/Locale.java
@@ -26,33 +26,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import ch.qos.cal10n.verifier.MessageKeyVerifier;
-
/**
- * This annotation serves to designate a list of locale names for which resource
- * bundles exist.
- *
- * <p>
- * Typical usage is:
- *
- * <pre>
- * @LocaleNames({"en", "jp"})
- * @BaseName("colors");
- * public class enum Colors {
- * RED, WHITE, BLUE;
- * }
- * </pre>
*
- * <p>
- * In the above example, @LocaleNames({"en", "jp"}) means that there are English
- * (en) and Japanese translations for the message keys found in the Colors enum.
- * The name of the corresponding resource bundle is named "colors".
+ * See {@link LocaleData} annotation.
*
- * <p>
- * Verification tools such {@link MessageKeyVerifier} can thus conclude that the
- * resource bundle files <em>colors_en.properties</em> and
- * <em>colors_jp.properties</em> should exist and checked against the keys
- * defined in the Colors enum.
+ * @see LocaleData
*
* @author Ceki Gülcü
*
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/LocaleData.java b/cal10n-api/src/main/java/ch/qos/cal10n/LocaleData.java
index c4912f0..605979d 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/LocaleData.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/LocaleData.java
@@ -26,33 +26,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import ch.qos.cal10n.verifier.MessageKeyVerifier;
-
/**
- * This annotation serves to designate a list of locale names for which resource
- * bundles exist.
- *
- * <p>
- * Typical usage is:
- *
- * <pre>
- * @LocaleNames({"en", "jp"})
- * @BaseName("colors");
- * public class enum Colors {
- * RED, WHITE, BLUE;
- * }
- * </pre>
- *
- * <p>
- * In the above example, @LocaleNames({"en", "jp"}) means that there are English
- * (en) and Japanese translations for the message keys found in the Colors enum.
- * The name of the corresponding resource bundle is named "colors".
- *
- * <p>
- * Verification tools such {@link MessageKeyVerifier} can thus conclude that the
- * resource bundle files <em>colors_en.properties</em> and
- * <em>colors_jp.properties</em> should exist and checked against the keys
- * defined in the Colors enum.
+ * In conjunction with the @Locale annotation, the @LocaleData annotation serves
+ * to designate a list of locale names for which resource bundles exist. In
+ * addition, you can specify a default charset for all locales. See the <a
+ * href="http://cal10n.qos.ch/manual.html#charset">section on charsets<a> in the
+ * manual for an explanation.
*
* @author Ceki Gülcü
*
@@ -61,5 +40,6 @@ import ch.qos.cal10n.verifier.MessageKeyVerifier;
@Target(ElementType.TYPE)
public @interface LocaleData {
Locale[] value();
+
String defaultCharset() default "";
}
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 be8e7c2..14ff09a 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
@@ -77,10 +77,6 @@ public class Cal10nError {
case MISSING_BN_ANNOTATION:
return "Missing @BaseName annotation in enum type ["
+ enumClassName + "]";
- // case MISSING_LOCALE_NAMES_ANNOTATION:
- // return "Missing @LocaleNames annotation in enum class [" +
- // enumClassName
- // + "]";
case FAILED_TO_FIND_RB:
return "Failed to locate resource bundle [" + baseName
+ "] for locale [" + locale + "] for enum type [" + enumClassName
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 14cf610..bb960c9 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
@@ -46,7 +46,7 @@ public interface IMessageKeyVerifier {
/**
* Verify that the keys defined in the enumClass match those found in the
* corresponding resource bundle for all locales declared in the enum type
- * via the {@link @LocaleNames} annotation.
+ * via the @{@link LocaleData} annotation.
*
* @param locale
* @return
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 deec78f..8db124a 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
@@ -153,7 +153,7 @@ public class MessageKeyVerifier implements IMessageKeyVerifier {
String[] localeNameArray = getLocaleNames();
if (localeNameArray == null || localeNameArray.length == 0) {
- String errMsg = "Missing @LocaleNames annotation in enum type ["
+ String errMsg = "Missing @LocaleData annotation in enum type ["
+ enumTypeAsStr + "]";
throw new IllegalStateException(errMsg);
}
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
index 5726920..f135751 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
@@ -30,6 +30,7 @@ import java.util.Locale;
import org.junit.Test;
import ch.qos.cal10n.sample.Colors;
+import ch.qos.cal10n.sample.Minimal;
import ch.qos.cal10n.sample.Host.OtherColors;
public class MessageConveyorTest {
@@ -105,4 +106,11 @@ public class MessageConveyorTest {
}
}
+
+ @Test
+ public void minimal() {
+ MessageConveyor mc = new MessageConveyor(Locale.ENGLISH);
+ assertEquals("A", mc.getMessage(Minimal.A));
+ }
+
}
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 33f9060..a620261 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
@@ -27,15 +27,11 @@ import ch.qos.cal10n.Locale;
import ch.qos.cal10n.LocaleData;
@BaseName("colors")
- at LocaleData({
- @Locale("en_UK"),
- @Locale("fr")
- })
+ at LocaleData( { @Locale("en_UK"), @Locale("fr") })
public enum Colors {
// sub-class for testing purposes
RED {
-
+
},
- BLUE,
- GREEN;
+ BLUE, GREEN;
}
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Minimal.java
similarity index 81%
copy from cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
copy to cal10n-api/src/test/java/ch/qos/cal10n/sample/Minimal.java
index 33f9060..a17911b 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Minimal.java
@@ -19,23 +19,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
package ch.qos.cal10n.sample;
import ch.qos.cal10n.BaseName;
-import ch.qos.cal10n.Locale;
-import ch.qos.cal10n.LocaleData;
- at BaseName("colors")
- at LocaleData({
- @Locale("en_UK"),
- @Locale("fr")
- })
-public enum Colors {
- // sub-class for testing purposes
- RED {
-
- },
- BLUE,
- GREEN;
+/**
+ * The most minimal enum that CAL10N supports.
+
+ * @author Ceki Gülcü
+ *
+ */
+
+ at BaseName("minimal")
+public enum Minimal {
+ A;
}
diff --git a/cal10n-api/src/test/resources/minimal_en.properties b/cal10n-api/src/test/resources/minimal_en.properties
new file mode 100644
index 0000000..18718bf
--- /dev/null
+++ b/cal10n-api/src/test/resources/minimal_en.properties
@@ -0,0 +1 @@
+A=A
\ No newline at end of file
diff --git a/cal10n-site/src/site/pages/codes.html b/cal10n-site/src/site/pages/codes.html
index b6e38e4..21dd972 100644
--- a/cal10n-site/src/site/pages/codes.html
+++ b/cal10n-site/src/site/pages/codes.html
@@ -55,13 +55,12 @@
<hr/>
<h3><a name="missingLocale" href="#missingLocale">Missing
- @LocaleNames annotation in enum type [...].</a>
- </h3>
+ @LocaleData annotation in enum type [...].</a> </h3>
<p>If an enum type and its associated bundles are to be verified
via the <em>maven-cal10n-plugin</em>, then the enum type needs to
be annotated with <a
- href="apidocs/ch/qos/cal10n/LocaleNames.html">LocaleNames</a>.
+ href="apidocs/ch/qos/cal10n/LocaleData.html">LocaleData</a>.
</p>
<script src="templates/footer.js" type="text/javascript"></script>
diff --git a/cal10n-site/src/site/pages/index.html b/cal10n-site/src/site/pages/index.html
index 3e5d777..67b0c97 100644
--- a/cal10n-site/src/site/pages/index.html
+++ b/cal10n-site/src/site/pages/index.html
@@ -39,7 +39,7 @@
<p>Tooling to detect errors in message keys</p>
</li>
- <li>The <em>native2ascii</em> no longer necessary. With CAL10N,
+ <li>The <em>native2ascii</em> tool becomes unnecessary. With CAL10N,
you can directly encode bundles in the most convenient charset,
per locale.</li>
diff --git a/cal10n-site/src/site/pages/manual.html b/cal10n-site/src/site/pages/manual.html
index 5699e42..3e8ce36 100644
--- a/cal10n-site/src/site/pages/manual.html
+++ b/cal10n-site/src/site/pages/manual.html
@@ -88,12 +88,13 @@
<pre class="prettyprint source">package com.foo.somePackage;
-import ch.qos.cal10n.LocaleNames;
+
+import ch.qos.cal10n.LocaleData;
+import ch.qos.cal10n.Locale;
import ch.qos.cal10n.BaseName;
- at BaseName("colors") // mandatory annotation
- at LocaleNames({"en_UK", "fr"}) // list of locale names used by
- // verification tools
+ at BaseName("colors")
+ at LocaleData( { @Locale("en_UK"), @Locale("fr") })
public enum Colors {
BLUE,
RED,
@@ -203,6 +204,58 @@ colors_fr_FR.properties</pre>
href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment">
less surprise</a>.</p>
+
+ <h2><a name="charset" href="#charset">Pick your charset, per
+ locale</a></h2>
+
+ <p>CAL10N allows you to encode the resource bundle for a given
+ locale in the charset of your choice. The set of supported charsets
+ depends on your Java platform. See this <a
+ href="http://www.websina.com/bugzero/kb/java-encoding-charset.html">java
+ encoding and charset list</a> for more details.
+ </p>
+
+ <p>Assume you have four resource bundles, for the English, French,
+ Turkish and Greek languages. You decide to encode all of them in
+ UTF-8 except for the Turkish bundle which is already encoded in
+ ISO8859_3. To tell CAL10N that those are the encodings, you would
+ write:</p>
+
+<pre class="prettyprint">
+ at BaseName("colors")
+ at LocaleData(
+ defaultCharset="UTF8",
+ value = { @Locale("en_UK"),
+ @Locale("fr_FR"),
+ @Locale(value="tr_TR", charset="ISO8859_3"),
+ @Locale("el_GR")
+ }
+ )
+public enum Colors {
+ BLUE,
+ RED,
+ GREEN;
+}
+</pre>
+
+ <p>The <code>defaultCharset</code> directive specified in the
+ <code>@LocaleDat</code>a annotation applies to all nested @Locale
+ annotations, unless the value is overriden by a <code>charset</code>
+ directive (as in the "tr_TR" locale in the example above). If not
+ specified, the default value for <code>defaultCharset</code> is the
+ empty string. In the absence of a <code>defaultCharset</code>
+ directive, the default value for the <code>charset</code> directive
+ is also the empty String.
+ </p>
+
+ <p>If both <code>charset</code> and <code>defaultCharset</code> are
+ empty, CAL10N will use the <a
+ href="http://mindprod.com/jgloss/encoding.html">default encoding</a>
+ for your Java platform to read a resource bundle.</p>
+
+
+
+
<h2><a name="reload" href="#reload">Automatic reloading of resource
bundles upon change</a></h2>
@@ -214,7 +267,7 @@ colors_fr_FR.properties</pre>
<p>Automatic reloading applies if the resource bundle is a regular
file but not if nested within a jar file.
</p>
-
+
<h2><a name="deferred" href="#deferred">Deferred
localization</a></h2>
@@ -314,8 +367,9 @@ Key [BLEU] present in resource bundle named [colors] for locale [fr_FR] but abse
<h3>One test to rule them all</h3>
<p>Instead of a separate unit test case for each locale, assuming
- you declared the locales in the enum type via the @LocaleNames
- annotation, you can verify all locales in one fell swoop.</p>
+ you declared the locales in the enum type via the @LocaleData and
+ nested @Locale annotations, you can verify all locales in one fell
+ swoop.</p>
<pre class="prettyprint source">
package foo.aPackage;
@@ -394,8 +448,8 @@ public class MyAllInOneColorVerificationTest {
</p>
<p>The plugin will iterate through every resource bundle for every
- locale listed in the enum type via the <code>@LocaleNames</code>
- annotation.
+ locale listed in the enum type via the <code>@LocaleData</code> and
+ <code>@Locale</code> annotations.
</p>
<h2><a name="eclipsePlugin" href="#eclipsePlugin">Eclipse plug-in</a></h2>
diff --git a/maven-cal10n-plugin/src/main/java/ch/qos/cal10n/plugins/VerifyMojo.java b/maven-cal10n-plugin/src/main/java/ch/qos/cal10n/plugins/VerifyMojo.java
index 32f41b0..dd13ef2 100644
--- a/maven-cal10n-plugin/src/main/java/ch/qos/cal10n/plugins/VerifyMojo.java
+++ b/maven-cal10n-plugin/src/main/java/ch/qos/cal10n/plugins/VerifyMojo.java
@@ -109,7 +109,7 @@ public class VerifyMojo extends AbstractMojo {
String[] localeNameArray = mcv.getLocaleNames();
if (localeNameArray == null || localeNameArray.length == 0) {
- String errMsg = "Missing @LocaleNames annotation in enum type ["
+ String errMsg = "Missing @LocaleData annotation in enum type ["
+ enumClassAsStr + "]. Please see "+MISSING_LOCALE;
getLog().error(errMsg);
throw new MojoFailureException(errMsg);
-----------------------------------------------------------------------
Summary of changes:
.../src/main/java/ch/qos/cal10n/BaseName.java | 8 +-
cal10n-api/src/main/java/ch/qos/cal10n/Locale.java | 26 +-------
.../src/main/java/ch/qos/cal10n/LocaleData.java | 32 ++-------
.../java/ch/qos/cal10n/verifier/Cal10nError.java | 4 -
.../qos/cal10n/verifier/IMessageKeyVerifier.java | 2 +-
.../ch/qos/cal10n/verifier/MessageKeyVerifier.java | 2 +-
.../java/ch/qos/cal10n/MessageConveyorTest.java | 8 ++
.../src/test/java/ch/qos/cal10n/sample/Colors.java | 10 +--
.../sample/{Furnitures.java => Minimal.java} | 21 +++---
.../src/test/resources/minimal_en.properties | 1 +
cal10n-site/src/site/pages/codes.html | 5 +-
cal10n-site/src/site/pages/index.html | 2 +-
cal10n-site/src/site/pages/manual.html | 72 +++++++++++++++++---
.../java/ch/qos/cal10n/plugins/VerifyMojo.java | 2 +-
14 files changed, 103 insertions(+), 92 deletions(-)
copy cal10n-api/src/test/java/ch/qos/cal10n/sample/{Furnitures.java => Minimal.java} (83%)
create mode 100644 cal10n-api/src/test/resources/minimal_en.properties
hooks/post-receive
--
Compiler assisted localization library
More information about the cal10n-dev
mailing list