public class MicrosoftTranslator extends Object implements Translator
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ID |
static String |
DEFAULT_SECRET |
static String |
ID_PROPERTY |
static String |
PROPERTIES_FILE |
static String |
SECRET_PROPERTY |
Constructor and Description |
---|
MicrosoftTranslator()
Create a new MicrosoftTranslator with the client keys specified in
resources/org/apache/tika/language/translate/translator.microsoft.properties.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isAvailable()
Check whether this instance has a working property file and its keys are not the defaults.
|
void |
setId(String id)
Sets the client Id for the translator API.
|
void |
setSecret(String secret)
Sets the client secret for the translator API.
|
String |
translate(String text,
String targetLanguage)
Use the Microsoft service to translate the given text to the given target language.
|
String |
translate(String text,
String sourceLanguage,
String targetLanguage)
Use the Microsoft service to translate the given text from the given source language to the given target.
|
public static final String PROPERTIES_FILE
public static final String ID_PROPERTY
public static final String SECRET_PROPERTY
public static final String DEFAULT_ID
public static final String DEFAULT_SECRET
public MicrosoftTranslator()
public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException
translate
in interface Translator
text
- The text to translate.sourceLanguage
- The input text language (for example, "en").targetLanguage
- The desired language to translate to (for example, "fr").Exception
TikaException
- When there is an error translating.IOException
Translator
public String translate(String text, String targetLanguage) throws TikaException, IOException
translate
in interface Translator
text
- The text to translate.targetLanguage
- The desired language to translate to (for example, "hi").Exception
TikaException
- When there is an error translating.IOException
Translator
public boolean isAvailable()
isAvailable
in interface Translator
public void setId(String id)
id
- The ID to set.public void setSecret(String secret)
secret
- The secret to set.Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.