AWS Builder Center
Building a DeepL CLI Translator in Minutes with Amazon Q Developer

Building a DeepL CLI Translator in Minutes with Amazon Q Developer

Here's how I built a minimal DeepL-powered CLI translator in under 10 minutes with Amazon Q Developer doing most of the heavy lifting.

As developers, we spend most of our time in the terminal. Switching to a browser just to translate a string, an error message, or a snippet of documentation breaks the flow. I wanted something simpler:
Type a command, get a translation, move on.

The Problem

I work across teams in multiple countries. Slack messages in Spanish, error logs in Portuguese, documentation in English. Copy-pasting into Google Translate works, but it's friction. What I really
wanted was:
 
1
2
python3 translate.py "Bonjour le monde" ES
[FR → ES] Hola, mundo
 
The Stack
•  DeepL API : far superior translation quality vs Google Translate, especially for Spanish, Portuguese, and French. The Developer plan gives 1M characters/month free.
•  Python deepl SDK : official client, minimal setup
• python-dotenv: keeps the API key out of the code
• Amazon Q Developer: the actual builder

The Process

I opened my terminal, ran q chat, and then I just started to describe what I wanted:
 
Amazon Q generated the full script in one shot:
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env python3
import sys, os, deepl
from dotenv import load_dotenv
load_dotenv(os.path.join(os.path.dirname(file), ".env"))
args = sys.argv[1:]
if not args:
sys.exit("Usage: translate.py <text> [target_lang] [source_lang]")
text = args[0]
target = args[1] if len(args) > 1 else "EN-US"
source = args[2] if len(args) > 2 else None
result = deepl.Translator(os.environ["DEEPL_API_KEY"]).translate_text(
text, target_lang=target, source_lang=source
)
print(f"[{result.detected_source_lang} → {target}] {result.text}")
 
It also:
• Created the .env credentials file
• Created requirements.txt
• Ran the install and tested it immediately
• Generated a full README with usage examples and a language code reference table
The entire session, from "I have a DeepL subscription" to a working, documented tool, took about 10 minutes.
 

Why This Is Useful for CLI Developers

• Zero context switching: translate without leaving the terminal
• Auto language detection: no need to specify the source language
• Scriptable: pipe it into other commands, use it in shell scripts, wrap it in a Makefile target
• Lightweight: 15 lines of code, two dependencies

Some practical uses:

For this sample use that I did to the command line tool I created with Amazon Q, I've set the relative path where the executor of the script into my .bashrcfile, then I passed the phrase that I wanted to translate as an argument to the script.
 

The Role of Amazon Q Developer

What stood out wasn't just that Q wrote the code, it's that it understood the full context of what I was doing. It knew I had a DeepL subscription (from earlier in our conversation), suggested storing
credentials in .env, ran the tests itself, and iterated when something didn't work (like finding the right Composer URL across multiple GCP environments we were debugging earlier in the same session).
 
It behaves less like an autocomplete tool and more like a pair programmer that remembers what you're working on.

Get Started

Get a free DeepL API key, the Developer plan is free up to 500K characters/month (no credit card required for the free tier).
You can contribute, fork and clone for free this command line tool from my GitHub repo 
Built with Amazon Q Developer CLI (q chat) — available as part of the AWS Toolkit.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article