Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.07 KB

README.md

File metadata and controls

37 lines (29 loc) · 1.07 KB

Language Translator

Installation

Maven
<dependency>
  <groupId>com.ibm.watson</groupId>
  <artifactId>language-translator</artifactId>
  <version>8.0.1</version>
</dependency>
Gradle
'com.ibm.watson:language-translator:8.0.1'

Usage

Select a domain, then identify or select the language of text, and then translate the text from one supported language to another.
Example: Translate 'hello' from English to Spanish using the Language Translator service.

Authenticator authenticator = new IamAuthenticator("<iam_api_key>");
LanguageTranslator service = new LanguageTranslator("2018-05-01", authenticator);

TranslateOptions translateOptions = new TranslateOptions.Builder()
  .addText("hello")
  .source(Language.ENGLISH)
  .target(Language.SPANISH)
  .build();
TranslationResult translationResult = service.translate(translateOptions).execute().getResult();

System.out.println(translationResult);