Search in sources :

Example 1 with TranslateTextResult

use of com.amazonaws.services.translate.model.TranslateTextResult in project aws-doc-sdk-examples by awsdocs.

the class App method main.

public static void main(String[] args) {
    // Create credentials using a provider chain. For more information, see
    // https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
    AWSCredentialsProvider awsCreds = DefaultAWSCredentialsProviderChain.getInstance();
    AWSTranslate translate = AmazonTranslateClient.standard().withCredentials(new AWSStaticCredentialsProvider(awsCreds)).withRegion(REGION).build();
    TranslateTextRequest request = new TranslateTextRequest().withText("Hello, world").withSourceLanguageCode("en").withTargetLanguageCode("es");
    TranslateTextResult result = translate.translateText(request);
    System.out.println(result.getTranslatedText());
}
Also used : AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) AWSTranslate(com.amazonaws.services.translate.AWSTranslate) TranslateTextRequest(com.amazonaws.services.translate.model.TranslateTextRequest) TranslateTextResult(com.amazonaws.services.translate.model.TranslateTextResult)

Aggregations

AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 AWSTranslate (com.amazonaws.services.translate.AWSTranslate)1 TranslateTextRequest (com.amazonaws.services.translate.model.TranslateTextRequest)1 TranslateTextResult (com.amazonaws.services.translate.model.TranslateTextResult)1