com.memetix.mst.translate
Class Translate

java.lang.Object
  extended by com.memetix.mst.MicrosoftTranslatorAPI
      extended by com.memetix.mst.translate.Translate

public final class Translate
extends MicrosoftTranslatorAPI

Translate Makes calls to the Microsoft Translator API /Translate service Uses the AJAX Interface V2 - see: http://msdn.microsoft.com/en-us/library/ff512406.aspx

Author:
Jonathan Griggs

Field Summary
 
Fields inherited from class com.memetix.mst.MicrosoftTranslatorAPI
apiKey, ENCODING, PARAM_APP_ID, PARAM_FROM_LANG, PARAM_LANGUAGE_CODES, PARAM_LOCALE, PARAM_SENTENCES_LANGUAGE, PARAM_SPOKEN_LANGUAGE, PARAM_TEXT_ARRAY, PARAM_TEXT_SINGLE, PARAM_TO_LANG
 
Method Summary
static String[] execute(String[] texts, Language to)
          Translates an array of texts from an Automatically detected language to another given Language using Microsoft Translator's TranslateArray service Note that the Microsoft Translator expects all source texts to be of the SAME language.
static String[] execute(String[] texts, Language from, Language to)
          Translates an array of texts from a given Language to another given Language using Microsoft Translator's TranslateArray service Note that the Microsoft Translator expects all source texts to be of the SAME language.
static String execute(String text, Language to)
          Translates text from a given Language to another given Language using Microsoft Translator.
static String execute(String text, Language from, Language to)
          Translates text from a given Language to another given Language using Microsoft Translator.
 
Methods inherited from class com.memetix.mst.MicrosoftTranslatorAPI
buildStringArrayParam, getToken, retrieveIntArray, retrieveString, retrieveStringArr, retrieveStringArr, setClientId, setClientSecret, setContentType, setHttpReferrer, setKey, validateServiceState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

execute

public static String execute(String text,
                             Language from,
                             Language to)
                      throws Exception
Translates text from a given Language to another given Language using Microsoft Translator.

Parameters:
text - The String to translate.
from - The language code to translate from.
to - The language code to translate to.
Returns:
The translated String.
Throws:
Exception - on error.

execute

public static String execute(String text,
                             Language to)
                      throws Exception
Translates text from a given Language to another given Language using Microsoft Translator. Default the from to AUTO_DETECT

Parameters:
text - The String to translate.
to - The language code to translate to.
Returns:
The translated String.
Throws:
Exception - on error.

execute

public static String[] execute(String[] texts,
                               Language from,
                               Language to)
                        throws Exception
Translates an array of texts from a given Language to another given Language using Microsoft Translator's TranslateArray service Note that the Microsoft Translator expects all source texts to be of the SAME language.

Parameters:
texts - The Strings Array to translate.
from - The language code to translate from.
to - The language code to translate to.
Returns:
The translated Strings Array[].
Throws:
Exception - on error.

execute

public static String[] execute(String[] texts,
                               Language to)
                        throws Exception
Translates an array of texts from an Automatically detected language to another given Language using Microsoft Translator's TranslateArray service Note that the Microsoft Translator expects all source texts to be of the SAME language. This is an overloaded convenience method that passes Language.AUTO_DETECT as fromLang to execute(texts[],fromLang,toLang)

Parameters:
texts - The Strings Array to translate.
from - The language code to translate from.
to - The language code to translate to.
Returns:
The translated Strings Array[].
Throws:
Exception - on error.


Copyright © 2012. All Rights Reserved.