Skip to content

qatre-ai/CodeAlpha_LanguageTranslationTool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Language Translation Tool β€” AI-Powered Translation App

🌐 Language Translation Tool

AI-Powered Real-Time Translation with Text-to-Speech

An NLP Translation App built with FastAPI & React.js for the CodeAlpha AI Internship

FastAPI React TailwindCSS CodeAlpha Open Source License

πŸ”¨ Tech Stack Β· ✨ Features Β· πŸš€ Getting Started Β· πŸ“ Architecture Β· πŸ“Έ Screenshots Β· πŸ§‘β€πŸ’» Author


πŸ“– About

The Language Translation Tool is a production-ready, full-stack AI Translation App that delivers instant translations across 100+ languages β€” powered by Google Translate through the deep-translator Python library. Designed as Task 1 for the CodeAlpha AI Internship, this project demonstrates how to architect a clean FastAPI React project with a modern glassmorphism UI, real-time text-to-speech playback, and seamless language swapping.

Whether you're building an NLP translation app, exploring FastAPI backend patterns, or learning how to integrate the Web Speech API into a React frontend, this repository serves as a comprehensive, production-quality reference.

πŸ’‘ Zero API keys required β€” the deep-translator library connects to Google Translate directly, so you can clone and run the project immediately.


πŸ”¨ Tech Stack

Layer Technology Purpose
Backend Python FastAPI High-performance async API with Pydantic validation
Translation Engine deep-translator Google Translate integration β€” no API key needed
Frontend React Vite Lightning-fast HMR + component-driven UI
Styling Tailwind Utility-first CSS with glassmorphism design system
Icons Lucide Beautiful, consistent open-source icon set
Text-to-Speech Web Speech API Browser-native TTS β€” no external dependencies

✨ Features

🎯 Core Features

Feature Description
🌍 100+ Languages Dynamic language dropdowns populated from the backend β€” supports every language Google Translate offers
⚑ Instant Translation Real-time translation powered by deep-translator with GoogleTranslator β€” no API key required
πŸ”„ Swap Languages One-click language swap with a smooth 180Β° rotation animation β€” text content swaps too
🎨 Glassmorphism UI Stunning glass-effect design with backdrop-blur, translucent panels, and a deep purple gradient
πŸ“± Fully Responsive Split-screen on desktop, stacked on mobile β€” works beautifully on every screen size

πŸš€ Bonus Features

Feature Description
πŸ”Š Text-to-Speech Listen to both source and translated text via the browser's native Web Speech API with auto voice matching
πŸ“‹ Copy to Clipboard One-click copy of the translated text with a checkmark icon confirmation that auto-resets after 2 seconds
⌨️ Ctrl + Enter Shortcut Press Ctrl + Enter (or ⌘ + Enter on Mac) in the textarea for instant translation
πŸ”’ Character Counter Live character count with color-coded warnings (amber at 4,500+, red at 5,000 limit)
⚠️ Smart Validation Subtle amber warning when translating empty text β€” no intrusive popups
πŸ”„ Loading States Animated pulsing spinner with "Translating..." text during API calls
πŸ›‘οΈ Error Handling Graceful error display for network failures, same-language guards, and backend unavailability

πŸš€ Getting Started

Prerequisites

Make sure you have the following installed on your system:

1️⃣ Clone the Repository

git clone https://github.com/qatre-ai/language-translation-tool.git
cd language-translation-tool

2️⃣ Set Up the Backend (FastAPI)

# Navigate to the backend directory
cd backend

# Create a virtual environment (recommended)
python -m venv venv

# Activate the virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate

# Install Python dependencies
pip install -r requirements.txt

# Start the FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

The backend API will be available at http://localhost:8000

πŸ“– Interactive API docs available at http://localhost:8000/docs (Swagger UI)

3️⃣ Set Up the Frontend (React + Vite)

Open a new terminal and run:

# Navigate to the frontend directory
cd frontend

# Install Node.js dependencies
npm install

# Start the Vite development server
npm run dev

The app will open at http://localhost:5173 β€” the Vite dev server automatically proxies /api/* requests to the FastAPI backend.

4️⃣ Start Translating! πŸŽ‰

  1. Type or paste text in the Source panel
  2. Select your source and target languages from the dropdowns
  3. Click Translate or press Ctrl + Enter
  4. Use πŸ”Š to listen, πŸ“‹ to copy, and πŸ”„ to swap languages

πŸ“ Project Architecture

