Hello everyone, today I’d like to share a free and open-source machine translation project called LibreTranslate, which provides users with a completely free and secure translation solution.
Project Overview
LibreTranslate uses neural translation technology with open-source language models to translate text without relying on external services. The project is primarily written in Python and is licensed under the GNU Affero General Public License v3.
Key Features
-
Self-Hosted Translation API
Users can deploy the translation service on their own servers or local environments, eliminating the need for proprietary service providers like Google or Azure. This ensures data security and privacy, with full customization options available for development as per the user’s needs. -
Offline Translation
LibreTranslate supports offline use, which is especially valuable in scenarios with unstable internet access or stringent data privacy requirements. Whether it’s for internal enterprise networks, remote areas, or sensitive document translations, users can still perform translations. -
Multilingual Support
The project supports a wide range of languages, allowing users to detect and translate between major world languages such as English, Chinese, French, German, Spanish, and more via API requests. -
Format Support
In addition to plain text translation, LibreTranslate also supports HTML text translation (currently in testing). This feature is highly useful for web content translation, as it directly translates text from web pages without needing to extract the text from HTML code beforehand.
Technical Implementation
-
Translation Engine
The engine is built on the open-source Argos Translate library , which relies on the OpenNMT framework to perform the translation. OpenNMT is a well-known open-source neural machine translation framework that delivers high-quality translation results. -
Model Management
Translation models are packaged into.argosmodel
files for easy installation and management. Users can select different models according to their needs or retrain and optimize existing models to improve translation accuracy and efficiency.
Use Cases
-
Software Development
Developers can integrate LibreTranslate into their applications to provide translation functions. This is useful for multilingual chat apps, cross-border e-commerce platforms, international office software, and other scenarios where language exchange is crucial. -
Academic Research
Researchers can use LibreTranslate as a tool to improve and optimize machine translation algorithms. Its open-source nature allows for deep analysis of the translation process, supporting the theoretical advancement of machine translation technology. -
Localization Services
Companies or organizations can use LibreTranslate to provide localization for their products or services, translating user interfaces, documentation, marketing materials, etc., into various languages, enhancing product competitiveness and user experience.
Installation and Usage
Installation
-
Via pip (For Simple Deployment)
To install LibreTranslate, check the Python version by running:python3 --version
Then, install and run LibreTranslate with the following commands:
pip install libretranslate libretranslate
The default service will listen on
http://localhost:5000
. To change the port or enable SSL, use the following options:libretranslate --host 0.0.0.0 --port 8080
-
Via Docker
Ensure that Docker and Docker Compose are installed on your system.Clone the LibreTranslate repository:
git clone https://github.com/LibreTranslate/LibreTranslate.git
Navigate to the project directory and use Docker Compose to start the service:
cd LibreTranslate docker-compose up -d
For GPU acceleration using CUDA, ensure NVIDIA Docker is installed and use the
docker-compose.cuda.yml
file instead of the default one.
Usage
-
Access the Service
Open your browser and navigate to the LibreTranslate service URL (e.g.,http://localhost:5000
or your custom address) to access the web interface. -
Text Translation
In the LibreTranslate web interface, you can input text for translation. After selecting the source and target languages, click the "Translate" button to get the result. -
File Translation
LibreTranslate also supports file translation. You can upload files for translation and set the source and target languages. After translation, you can download the translated file. -
API Documentation
API documentation is available in the web interface's top right corner. It details the various endpoints and usage examples, allowing developers to integrate and call the translation service easily.
For more details, refer to the online API documentation .