google-api-translate-java-maven-plugin
I recently joined as a contributor to the open source “google-api-translate-java-maven-plugin” project. This project provides a Maven Mojo/Plug-in that will perform automated language translations for your Java resource property files using the Google Translation API.
To aid the development process, it is helpful to see your application running in other languages so that you can see where resource string may have been missed and where text positioning, sizing, and alignment issues show up. I personally feel that it is helpful to have this early on in the project development cycle long before the resource property files are ready to be sent out of house for proper translation. So how can I get my property files translated and add that as an automated step in my lifecycle management or build process? … Enter “google-api-translate-java-maven-plugin“. This Maven plugin can be pointed at a source language file and can be configured for all the desired languages to generate, as long as it is a supported language by the Google Language API.
While this plugin certainly worked to meet my needs out of the box, there were a few features that I wanted to expose to provide greater flexibility and control over the translation process. I added the following features as Version 1.3:
- console progress display to show the current translation cycle status
- overriding source properties file name
- output file encoding options
- exclusion list of named properties to exclude from generated output files
- comment header for generated output files
- smart-sync feature to limit translation effort to only added and changed properties
- pass-thru list of named properties to include in the generated output files, but not translate
For a complete detailed listing of these features and their configuration properties, please visit this Wiki article on the project’s Google Code site: New_Features_Version_1_3
Here is an example of a Maven project POM file configured to use these options: UTF-8 Sample Project POM
The feature that I am most proud of is the Smart Sync feature. Rather than performing translations on all property values for all generated output property files in all languages, I wanted a way to only perform the translation work on property values that have been added or updated and remove any properties form the output files that were removed from the source language property file. This feature greatly reduces the amount of time it take to run this plugin since it is really only calling out to the Google API for additions and updates. Before this feature it was taking in excess of 30-45 minutes to run through and perform the automated translations, and this length of time made it prohibitive to include this step in the regular build process. With this feature enabled, it can take as little as 5 seconds
One other notable feature is the support for saving the output generated property files with alternate file encodings such as UTF-8 and the option to include byte-order-mark (BOM) bytes at the beginning of the file. While the default Java Properties reader and writer cannot make use of this, there are other property file implementation such as the one in the Spring Framework that can make use of UTF-8 or UTF-16 encoded files. With the files encoded in UTF-8, we can see Japanese, Chinese, Russian, and Arabic character sets in the property file editor and all of the bytes that make of these characters do not have to be escaped making for an unreadable property file.
For more information an examples on how to use this Maven plugin, please visit the project Google Code site: “google-api-translate-java-maven-plugin“



