Our new Vivaldi Translate feature is designed to allow you to translate a page’s text quickly and easily. In addition, Vivaldi respects your privacy, unlike some translator extensions or built-in translators like Google Translate.
Now, it’s time for a deeper dive, with Petter Nilsen, the Vivaldi developer who took the lead on Vivaldi Translate. He’ll explain how Vivaldi Translate works “under the hood”, and will share some behind the scenes challenges our team overcame to bring translation functionality to the Vivaldi browser.
How does Vivaldi Translate work?
Petter: It works in conjunction with the Vivaldi Translate server, which does the heavy lifting of translating the page. This translation server was created by our partner Lingvanex. It uses machine learning and runs on a number of GPUs (graphic processing units) hosted in Vivaldi’s datacenter in Iceland. GPUs are uniquely suitable for some heavy computational tasks, particularly machine learning, compared to CPUs.
The translation process follows these steps:
- When you visit a page, all text on that page is extracted and passed to the CLD v3 (Compact Language Detector v3), a neural network model, which detects the language of the page and notifies the browser. (For more on the CLD v3 model, go here.)
- The browser compares the page language to the language you have configured for it. If they are different, it shows a popup with a button to translate the page.
- If you click that Translate button, the browser sends a script for translating the page to the renderer.
- The renderer injects the script in the page and instructs it to translate the page to a specific language.
- The script will extract all texts on the page, send them to the Lingvanex translation server, and wait for a response with the translated text. Then it will replace the original text on the page with the translated text in your chosen language.
- The renderer keeps polling the script until translation is complete or it has failed and forwards that notification to the browser.
- The browser then will show you a pop-up that explains either that the page has been translated or that the translation failed. This popup typically disappears after translation, and instead the icon in the Vivaldi address field will be highlighted.
What all this means is that Vivaldi Translate, powered by Lingvanex, allows you to translate a full page from any language supported to the language of your Vivaldi installation by default (or from additional languages in the drop-down) with a single click. You can also customize the translation with these options:
- Always translate – always translate the current language
- Never translate – never be asked about the current language on any web page again
- Never translate this site – never be asked about translation on that particular site again
- Offer to translate pages – disables the automatic translation of pages and pop-ups that show automatically. The button remains in the address field to allow you to reverse the action or manually translate a page.
How did you and the team get the Vivaldi browser to work with the Lingvanex translation server?
Petter: There are many parts that must be in place to make capable translation support possible.
First there is the UI and all its options. The browser also has to be able to retrieve the list of languages that the Lingvanex translation server supports. This must be done at regular intervals, so additional supported languages will show up in the UI.
But at the end of the day, the most challenging part, browser-wise, is to work all the kinks out of the script, so it can extract the text and send it to the API on the translation server, and then replace the webpage text with the translated version. This might happen quite often when scrolling a page, so optimization strategies must be in place. Work on this script is ongoing, and it will improve over time, as we get more feedback from users.
What other hurdles must be jumped to make sure Vivaldi Translate works?
Petter: One special (and pricey) challenge, in these pandemic times (not to mention the explosion of bitcoin mining) has been getting hold of enough GPUs to run translations on.
Another is that, whenever we fix issues with text extraction on web pages, we need to ensure we have enough unit tests to cover the fixed cases and that we’re not breaking other pages.
Likewise, when adding new languages to the Lingvanex translation server, we need to ensure this also works in the UI. In some cases, we’ll need to add support for these languages in the UI, so they show up with their local language names.
Some pages present extra translation challenges, such as those with iframes or dynamic pages, where texts might be removed and re-added.
We have also seen that some forums don’t load pages or posts using the “normal” mechanism. This means they don’t trigger the normal language detection mechanism, making it a challenge to determine the language without incurring performance penalties.
Of course, these are not necessarily unique challenges for Vivaldi Translate, as similar issues can be seen in other browsers. We expect to solve or improve upon them, as we go along.
Regardless of the challenges that come up, we are constantly working on optimizations and fixes to improve the user experience.
Right now, Vivaldi Translate is limited to page translation. Are there any plans in the works to expand its functionality?
Petter: Work is already underway to implement the translation of the selected text on web pages. We have also started planning for exposing translation to other parts of the UI, such as Vivaldi Mail, in a panel, and possibly other places, too. Stay tuned!
Getting Vivaldi Translate, powered by Lingvanex, is easy! Just download the Vivaldi 4.0 on Windows, Mac and Linux computers, mobile phones and tablets running Android 5 or higher, and on up-to-date Chromebooks. Get it now. 🚀
Have you tried Vivaldi Translate yet? We’d love to hear what additional languages and translation functionality you’d like to see in your browser.