CERN Accelerating science

Close menu

Languages and translation

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

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:

  1. Visit Configuration -> Regional Settings -> Language
  2. Click on “Add language”
  3. Select the language that you want to add.
  4. Clear the caches.
  5. Done!

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:

  1. Visit Structure -> Structure -> Content Types 
  2. Click the arrow next to “Manage Fields” to expand the list and choose “Edit”
  3. Choose “Language Settings”
  4. Enable the two following options:
    1. 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.
    2. Enable Translation - This option enables the translation of the content of this content type.
  5. Done!
Translate 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).

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.
 

Both methods have pros and cons

  Content translation Entity translation
Pros
  • Node based functionalities like search work in an optimised way. 
  • The main advantage is that you don’t have to mind about synchronizing your content. You just translate your node and the system is responsible to do the mapping. Especially if the translation is done by a different person, synchronizing the translated node (images, files etc) would create trouble.
  • It deals better with neutral content. You might have noticed in Drupal 7 that having to translate neutral content created problems, which are now solved by using Entity Translation
Cons

The main drawback is the creation of node duplicates

  • This creates more content which takes more database space.
  • It’s more difficult to synchronize duplicate nodes. For example, if you have an image field in your node, when you make the translation you have to re-upload it.
  • It doesn’t work with revisions and core search. 

 

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.

Related FAQs