language-translation-tool/
β”œβ”€β”€ πŸ“‚ backend/                    # FastAPI Python backend
β”‚   β”œβ”€β”€ πŸ“„ requirements.txt        # Python dependencies
β”‚   └── πŸ“‚ app/
β”‚       β”œβ”€β”€ πŸ“„ __init__.py
β”‚       β”œβ”€β”€ πŸ“„ main.py             # FastAPI app + CORS + health check
β”‚       β”œβ”€β”€ πŸ“„ models.py           # Pydantic request/response schemas
β”‚       └── πŸ“„ routes.py           # /api/translate + /api/languages
β”‚
β”œβ”€β”€ πŸ“‚ frontend/                   # React + Vite frontend
β”‚   β”œβ”€β”€ πŸ“„ index.html              # HTML shell
β”‚   β”œβ”€β”€ πŸ“„ vite.config.js          # Vite + Tailwind + API proxy
β”‚   β”œβ”€β”€ πŸ“„ package.json            # Node.js dependencies
β”‚   └── πŸ“‚ src/
β”‚       β”œβ”€β”€ πŸ“„ main.jsx            # React entry point
β”‚       β”œβ”€β”€ πŸ“„ index.css           # Tailwind v4 import
β”‚       β”œβ”€β”€ πŸ“„ App.jsx             # Root layout + TTS voice preload
β”‚       β”œβ”€β”€ πŸ“„ App.css             # Custom animations
β”‚       β”œβ”€β”€ πŸ“‚ components/
β”‚       β”‚   β”œβ”€β”€ πŸ“„ TranslationForm.jsx   # Main orchestrator component
β”‚       β”‚   β”œβ”€β”€ πŸ“„ LanguageSelector.jsx  # Dynamic language dropdown
β”‚       β”‚   β”œβ”€β”€ πŸ“„ TextPanel.jsx         # Source/Target split panel
β”‚       β”‚   └── πŸ“„ LoadingSpinner.jsx    # Animated loading indicator
β”‚       └── πŸ“‚ services/
β”‚           β”œβ”€β”€ πŸ“„ api.js          # API service (fetch, translate, cache)
β”‚           └── πŸ“„ tts.js          # Web Speech API wrapper
β”‚
└── πŸ“„ README.md                   # You are here! ✨

πŸ”Œ API Endpoints

Method Endpoint Description
GET / Health check β€” returns API status and version
GET /api/languages Returns all supported languages as {code: name} dictionary
POST /api/translate Translates text β€” accepts {text, source_lang, target_lang}
GET /docs Interactive Swagger UI documentation
GET /redoc ReDoc API documentation

Example API Request

curl -X POST http://localhost:8000/api/translate \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, world!", "source_lang": "en", "target_lang": "es"}'

Example API Response

{
  "translated_text": "Β‘Hola, mundo!",
  "source_lang": "en",
  "target_lang": "es",
  "original_text": "Hello, world!"
}

πŸ“Έ Screenshots

πŸ–ΌοΈ Add your screenshots here! Replace the placeholders below with actual images.

Split-Screen Layout Mobile Responsive
Desktop View Mobile View
Swap Animation Copy Confirmation
Swap Demo Copy Demo

🎨 Design System

This AI Translation Tool uses a carefully crafted glassmorphism design system built on Tailwind CSS v4:

Element Style
Background Deep gradient: from-indigo-950 via-purple-950 to-slate-900
Glass Panels bg-white/5 backdrop-blur-md border border-white/10
Primary Button Gradient: from-violet-600 to-fuchsia-600 with glow shadow
Accent Colors Violet β†’ Fuchsia β†’ Pink gradient spectrum
Animations Custom spin-180, pulse-ring, fade-in-up keyframes
Typography Gradient text headers with bg-clip-text text-transparent

🀝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow the existing code style.


πŸ“œ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgments

  • CodeAlpha β€” For the incredible AI Internship opportunity and the structured learning path that made this project possible. The internship program provides hands-on experience in AI and software engineering, and I'm grateful for the mentorship and community support.
  • deep-translator β€” For providing a free, no-API-key-required translation library that makes building NLP translation apps accessible to everyone.
  • FastAPI β€” For the elegant, high-performance Python web framework.
  • React & Vite β€” For the blazing-fast frontend developer experience.
  • Tailwind CSS β€” For making beautiful UIs achievable with utility classes.

πŸ§‘β€πŸ’» Crafted by

Meraj Basiri

Meraj Basiri

AI Engineer Β· Open Source Enthusiast Β· CodeAlpha AI Intern

GitHub LinkedIn Organization


πŸ’œ If this project helped you, consider giving it a ⭐ β€” it means a lot!

⬆ Back to Top

About

AI-powered translation tool with TTS support | CodeAlpha Internship Task 1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors