Skip to content
ludup edited this page Feb 8, 2014 · 8 revisions

Welcome to the google-translate-v2-java-maven-plugin wiki!

This provides a plugin for maven 3 projects to automatically translate Java resource files against the Google Translate V2 API. The plugin uses a cache so that only new or changed texts are translated, ensuring your don't run up a large API bill.

The plugin is build and maintained by the developers at Nervepoint Technologies; contributions, feedback and comments are always welcome.

Quickstart

Define the plugin in your pom's build configuration and tie it to the process-resources phase.

<build>
   <plugins>
      <plugin>
         <groupId>com.nervepoint</groupId>
	 <artifactId>google-translate-v2-java-maven-plugin</artifactId>
	 <executions>
	    <execution>
	       <phase>process-resources</phase>
	       <goals>
	          <goal>translate</goal>
	       </goals>
	    </execution>
	</executions>
     </plugin>
   </plugins>
</build>

Add the plugin to your pluginManagement section and define its global configuration.

<pluginManagement>
   <plugins>
      <plugin>
	<groupId>com.nervepoint</groupId>
	<artifactId>google-translate-v2-java-maven-plugin</artifactId>
	<version>0.0.2-SNAPSHOT</version>
	<configuration>
           <apikey>${yourAPIKey}</apikey>
           <cacheTag>${yourTag}</cacheTag>      
           <sourceDirectory>${basedir}/src/main/resources/i18n</sourceDirectory>
           <recurse>true</recurse>
           <targetDirectory>${basedir}/target/classes/i18n</targetDirectory>    
           <sourceLanguage>en</sourceLanguage>
           <languages>da,nl,fi,fr,de,it,no,pl,ru,sv,es,ja</languages>
           <failOnMissingSourceDir>false</failOnMissingSourceDir>
           <failOnMissingCacheDir>true</failOnMissingCacheDir>
	</configuration>
	<executions>
	   <execution>
	      <goals>
                 <goal>translate</goal>
	      </goals>
	   </execution>
	</executions>
      </plugin>
   </plugins>
</pluginManagement>

Source Directory

Scans this directory for any .properties files, will recurse into subfolders if the recurse configuration is set to true.

Cache Location

By default the cache root is located at:

${user.home}/.i18n_cache/${project.groupId}/${cacheTag}

Within the cache root, each maven project will store its own cache under its artifact id.

${cacheTag} is defined in your plugin configuration and allows you to define multiple caches for different branches of the same artifact.

Fail on missing cache

This option is very useful if you have a large project and the is no cache defined, when new workspaces are created you can copy your cache to prevent duplicate lookups and increased bills. Setting this option will ensure that a translation will not be performed without the cache directory present.

Clone this wiki locally