
Table of Contents
With a market share of around 2%, Drupal is a solid contender for the fourth place as the CMS (after WordPress, Joomla and Squarespace) of choice for website owners. Due to its modular nature and powerful features, Drupal is often used as a framework for developing web applications and sites that are expecting heavy traffic. Questo articolo si concentra sulle caratteristiche di base per l’internazionalizzazione e la traduzione di Drupal 8, anche se alla fine del 2020 è stata rilasciata la versione 9.
World’s 4th CMS
Free and open source, Drupal allows you to develop and manage websites through a sound administration interface.
Thanks to the tens of thousands of add-on modules and graphic themes available it is possible to create huge sites without any extra coding: modules, sometimes already packaged in ready-to-use distributions, allow web developers to extend system functionalities that the native installation lacks.
From the Drupal version 8, for example, the internationalization modules are already included in the core system. The system is thus ready to accommodate pages in different languages, activate the language switcher, etc. (however if the site is based on Drupal version 7, you should refer to the Internationalization (i18n) module documentation). Additionally, the system and interface messages are already translated by the community into dozens of languages and can be added in a few clicks.
Translation quote for a Drupal site
The good news is therefore that we only need to focus on the actual contents of the website, which must first of all be counted in order to estimate the time and cost of the translation.
Before starting a Drupal localization project, it is necessary to identify where the source texts are. Here is a list of the most common translatable content:
- system and interface messages
- User generated content
- Menus, buttons and CTAs
- Headers and footers
- Pages
- Blog posts
- Widgets
- Comments
- Metadata
- Taxonomy
- Themes
- Modules
- External files
- Images
- Video
- Embedded code
In order to estimate the volume of a website before installing a localization module, various techniques can be used, although none of them will yield a word count as precise as processing all the content in a CAT tool. However, at least to get the gist of the workload, it is possible to:
- Do a word count of the source text documents, if the copywriting team have saved the contents as text files (docx, Google docs, etc.)
- Do a word count of an SQL export (XML database dump), by accessing the underlying MySQL database through PHPMyAdmin or using a specific module
- Export the contents in CSV format, using a specific module, such as Entity Export CSV and count the resulting CSV file
- Do a word count of a static copy of the website by downloading the HTML files with HTTrack Website Copier, which is free and open source, or WebCopy.
Any external files present must be counted separately and can follow the standard workflow of yourtranslation provider. Because of that, we will not discuss them here.
How to translate Drupal system and interface messages
As anticipated, we don’t have to worry about translating system and interface messages because they are added directly when a language pack is imported, which has been already translated by the community.
Therefore, to make sure that the basic menu items, such as "Home", "Contact", the content of the 404 page and other similar texts are displayed in the new language, you must first activate all the modules of the Extend → Multilingual section and add the target language or languages from Configuration → Regional and language → Languages.
Then, in order to allow site visitors to switch between languages, the Language switcher block must be activated from the block administration page: in Structure → Block layout, choose an area of the page where you want the element to appear, click on Place block, search for “Language switcher” and save. Alternatively there are special modules such as Dropdown Language, which allow you to add a dropdown menu to choose the language.
If we want to use Drupalʼs backend (for website administration) in a language different from English, this setting depends on the user preferences. In Configuration → Regional and language → Languages, click the Detection and selection tab and check that the Account administration pages option is enabled. Then, in the Language settings section of your user profile, change the language of the administration pages from the Language drop-down menu.
Existing translations can be edited from the user interface in Configuration → Regional and language → User interface translation. Alternatively, you can export the strings in .pot format, translate them offline and import them back into your site. But be careful: when components are added or changed in Drupal, the corresponding texts will be translated by the community and released to the public. If Drupal is set up so that translations are automatically updated, any strings changed (by you) will be overwritten with the default (community) translation.
How to translate Drupal themes and modules
As for themes, starting with Drupal 8, Twig was introduced, replacing PHPTemplate as the default engine. This means that theme_*
functions and PHP-based *.tpl.php
files have been replaced by *.html.twig
templates.
Twig leverages the Internationalization module so that theme developers can use the code {% trans %}
...{% endtrans %}
, which makes the text between these tags translatable. But if a theme was not developed according to these specifications and hard-coded strings are found that need to be translated, the text won’t be detected as translatable and will be displayed in the original language. The solution to this problem is to create a copy of the theme and manually edit it. Then you need to assign the modified theme to the translated pages using a specific add-on module, such as Switch Page Theme.
In the case of modules, if they follow the best practices of internationalization, there should be a file in Portable Object format (.po/.pot) for each language, so just translate this file, rename it with the target language code and add it to the module. However, if the module does not follow this standard and untranslatable strings are found because they are hard-coded, you have two options:
- contact the developer of the module and ask them to update the module according to the correct specifications
- make a copy of the module, manually update the code and install it as a separate module, then use the edited module on the translated pages
How to translate user generated content in Drupal
The process of translating the main content, such as pages and blog posts, begins by installing the Translation Management Tool (TMGMT) module and activating all modules in Expand → Translation management. This module is used both to export and import content in XLIFF or HTML format, and to connect to the most popular translation tools such as Trados Studio and Memsource. The former means that the translation will be performed offline, i.e. by sending the exported files to your translation provider, while the latter means that the translation will take place online, as the translation system fetches the content directly from Drupal.
Configuring XLIFF/HTML export in Drupal
Let’s briefly see the first case. Depending on the translation workflow, there are a few options to set up. In the Translation → Providers section the default export format is XLIFF, the target field is empty and the HTML tags are escaped, meaning they will appear as translatable text in a CAT tool. If you choose HTML instead, no customization is available.
Your translation provider will be able to tell you how to choose and set up the format and it is highly recommended to test the configuration and the whole export-translation-import process with a couple of sample pages or posts.
Typical XLIFF workflow
Let’s now summarise the typical translation workflow with the XLIFF format. First you need to click on the Sources tab to create a translation job before you can export and download it:
- Select the content to export
- Select the source and target languages in the Checkout box
- Click Request translation
- Select File exchange in the Configure provider box
- Select the XLIFF file format
- Click Submit to provider
At this point the resulting file is ready to download:
- Click on the Jobs tab
- Click Manage for the job in question to open the Jobs overview screen
- Scroll to the Translation job messages box
- Click the download link
Now it is possible to send the files for translation and, when the translations are ready, go back to the Jobs overview screen and select the translated XLIFF files from your computer to upload them. Finally, you can review and edit the translations before they go live.
A validation tool is also available in this step, to check that all fields are filled in, and an HTML tag parser, to make sure the format is maintained. A useful feature of this step is the preview, which allows you to check how the translated pages will be displayed.
Workflow with a TMS connector
As an alternative to the offline workflow, many translation platforms such as Memsource, Smartling, and Wordbee offer a connector that doesn't require the export and import middle step, but interfaces directly with Drupal and the entire translation process takes place online.
In this case, you need to create a new translation provider. Here is the procedure taking Memsource as an example:
- Install the Memsource Translation Plugin for TMGMT module
- In the Translation → Providers section, click Add provider and type a name and a description.
- Under Provider plugin, select Memsource.
- Memsource-specific settings appear and the Memsource Home URL field is filled with the address
https://cloud.memsource.com/web
. - Enter your Memsource username and password and click Connect
- Click Save
In some cases you may be required to generate and enter API keys, but the procedure is usually very similar. In this regard, we refer you to the documentation of each module to configure it correctly.
Conclusion
Translating a Drupal website may present technical challenges if the site is particularly large or complex, or it has code-level customizations.
All in all, however Drupal is one of the most localisation-friendly CMSs, especially since the two main modules (Internationalization and TMGMT) are native and, in addition to being free as the core system, they guarantee a 100% compatibility.
Unfortunately, its main hinders are its limited diffusion and the fact that, being an open source project, the development of modules is sometimes abandoned. So it is important to evaluate and choose the online translation system with some foresight, if you decide to go down that path, because you are bound to a certain connector that must guarantee updates and compatibility with future versions.
As for offline translation, Drupal offers a fairly secure export and import procedure using standard formats (XLIFF and HTML) that are compatible with all translation systems on the market and can be a sort of backup if the online workflow becomes unfeasible.
Useful links
Unless otherwise specified, the resources are in English.