In this Demo, we will:-
1. Set up S3 buckets for source and translated documents
2. Create IAM roles and policies for Amazon Translate
3. Configure Amazon Translate for real-time translation
4. Set up batch translation jobs
5. Create a Lambda function for automated translation triggers
6. Test both real-time and batch translation scenarios
7. Monitor translation jobs and review results
8. Clean up resources
translate-demo-source-183101
translate-demo-output-183101
input-documents
processed
Global Supply Chain Management
Our company specializes in international logistics and supply chain optimization.
We provide end-to-end solutions including inventory management,
transportation coordination, and customs clearance services across 50+ countries.
Financial Services Overview
We offer comprehensive financial solutions including corporate banking,
investment advisory, risk management, and regulatory compliance support.
Our team of certified professionals ensures your business meets all
international financial standards.
Technology Innovation Hub
Join our innovation center where cutting-edge technology meets practical business solutions.
We specialize in artificial intelligence, machine learning, cloud computing,
and digital transformation strategies.
AWSLambdaBasicExecutionRole
TranslateFullAccess
AmazonS3FullAccess
TranslateLambdaRole
Welcome to our global business platform.
We provide comprehensive solutions for international commerce,
including multi-language support, currency conversion,
and cross-border logistics management.
demo-batch-translation-job
Demo
AutoTranslateFunction
import json
import boto3
import urllib.parse
from datetime import datetime
def lambda_handler(event, context):
# Initialize AWS clients
translate_client = boto3.client('translate')
s3_client = boto3.client('s3')
# Parse S3 event
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = urllib.parse.unquote_plus(record['s3']['object']['key'])
try:
# Read the uploaded file
response = s3_client.get_object(Bucket=bucket, Key=key)
file_content = response['Body'].read().decode('utf-8')
# Translate the content
translation_response = translate_client.translate_text(
Text=file_content,
SourceLanguageCode='auto',
TargetLanguageCode='es' # Spanish
)
translated_text = translation_response['TranslatedText']
source_language = translation_response['SourceLanguageCode']
# Create output filename
output_key = f"translated/{key.split('/')[-1]}_translated_to_spanish.txt"
# Save translated content to output bucket
output_bucket = 'translate-demo-output-183101' # Replace with your actual output bucket name
s3_client.put_object(
Bucket=output_bucket,
Key=output_key,
Body=translated_text,
ContentType='text/plain'
)
# Log successful translation
print(f"Successfully translated {key} from {source_language} to Spanish")
return {
'statusCode': 200,
'body': json.dumps({
'message': 'Translation completed successfully',
'source_file': key,
'output_file': output_key,
'source_language': source_language
})
}
except Exception as e:
print(f"Error processing {key}: {str(e)}")
return {
'statusCode': 500,
'body': json.dumps({
'error': str(e),
'source_file': key
})
}
Translate
Translate
confirm