In Drupal 8, the modules regarding Languages and Translation are now reduced to 4 modules and are placed in the Drupal core. As a result, you get them by default with the creation of your website. The 4 modules that you need to enable in order to support more Languages and Translation are:
- Language: Enables more languages in your website
- Content Translation: Enables the translation of content
- Interface Translation (optional): Enables the translation of the user interface
- Configuration Translation (optional): Enables the translation for configuration
It is highly recommended to also enable the two optional Translation modules, especially if you have multilingual administrators or content creators.
How to enable more Languages
After having enabled the Language module, you are then able to add more languages to your website. In order to do it:
- Visit Configuration -> Regional Settings -> Language
- Click on “Add language”
- Select the language that you want to add.
- Clear the caches.
Step No4 is really important when it comes to building and maintaining a Drupal website. Whenever you make a big change, like installing a new module or enabling a new feature (or language in this case), it is highly recommended to clear the caches afterwards. It is a really frequent phenomenon when building a Drupal website to not being able to see some changes even though you have applied them, just because you haven’t cleared the caches.
Make a Content Type translatable
The custom content types are not by default translatable. In order to make a custom Content Type translatable you need to:
- Visit Structure -> Structure -> Content Types
- Click the arrow next to “Manage Fields” to expand the list and choose “Edit”
- Choose “Language Settings”
- Enable the two following options:
- Show language selector on create and edit pages - By enabling this option, you display the language selector every time you create or edit a content page in order to select the language of the content.
- Enable Translation - This option enables the translation of the content of this content type.
How to translate a piece of content
Let’s assume that you have created a translatable content type, you have added content out of the content types, you have enabled more languages in your website and now you want to translate the content that you have created. In this part, we will show how to translate the content that you created in the enabled language(s).
- Visit the “Edit” page of the content that you want to translate.
- Click on the “Translate” tab on top of the page
- Click “Add” for the language that you want to translate your content in (in this case French)
- Translate the Fields and save.
Content Translation vs Entity Translation
For those of you who have used Drupal 7, you probably know that when you translated content in it, the system was creating a new node for it. For example, let's assume that you had created a node (content) in english and it was assigned the node ID 5. If you were to translate this piece of content to a different language, for instance in French, the system was creating a new node and was giving it a new node ID, for example node ID 6. This way, all the translated contents were duplicates and you had twice the amount of nodes. The latter was actually the biggest disadvantage of this method, which by the way is called “Content Translation”
Drupal 8 is a better, more advanced and optimised version of Drupal and for that reason the Drupal engineers introduced a new way of translating the content, which is called “Entity Translation”. The difference is that instead of creating a new node, only the fields are translated and keeps the same node ID. In this way you don’t have duplicated nodes in your website and in general it’s easier to avoid misunderstanding between the IDs.
If you translate a node on Drupal 8 from one language to another and then visit the “Content” page (/admin/content/), you will notice that both the original and the translated content appear. This can create a misunderstanding thinking that the translated part is a different node, which is not the case. You can easily confirm it by visiting both nodes and checking the URL: you will notice that they both have the same node ID.
Both methods have pros and cons
|Content translation||Entity translation|
The main drawback is the creation of node duplicates.
The default way on Drupal 8, hence the way we presented in the previous section, is entity translation. Either way no matter how you will decide to translate your content, you should decide it before starting translating content. This part is highlighted because since you start translating content, it is then really difficult to change from one way to another and it will require a lot of customizations and custom modules.