Skip to main content

AI-powered code translator using Claude Sonnet 4.5's extended thinking

Project description

🌍 Polyglot - AI Code Translator

An AI-powered CLI tool that translates code between programming languages using Claude Sonnet 4.5's extended thinking capabilities.

Features

  • 🧠 Extended Thinking - See the AI's reasoning process as it translates
  • 🎨 Idiomatic Translation - Not just syntax conversion, but proper language idioms
  • Smart Optimization - Optimizes for target language best practices
  • 📊 Side-by-side Comparison - Visual diff of source and target
  • 🎯 12+ Languages - Python, Rust, Go, TypeScript, Java, C++, and more

Installation

Option 1: Install from PyPI (Recommended)

pip install polyglot-cli

# Set your API key
export ANTHROPIC_API_KEY='your-key-here'

Option 2: Install from source

git clone https://github.com/samar/polyglot-cli.git
cd polyglot-cli
pip install -e .

# Set your API key
export ANTHROPIC_API_KEY='your-key-here'

Option 3: Use pipx (Isolated installation)

pipx install polyglot-cli
export ANTHROPIC_API_KEY='your-key-here'

Usage

Translate a file

polyglot translate python rust --file example.py

Translate from stdin

echo 'def hello(): print("hi")' | polyglot translate python go

Save output

polyglot translate python rust --file example.py --output example.rs

Hide AI reasoning

polyglot translate python rust --file example.py --no-thinking

List supported languages

polyglot languages

Examples

Python → Rust

polyglot translate python rust --file example.py

The AI will:

  1. Show its thinking process (how it approaches the translation)
  2. Convert Python's dynamic types to Rust's static types
  3. Replace Python's dict cache with Rust's HashMap
  4. Use idiomatic Rust patterns
  5. Show side-by-side comparison

JavaScript → Go

polyglot translate javascript go --file api.js

Converts async/await to Go's goroutines and channels!

Why Polyglot?

This showcases Claude Sonnet 4.5's extended thinking - you can literally see the AI reasoning through:

  • Type system differences
  • Memory management patterns
  • Idiomatic conventions
  • Performance trade-offs

It's not just translating syntax, it's understanding and adapting code philosophy between languages!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polyglot_cli-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polyglot_cli-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file polyglot_cli-0.1.0.tar.gz.

File metadata

  • Download URL: polyglot_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for polyglot_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f889dad85ea80c647aab5cffe21963bb906212f98e40c2727c8532d2f8e7ec7
MD5 cad90fabe7260005140f5e90826e9ddc
BLAKE2b-256 e488985d1ee2b34cde2195118c2df50bbaa00bf68782d9fb799c1848b15333a3

See more details on using hashes here.

File details

Details for the file polyglot_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polyglot_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for polyglot_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4dae974da6e9cff70b06bbd4f0b0f1f01d09283563622b5c83757f73d9513f
MD5 7e2015c1a8abce8aade5c8461d936a08
BLAKE2b-256 53f359077528ca99c8293ceab7c1e4b79db3dc3b2d241cc6e02042d8a9e0596a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page