Run your own Raspberry Pi-based translation service with LibreTranslate

Being able to instantly translate words, phrases, and documents is an essential part of living online and offline in the 21st century. While Google Translate comes pre-installed on most Android phones, many people don’t want an intrusive advertising agency to know how many cervezas they’re ordering in a bar in Barcelona or the exact nature of their business in Aguascalientes.


With LibreTranslate, you can host your own translation service on a Raspberry Pi, making it easy to translate multiple languages ​​away from the eyes of overly interested tech giants.


Why not use Google Translate?

Google Translate on an Android phone

If you’re the type of person who already hosts a bunch of sites and services on a Raspberry Pi, you probably already have an answer for that. You’re trying to break away from big tech and develop a kind of digital autonomy without losing any of the functionality and ease that comes with living in a technologically advanced society.

It’s easy to accept the quality-of-life improvements offered by Google and other tech giants, and ignore the egregious privacy violations, data leaks, and learned dependence on an ecosystem you don’t. can be ejected at any time.

We recently covered Raspberry Pi self-hosting projects to replace common services, including:

Until recently, your options for translating words, phrases, and documents were limited, but now you can run your own Pi-based translation service, accessible from any device.

What is LibreTranslate?

LibreTranslate is a free and open-source machine translation API, which was released in 2020, with Raspberry Pi-compatible ARM64 images in December 2022. The project is completely self-hosted, with its translation engine powered by the open-source Argos library Translate, rather than Google or Azure.

If you run LibreTranslate on your Raspberry Pi, you can access the translations via dedicated FOSS apps or via a web interface accessible with any browser.

How to install LibreTranslate on your Raspberry Pi

LibreTranslate won’t run on any Raspberry Pi as it requires good processing power and the images are only available for ARM64, rather than earlier 32-bit versions. So make sure you have a Raspberry Pi 4B running a recent 64-bit operating system.

There are several ways to install LibreTranslate on your Raspberry Pi, but the easiest way is to use Docker Compose, as it allows you to easily manage the service, as well as pull and update when new images are released. published.

Log in to your Raspberry Pi using Secure Shell (SSH), then update all installed software:

 sudo apt update
sudo apt upgrade

If you do not have Docker and Docker Compose installed, you need to install them now. You will also need Git.

 sudo apt install git 

Make sure you are in your home directory, then clone the LibreTranslate GitHub repository:

 cd ~
git clone https:

Move to the new directory:

 cd LibreTranslate 

And then enter:

 docker-compose up -d  

Note: If you are already running a service through port 5000, you will need to change the docker-compose.yml case:

 nano docker-compose.yml 

…and define a new unused port.

Docker Compose will download Docker images and run scripts to configure your LibreTranslate containers. This process can take more than half an hour, so take the opportunity to clean up your workspace. When done, you will be returned to the command prompt.

Access LibreTranslate on your local network

LibreTranslate on the Raspberry Pi web interface

If you have not changed the port in your Docker Compose, the web interface of your LibreTranslate instance will be available on your local network at your.local.ip.address.pi.:5000and you can access it through your browser.

Write or paste your text in the left box and the translated output will appear in the right box. By default, the input language is English, but you can select from 29 languages ​​in the drop-down list, or even have LibreTranslate detect the language automatically. Supported languages ​​include Irish, Catalan, and Azerbaijani, as well as more common European and Asian languages.

Translation is done instantly as text is entered, meaning you don’t need to press Come back or press any other button. If the text you want to translate is in a file, click the Translate the file and click the turquoise upload button to choose your file. Supported file formats include .txt, .odt, .odp, .docx, .pptx, .epub, .html.

There are no limits to the size of the text to be translated, but you can easily set a character limit by changing your docker-compose.yml case.

Accessing LibreTranslate on the Internet

Chances are that when you desperately need translation software, you’ll be out in the world, away from your Raspberry Pi, and desperately trying to negotiate a taxi ride from the airport to your AirBnB.

The first thing to do is make sure you can access your Pi from outside your home network. Visit your router’s admin page (usually at 192.168.1.1) and find the Port management section. Create a new entry for HTTP requests.

Set the local and public port to 80, and the local IP address to your Raspberry Pi’s IP address. A second open port is required for HTTPS requests. Set the local and public port to 443and again, the local IP address to your Pi’s IP address.

Choose a domain name or subdomain name from a good domain registrar. From the registrar settings page, find the “Advanced DNS” options and add a new A registration. Put it on Host field to “@” and the value field to your personal IP address. Set the TTL (Time to Lease) value as low as possible, then save.

Back on the Pi, install Apache:

 sudo apt install apache2 

Start and activate Apache with the following commands:

 sudo systemctl start apache2
sudo systemctl enable apache2

Enable Apache proxy modules with:

 sudo a2enmod proxy
sudo a2enmod proxy_http

Now change directory and create a new configuration file:

 cd /etc/apache2/sites-available
sudo nano libretranslate.conf

In the new file, paste the following lines:

 <VirtualHost *:80>
ServerName your-domain-name.tld
ProxyPass / http:
ProxyPassReverse / http:/127.0.0.1:5000/
ProxyPreserveHost On
</VirtualHost>

Save and exit nano with Ctrl+O, then CTRL+Xand activate your new configuration file with:

 sudo a2ensite libretranslate.conf 

…and restart Apache.

 sudo service apache2 restart 

To ensure that your translations are encrypted in transit and not open to eavesdropping, you should use Certbot to retrieve encryption keys and security certificates. Install it with:

 sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt-get install python3-certbot-apache

Run Certbot:

 sudo certbot 

…and restart Apache.

 sudo service apache2 restart 

You can now access your LibreTranslate from any browser on https://your-domain-name.tld.

Access your LibreTranslate instance with an app

It’s easy to access your Pi-powered translator on the go. If you are an Android user, you can download LibreTranslator from the Google Play Store or of F-Droid. If you are using an iPhone, you can find LiTranslate on the App Store.

Open the app settings and enter your domain in the “Custom server URL” field. The text to be translated goes in the upper field and the translation appears at the bottom of the screen. That’s all we can say about it.

Get the most out of your Raspberry Pi Hosted Translator

With a huge range of language translations at your disposal, you can travel the world knowing you’ll be able to ask directions, order food and hold conversations with locals.

As you travel around the world, you can take photos and automatically upload them from your phone to a self-hosted Raspberry Pi PhotoPrism instance.

Comments are closed.