Getting started (SDK) - Amazon Translate

Getting started (SDK)

AWS provides SDKs for various computer languages. The SDK manages many of the API connection details for your client, such as signature calculation, request retry handling, and error handling. For more information, see AWS SDKs.

The following examples demonstrate how to use Amazon Translate TranslateText operation using Java and Python. Use the SDKs to learn about the Amazon Translate API and as building blocks for your own applications.

Translating text using the AWS SDK for Java

AWS provides a GitHub example of how to use the TranslateText operation in Java. To run this example, you need the AWS SDK for Java. For instructions for installing the SDK for Java, see Set up the AWS SDK for Java 2.x.

Translating text using the AWS SDK for Python (Boto)

The following example shows how to use the TranslateText operation in Python. To run the example, install the Python SDK via the AWS CLI. For instructions, see Install and configure the AWS Command Line Interface (AWS CLI).

import boto3 translate = boto3.client(service_name='translate', region_name='region', use_ssl=True) result = translate.translate_text(Text="Hello, World", SourceLanguageCode="en", TargetLanguageCode="de") print('TranslatedText: ' + result.get('TranslatedText')) print('SourceLanguageCode: ' + result.get('SourceLanguageCode')) print('TargetLanguageCode: ' + result.get('TargetLanguageCode'))

For a list of supported language codes, see Supported languages and language codes

Other SDK examples

See Code examples for Amazon Translate using AWS SDKs for examples that use .NET and SAP ABAP.