Skip to content

tbarker/TranslateTask

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 

Google Translate Task

A simple ant task and runnable JAR for translating Java property files using Google Translate. Just run ant dist to get started.

You'll need a Google Translate API key from the Google API Console.

Remember that machine translated text is rarely "quite right", so you should flag this up to your user. (And give Google Translate credit as per their T&Cs.) Translate Task can add a magic property to generated output to distinguish it.

Usage

<taskdef name="translate" classname="com.thomasbarker.translatetask.ant.TranslateTask" classpath="dist/translate-task.jar" />
<translate from="en" to="de" key="${translate.googleapikey}"
    dest="test" targetEncoding="XML" magicProperty="magic.autotranslate">
    <fileset dir="test">
        <include name="**/test.properties" />
    </fileset>
</translate>

Alternatively...

$ java -jar translate-task.jar -h
usage: translate-tool
 -e,--encoding <arg>                Output encoding, either ASCII or XML.
 -f,--sourcePropsFile <arg>         Source properties files
 -h                                 Print this message
 -k,--googleApiKey <arg>            Google Translate API Key
 -m,--magicProperty <arg>           Magic property key to mark
                                    autotranslated output
 -o,--targetPropsDir <arg>          Target director for output files
 -s,--sourceLanguage <ISO 639-1>    Source langauge
    --skipped <ISO 639-1>           Skip languages
 -t,--targetLanguages <ISO 639-1>   Target languages.  Omit to translate

Future Work

  • Handle GNUText PO file
  • Rotating Google API keys (slightly evil)
  • Multiple source languages
  • Translate static content

About

Simple ant task to automatically translate Java properties files using the Google Translate API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages