use of software.amazon.awssdk.services.translate.TranslateClient in project aws-doc-sdk-examples by awsdocs.
the class BatchTranslation method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <s3Uri> <s3UriOut> <jobName> <dataAccessRoleArn> \n\n" + "Where:\n" + " s3Uri - the URI of the Amazon S3 bucket where the documents to translate are located. \n" + " s3UriOut - the URI of the Amazon S3 bucket where the translated documents are saved to. \n" + " jobName - the job name. \n" + " dataAccessRoleArn - the Amazon Resource Name (ARN) value of the role required for translation jobs.\n";
if (args.length != 4) {
System.out.println(USAGE);
System.exit(1);
}
String s3Uri = args[0];
String s3UriOut = args[1];
String jobName = args[2];
String dataAccessRoleArn = args[3];
Region region = Region.US_WEST_2;
TranslateClient translateClient = TranslateClient.builder().region(region).build();
String id = translateDocuments(translateClient, s3Uri, s3UriOut, jobName, dataAccessRoleArn);
System.out.println("Translation job " + id + " is completed");
translateClient.close();
}
use of software.amazon.awssdk.services.translate.TranslateClient in project aws-doc-sdk-examples by awsdocs.
the class ListTextTranslationJobs method main.
public static void main(String[] args) {
Region region = Region.US_WEST_2;
TranslateClient translateClient = TranslateClient.builder().region(region).build();
getTranslationJobs(translateClient);
translateClient.close();
}
use of software.amazon.awssdk.services.translate.TranslateClient in project aws-doc-sdk-examples by awsdocs.
the class LexService method textTranslateToEn.
public String textTranslateToEn(String lanCode, String text) {
Region region = Region.US_EAST_1;
TranslateClient translateClient = TranslateClient.builder().credentialsProvider(EnvironmentVariableCredentialsProvider.create()).region(region).build();
try {
TranslateTextRequest textRequest = TranslateTextRequest.builder().sourceLanguageCode(lanCode).targetLanguageCode("en").text(text).build();
TranslateTextResponse textResponse = translateClient.translateText(textRequest);
return textResponse.translatedText();
} catch (TranslateException e) {
System.err.println(e.getMessage());
System.exit(1);
}
return "";
}
use of software.amazon.awssdk.services.translate.TranslateClient in project aws-doc-sdk-examples by awsdocs.
the class LexService method textTranslateFromEn.
public String textTranslateFromEn(String lanCode, String text) {
Region region = Region.US_EAST_1;
TranslateClient translateClient = TranslateClient.builder().credentialsProvider(EnvironmentVariableCredentialsProvider.create()).region(region).build();
try {
TranslateTextRequest textRequest = TranslateTextRequest.builder().sourceLanguageCode("en").targetLanguageCode(lanCode).text(text).build();
TranslateTextResponse textResponse = translateClient.translateText(textRequest);
return textResponse.translatedText();
} catch (TranslateException e) {
System.err.println(e.getMessage());
System.exit(1);
}
return "";
}
Aggregations