Class GoogleTranslateService
- java.lang.Object
-
- org.javlo.service.google.translation.GoogleTranslateService
-
- All Implemented Interfaces:
ITranslator
public class GoogleTranslateService extends Object implements ITranslator
-
-
Field Summary
-
Fields inherited from interface org.javlo.service.google.translation.ITranslator
ERROR_PREFIX
-
-
Constructor Summary
Constructors Constructor Description GoogleTranslateService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ITranslator
getTranslator()
static String
translate(String sourceText, String sourceLang, String targetLang, String apiKey)
Translate the source text from source to target language.String
translate(ContentContext ctx, String text, String sourceLang, String targetLang)
-
-
-
Method Detail
-
translate
public static String translate(String sourceText, String sourceLang, String targetLang, String apiKey) throws Exception
Translate the source text from source to target language.- Parameters:
sourceText
- source text to be translatedsourceLang
- source language of the texttargetLang
- target language of translated text- Throws:
Exception
-
getTranslator
public static final ITranslator getTranslator()
-
translate
public String translate(ContentContext ctx, String text, String sourceLang, String targetLang)
- Specified by:
translate
in interfaceITranslator
-
-