Editor's note: This is the fifth installment of a 2018 update to our "The Ultimate Guide to Drupal 8" blog series, fresh off the presses for Drupal 8.6.
Drupal 8 comes with no less than four modules for language support, each with a different role.
- Language module enables maintaining language information (other than English) on content and configuration in the system. If you are building an asset repository with an English interface, you would only need this module to maintain language metadata on your assets.
- Interface translation module provides translations of the built-in interfaces of Drupal on the back end and front end.
- Content translation provides translation features for content items (nodes, taxonomy terms, menu items, user profiles, etc).
- Configuration translation provides an interface to translate website configuration to multiple languages.
For a monolingual, non-English website, at least the language and interface translation modules should be enabled. In fact, when you install Drupal after selecting a foreign language those two are enabled automatically, and Drupal is installed entirely in that foreign language. For a multilingual website, the content translation and configuration translation modules are essential.
Drupal 8 is capable of managing any number of languages. After enabling the language module, it becomes possible to assign language information to content, so you can track the language of each content item. By default, Drupal assigns the site default language to newly created content, but you can customize this further with various dynamic presets, such as the author's preferred language.
The language module is also responsible for selecting the language used for the page, which may be based on the visitor's browser preferences or a part of the URL or other settings.
Finally, blocks are also enhanced with language visibility settings, so you can show or hide specific blocks for a group of languages. This feature can be used to provide different navigation options, for example when the foreign language version of the website is less capable than the original language.
Drupal has a lot of built-in interface features for both the back end and front end of the site. For many languages, these are already translated by the community at https://localize.drupal.org/ so the interface translation module downloads translations from there automatically when a new language is added (and as part of installing Drupal).
However, not all translations are complete, and not all translations match the needs of all sites, so there is a built-in user interface to customize these translations further. As the module keeps the translations updated from community sources, you can choose to protect your local customizations from being overwritten in such updates.
It is also possible to enable interface translation for English, which allows making small modifications to the English user interface, such as when "sign in" is needed in place of "log in."
All of these customizations may be exported and reused on other sites. Translation updates may be disabled on live sites and made part of a deployment process.
The content translation module builds on the language assignment functionality of the language module and allows content items (such as nodes, user profiles, taxonomy terms, custom blocks and menu items) to be translated to multiple languages. This functionality is configurable on the field level and in some cases even within fields. Such as for images, the file itself may be the same across translations while the title and alternate text would be translated. This is practical for a user profile picture. For a figure with text on it, the file would also need to be replaced in translations.
Translations of a content item are managed using the translate tab on the item itself. Once the translations are there, you can adjust listings and pages using the views module (which generates dynamic content listings) to adhere to your language requirements. Built-in pages like the default front page are created with views, so you can customize their language behavior. Views has filters to show only content in specific languages and the rendering of results is also customizable in terms of language used.
The combination of content translation, views, and block visibility can be used to build really complex multilingual experiences.
Finally, a major piece of Drupal 8 is the configuration system that manages deployable configuration of content types, fields, menus, forms, views, block placement, etc. These also need translation. The configuration translation module provides a user interface to manage the translation of these pieces and it stores the language files within the regular configuration storage system so translations participate in the deployment process as well.
That's a Wrap
Join us for our next installment, when we'll be talking all about Drupal 8's new page layout capabilities.