SpeakingDuck (Maven plugin for java resource bundle transition.)

Developing multi-lingual applications in java seems a pain, to me anyway.
There are resource bundles and a localisation API – which are well documented.

To speed things up, I wanted to auto translate these bundles, and then have others look over and refine the translations later.

Looking at what already existed, I was not excited.

  • I did not want some heavy weight application.
  • I found some simple auto translation tools, some free-ish, some pay-per-say. But they did not support java resource bundles.
  • I did like translate shell a lot, but it needed integration into the java resource bundle ecosystem
  • Very few tools supported maven
  • Nothing “just worked”

So I created a maven plugin (SpeakingDuck) to translate resource bundles. SpeakingDuck will use whatever translation tool you configure it to run with.

Find it on github:   https://github.com/busyDuckman/speakingDuck

or install via the Maven Repository, or via reference in your pom.xml.

The following pom.xml will cause German, Chinese, Spanish and Russian resource bundles to be maintained (updated for new keys) every compile.

<build>
    <plugins>
        <plugin>
            <groupId>com.busyducks</groupId>
            <artifactId>speakingDuck-maven-plugin</artifactId>
            <version>0.9.7</version>
            <configuration>
                <call>trans -b :$CALL_LANG $TEXT_ESCAPED_QUOTED</call>
                <translations>
                    <translation>
                        <bundlePattern>./src/main/resources/generalText_$FILE_LANG.properties</bundlePattern>
                        <sourceLang>en:en</sourceLang>
                        <destLangs>de:de, zh:zh, es:es, ru:ru</destLangs>
                        <replaceExistingKeys>false</replaceExistingKeys>
                    </translation>
                </translations>
            </configuration>

            <executions>
            <execution><goals><goal>translate</goal></goals></execution>
            </executions>
        </plugin>
    </plugins>
</build>

The translations are generated via translate shell (because of the call “trans -b”), you will need to install translate shell yourself for this to work.

Keep Reading

PreviousNext