Simple Translator

Simple Translator Screenshot

Project Overview

This Simple Translator project is a Python-based application that provides reliable text translation between multiple languages. Built with both command-line and interactive modes, the application uses external translation APIs while implementing smart caching to improve performance and reduce unnecessary API calls.

Interactive Demo

Try the translator below by entering text and selecting your desired language:

Translate to:

Translated text will appear here.

Features

Multiple Languages

Support for over 100 languages using Google Translate's API.

Intelligent Caching

Stores previous translations to reduce API calls and improve performance.

Dual Interface

Both interactive mode and command-line support for flexible usage.

Save Translations

Option to save translation history to a text file for future reference.

Technical Implementation

The core of the translator is built around efficient API usage and caching:

# Translation function with caching for improved performance def translate_text(text, dest_language): # Check if translation is in cache if (text, dest_language) in cache: return cache[(text, dest_language)] translator = Translator() translated = translator.translate(text, dest=dest_language) # Store translation in cache cache[(text, dest_language)] = translated.text return translated.text

Welcome Screen

The app starts with a welcome screen where users can enter the text they want to translate and select the target language. The interface is designed to be straightforward and easy to use.

Welcome Screen

Translation

Once the user enters the text and selects the target language, the app uses a translation API to fetch the translated text and displays it on the screen. The app supports multiple languages.

Translation Screen

Key Features

How to Use

Interactive Mode:

  1. Launch the application with python Translator.py
  2. Enter the text you want to translate
  3. Select the target language from the menu
  4. View the translation and optionally save it to history

Command-Line Mode:

python Translator.py -t "Hello world" -d es # Translates "Hello world" to Spanish

The application's flexibility makes it useful for casual translations, language learning, and integration into other scripts or workflows.

Back to Projects