Skip to end of metadata
Go to start of metadata

Description

FastTranslate is a service that translates between human languages. And it is fast. Very fast. It's backed by the Google Translate service, and supports all the languages that they do. Unlike Google Translate (or the Java API for it), tranlation requests are not restricted in size. Want to translate several pages of text? Go for it. It'll be fast. Very fast.

Why so fast? FastTranslate is backed by GParallelize or GPars, so requests to the Google servers are batched and parallelized. Gotta embrace that multi-core revolution.

Requirements

FastTranslate requires two things:

  • An Internet connection - Google Translate is a web service and must be reached.
  • The GParallelize Plugin - FastTranslate is not bundled with the GPars/GParallelizer plugin. You'll need to install it yourself. Currently, version 0.3 is the best one to install. 

Installation

The current version of FastTranslate is 0.2
To install just issue the following commands:

API

org.fasttranslate.TranslationService

String

translate(String text, String lang1, String lang2)

Translates the specified text from one language to another.
text - the text to translate
lang1 - the language to translate from
lang2 - the language to translate to
Returns: the translated text

void

translate(List<Map> translationRequests)

Provides service to translate several pieces of text in several languages.
The parameter is a list of Map in the form:

[ [text: 'text to translate...', from: 'language', to: 'language', then: { result -> do something with result...}],
[ [text: 'other to translate...', from: 'language', to: 'language', then: { result -> do something else with result...}] ]

The 'text' key specifies the text to translate.
The 'from' key specifes the langauge to translate from.
The 'to' key specifies the langauge to translate to.
The 'then' key is a closure that will receive the result of the translation.

This allows you to translate several blocks of text in several lanuages in parallel.
There is no guarantee which order the result closures will be called.

void

translate(String text, List<Map> requests)

Provides service to translate a piece of text into several languages.
The 1st parameter is the text that will be translated.  
The 2nd parameter is a list of Map in the form:

[ [from: 'language', to: 'language', then: { result -> do something with result...}],
[ [from: 'language', to: 'language', then: { result -> do something else with result...}] ]

The 'from' key specifes the langauge to translate from.
The 'to' key specifies the langauge to translate to.
The 'then' key is a closure that will receive the result of the translation.

This allows you to translate several blocks of text in several lanuages in parallel.
There is no guarantee which order the result closures will be called.

List<String>

getLanguages()

Gets a list of all supported languages.
Returns: a String list of all supported languages

Usage

Example

The FastTranslate plugin is used by the open source easy-translate application: http://code.google.com/p/easy-translate/ 

  • No labels