Offline text translation with Firefox

Foreign Language Skills

© Lead Image © wirestock, 123RF.com

© Lead Image © wirestock, 123RF.com

Article from Issue 286/2024
Author(s):

While all popular web browsers offer an online translation function, Mozilla Firefox lets you translate your texts offline while protecting your privacy.

Having foreign language text automatically translated in your web browser at the push of a button is an indispensable function that many users rely on every day. Virtually nobody seems to think about the fact that a service provider is translating the foreign language content into the desired target language. Although this does not incur any direct costs, this translation feature still comes at a price: The service providers analyze the translated data and then use the information for commercial purposes and profiling. Native Linux translation programs such as LibreTranslate [1] work in an offline mode, which means that they do not spy on your personal data. However, you have to install them and in some cases compile them from the source code.

Starting with version 118 released in September 2023, the free Firefox web browser and its derivatives include a translation function that can also be used offline. You can enable this translation function with just a few mouse clicks. Developed as part of the Bergamot project funded by the European Union at a cost just south of EUR3 million, Firefox Translations is based on various language models and is constantly being improved.

The developers have implemented the Firefox Translations function in Firefox in a similar way to the popular search engine operators. Two framed text segments appear next to each other in a separate tab in the browser window. You insert the text to be translated on the left, and the translated text appears on the right. Appropriate selection fields let users define the source and target languages.

Google, Microsoft, and others provide translation services that send the text entered in the left-hand panel to servers that they operate. When the text reaches the servers, it is not only translated, but also evaluated for further use in a totally nontransparent way. In contrast to this, Firefox Translator downloads a language model in the target language when translating for the first time. This is used for translation moving forward, and it operates completely without an Internet connection.

The Bergamot Project

The Bergamot project [2] is a collaboration between the University of Edinburgh, University of Sheffield, Charles University in Prague, the University of Tartu, and Mozilla. With the objective of developing translation tools that work with neural networks, these networks ultimately have enabled Mozilla to create an exclusively local extension for translating web pages in Firefox.

As a prerequisite, the entire infrastructure, including both the language models and the translation algorithms, must be capable of offline use without any restrictions. One particular challenge during development was efficiently programing the software so that it runs quickly on standard PC CPUs and does not require a dedicated GPU, as is often the case with deep learning solutions. Mozilla has also invited the user community to train the language models; it has set up a dedicated GitHub page [3] for this purpose. As a result, the existing language models are constantly being improved and new languages are also regularly being added to Firefox Translations.

Well-Kept Secret

Firefox's translation module can be used in various ways. The developers have hidden the interface in the browser. To enable Firefox Translations, you first need to open the web browser's configuration dialog by typing about:config in the address bar. After confirming the warning message, you will see an input line where you can enter the desired configuration option, translations in this case. The interface lists all the options it finds while you type. Find the browser.translations.enable line and change the value displayed in the middle from false to true by clicking on the small button with the two arrows on the right. You have now enabled the translation interface (Figure 1).

Figure 1: In Firefox and its derivatives, you only need to change one setting in the manual configuration to enable the translation feature.

If you then open a new tab in the web browser and enter about:translations in the URL input bar, the application opens the conventional interface for translating text. You can use the two selection boxes above the source and target text input boxes to choose the languages. By default, Firefox automatically detects the source language.

Once you have added some text in the source input box on the left, you can specify one of the supported languages in Select language on the right. When using Firefox Translations for the first time, it can take some time for the translated text to appear on the right. Firefox first downloads the language model available for the target language and then translates the source text (Figure 2). If you want to configure the source language manually, you can specify it in the selection box above the left-hand window pane.

Figure 2: The translation function is also available in Firefox derivatives such as LibreWolf.

Manual Configuration

In Firefox and its derivatives, the developers have also adapted the settings dialog following the implementation of the translation feature. You can manually download individual or all language models from the list displayed in the Translations group of the Settings | General menu and integrate them with the browser by pressing the respective button (Figure 3). You can tell which language models are already installed by the label on the corresponding button: An installed model's button will read Remove instead of Install. If you don't have Internet access when selecting a target language for which a language model is not yet available, the application displays a note to this effect in the translation pane.

Figure 3: The language models can be downloaded individually or in one fell swoop.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News