Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Content Translation Tutorial for Drupal

Introduction

Content translation is a crucial aspect of building multilingual sites in Drupal. It enables the creation of content in multiple languages, ensuring that users from different linguistic backgrounds can access the information they need. This tutorial will guide you through the process of setting up and managing content translations in Drupal.

Prerequisites

Before you start translating content, ensure you have the following:

  • A Drupal site installed (version 8 or later recommended).
  • Admin access to manage modules and settings.
  • Content types created that you want to translate.

Step 1: Enable the Required Modules

To enable content translation, you must activate the necessary modules:

  • Language: This module allows users to select their language.
  • Content Translation: This module helps translate content entities like nodes, taxonomy terms, etc.

To enable these modules, navigate to Extend in the admin menu and search for the modules mentioned above. Check the boxes and click Install.

Step 2: Configure Languages

After enabling the necessary modules, set up the languages you want to support:

  1. Go to Configuration > Regional and Language > Languages.
  2. Click on Add language and select the desired language from the dropdown.
  3. Click Add to save the language configuration.

Repeat these steps for each language you want to add.

Step 3: Configure Content Translation Settings

Next, you need to configure which content types can be translated:

  1. Navigate to Configuration > Regional and Language > Content language and translation.
  2. Under the Content types section, select the content types you want to translate and check the Enable translation box.
  3. Click Save configuration.

Step 4: Translating Content

To translate a piece of content, follow these steps:

  1. Navigate to Content and find the content you want to translate.
  2. Click on the Edit button for the content item.
  3. In the Language dropdown, select the language you want to translate to.
  4. Fill in the translated fields and click Save.

Example: If you have a blog post in English, you can create a Spanish version by selecting Spanish in the language dropdown, translating the title, body, and any other fields, and saving the post.

Step 5: Displaying Translated Content

To display translated content on your site, ensure that the language switcher is enabled:

  1. Go to Structure > Block layout.
  2. Find the Language switcher block and place it in a region of your theme.
  3. Save the block configuration.

This will allow users to switch between languages, and they will be presented with the translated content based on their selection.

Conclusion

Content translation in Drupal is a powerful feature that allows you to create a multilingual site that caters to a diverse audience. By following the steps outlined in this tutorial, you can effectively manage and display content in multiple languages, enhancing user experience and accessibility.