This document describes how to create a translation service using AWS Services
Create an AWS Account
Go to https://aws.amazon.com/free/
Fill out the following form with your information
Part 1: Create an AWS Lambda

import json
import boto3
def lambda_handler(event, context):
# This creates the translation service client
# This lambda has permission to call this service because we allowed it in IAM
client = boto3.client(service_name='translate', region_name='us-west-2', use_ssl=True)
# We call the client with the text we want translated
# Pass the source and target language
# https://docs.aws.amazon.com/translate/latest/dg/what-is.html#what-is-languages
response = client.translate_text(
Text= "Hello",
SourceLanguageCode='en',
TargetLanguageCode='es'
)
print(json.dumps(response))
# Return the translated text in the response
return {
'statusCode': 200,
'body': json.dumps(response["TranslatedText"])
}
Part 2: Add Permissions for Lambda to Call Translation Service



Part 3: Create an API


Part 5: Get Input from API
import json
import boto3
def lambda_handler(event, context):
# This creates the translation service client
# This lambda has permission to call this service because we allowed it in IAM
client = boto3.client(service_name='translate', region_name='us-west-2', use_ssl=True)
# We call the client with the text we want translated
# Pass the source and target language
# https://docs.aws.amazon.com/translate/latest/dg/what-is.html#what-is-languages
response = client.translate_text(
Text= event["queryStringParameters"]["q"],
SourceLanguageCode='en',
TargetLanguageCode='es'
)
# Return the translated text in the response
return {
'statusCode': 200,
'body': json.dumps(response["TranslatedText"])
}
Test It!
https://YOUR_API.execute-api.us-west-2.amazonaws.com/?q=library