Class YandexTranslator
- java.lang.Object
- 
- org.apache.tika.language.translate.impl.YandexTranslator
 
- 
- All Implemented Interfaces:
- Translator
 
 public class YandexTranslator extends Object implements Translator An implementation of a REST client for the YANDEX Translate API. You can sign up for free access online on the API Key form and set your Application's User Key in thetranslator.yandex.propertiesfile.
- 
- 
Constructor SummaryConstructors Constructor Description YandexTranslator()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApiKey()Get the API Key in use for client authenticationStringgetFormat()Retrieve the current text format setting.booleanisAvailable()voidsetApiKey(String apiKey)Set the API Key for client authenticationvoidsetFormat(String format)Set the text format to use (plain/html)Stringtranslate(String text, String targetLanguage)Translate text to the given language This method attempts to auto-detect the source language of the text.Stringtranslate(String text, String sourceLanguage, String targetLanguage)Translate text between given languages.
 
- 
- 
- 
Method Detail- 
translatepublic String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException Description copied from interface:TranslatorTranslate text between given languages.- Specified by:
- translatein interface- Translator
- Parameters:
- text- The text to translate.
- sourceLanguage- The input text language (for example, "en").
- targetLanguage- The desired language to translate to (for example, "fr").
- Returns:
- The translation result. If translation is unavailable, returns the same text back.
- Throws:
- TikaException- When there is an error translating.
- IOException
 
 - 
getApiKeypublic String getApiKey() Get the API Key in use for client authentication- Returns:
- API Key
 
 - 
setApiKeypublic void setApiKey(String apiKey) Set the API Key for client authentication- Parameters:
- apiKey- API Key
 
 - 
getFormatpublic String getFormat() Retrieve the current text format setting. The Yandex Translate API can handle text in plain and/or html format, the default format is plain- Returns:
 
 - 
setFormatpublic void setFormat(String format) Set the text format to use (plain/html)- Parameters:
- format- Text format setting, either plain or html
 
 - 
translatepublic String translate(String text, String targetLanguage) throws TikaException, IOException Description copied from interface:TranslatorTranslate text to the given language This method attempts to auto-detect the source language of the text.- Specified by:
- translatein interface- Translator
- Parameters:
- text- The text to translate.
- targetLanguage- The desired language to translate to (for example, "hi").
- Returns:
- The translation result. If translation is unavailable, returns the same text back.
- Throws:
- TikaException- When there is an error translating.
- IOException
 
 - 
isAvailablepublic boolean isAvailable() - Specified by:
- isAvailablein interface- Translator
- Returns:
- true if this Translator is probably able to translate right now.
 
 
- 
 
-