dev@glassfish.java.net

RE: message catalog synchronization

From: Frank Kieviet <Frank.Kieviet_at_Sun.COM>
Date: Wed, 15 Jul 2009 23:59:10 -0700

Hi Kedar,

 

Here is an example pom of the XSLT SE in the Open-JBI-Components project on
java.net:

 

    <build>

        <plugins>

            <plugin>

                <artifactId>maven-antrun-plugin</artifactId>

                <executions>

                    <execution>

                        <id>${project.artifactId}-generate-i18n-bundle</id>

                        <phase>process-classes</phase>

                        <goals><goal>run</goal></goals>

                        <configuration>

                            <tasks>

                                <taskdef name="i18n"

 
classname="net.java.hulp.i18n.buildtools.I18NTask">

                                    <classpath>

                                        <pathelement

 
location="${maven.repo.local}/net/java/hulp/i18ntask/net.java.hulp.i18ntask/
2.1-SNAPSHOT/net.java.hulp.i18ntask-2.1-SNAPSHOT.jar"/>

                                    </classpath>

                                </taskdef>

                                <i18n dir="${project.build.outputDirectory}"


 
file="${project.build.outputDirectory}/com/sun/jbi/engine/xslt/msgs.properti
es"

                                      prefix=""

                                      pattern="(XSLTSE-[4-7]\d\d\d)(: )(.*)"
/>

                            </tasks>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

        </plugins>

    </build>

(thanks to Kevan Simpson)

 

As you can see it is using Ant. I'm not a Maven expert (yet), but I'd think
this can be made into a Maven plugin (mojo?). This may make it less verbose.

 

If you're not using Maven, here's an example of how I use it in Ant in the
JMSJCA project (jmsjca.dev.java.net):

 

        <!-- Before jar, update i18n properties file in src directory and
copy it to the jar -->

        <taskdef name="i18n" classname="com.stc.i18ntools.TextExtractor"
classpath="${jmsjca.build-tools.classes.dir}"/>

        <i18n dir="${jmsjca.xxx.rar.classes.dir}"
file="${jcaid}/src/java/com/stc/jmsjca/${jcaid}/msgs.properties"
prefixU="ra${jcaid}-" />

        <copy todir="${jmsjca.xxx.rar.classes.dir}">

            <fileset dir="${jcaid}/src/java" excludes="**/*.java"/>

        </copy>

 

JMSJCA uses a predecessor of the hulp.dev.java.net tools, and JMSJCA adds a
few wrappers so that I can force the use of internationalizable messages,
e.g. the warn-method requires a localized message.

 

sLog.warn(LOCALE.x("E042: Ignoring ClientID: the ClientID is "

  + "already set to [{0}]; cannot set to [{1}] as required in "

  + "activationspec [{2}]", currentClientId, spec.getClientId(), spec));

 

For those that haven't read my blog entry, the above statement is what's in
the source. During build time, the message gets put into a resource bundle.
Sometime before the release, the bundle is sent to the localization team
which sends back a localized bundle, which then gets packaged into the
release bits. During runtime, the statement above uses the first part of the
message, i.e. the message id (E042), to load the localized message from the
proper bundle and logs "JMSJCA-E042: De client ID wordt genegeerd: de client
ID is reeds gespecificeerd als [{0}] en kan niet... " etc.

 

Let me know if I can help. The Maven plugin may be a good finger exercise to
get going with Maven (I'm studying Maven currently for use in the Fuji
project).

 

Frank

 

 

 

 

 

> -----Original Message-----

> From: Kedar.Mhaswade_at_Sun.COM [mailto:Kedar.Mhaswade_at_Sun.COM]

> Sent: Wednesday, July 15, 2009 20:32

> To: dev_at_glassfish.dev.java.net

> Subject: Re: message catalog synchronization

>

> Frank,

>

> I like your approach. I think it's similar to Ken's approach, but was

> simpler to understand.

>

> What are the maven artifact details for this functionality in case we want

> to try it out? Or do we have to use maven-ant-plugin?

>

> -Kedar

>

> PS - Bill it was a good requirement to think about!

>

> Frank Kieviet wrote:

> > Hi Bill,

> >

> > In most of the components in OpenESB we use a tool that reads the

> strings

> > from the Java files and puts them in resource bundles. This avoids

> > synchronization issues automatically. It also makes reading the sources

> > easier and while reading the sources, it's easier to detect problems

> where

> > the arguments don't match the messages.

> >

> > We've integrated this tool into our Maven builds.

> >

> > See <

> >

> http://blogs.sun.com/fkieviet/entry/server_side_internationaliation_made_e

> as

> > y> for more info.

> >

> > HTH,

> > Frank

> >

> >

> >> -----Original Message-----

> >> From: dev-return-13444-frank.kieviet=sun.com_at_glassfish.dev.java.net

> >> [mailto:dev-return-13444-frank.kieviet=sun.com_at_glassfish.dev.java.net]

> On

> >> Behalf Of Bill Shannon

> >> Sent: Wednesday, July 15, 2009 14:53

> >> To: dev_at_glassfish.dev.java.net

> >> Subject: message catalog synchronization

> >>

> >> Does anyone have any tools or techniques for keeping message catalogs

> >> (LocalStrings.properties) synchronized with the code that uses them?

> >>

> >> ---------------------------------------------------------------------

> >> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net

> >> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net

> >

> >

> >

> > ---------------------------------------------------------------------

> > To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net

> > For additional commands, e-mail: dev-help_at_glassfish.dev.java.net

> >

>

> ---------------------------------------------------------------------

> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net

> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net