Understanding Drupal translations and multilingual modules

Image
trans
Why are multilingual translations are useful ?

Multilingual translations can help us to expand our market and reach a wider audience. However, By translating your own content into multiple languages, we could breakdown language barriers and make your website readily available across the globe. Poorly translated content can damage your organisations reputation and lose a number of potential customers. Drupal provides four translation modules where each plays a significant role in translating.

When we install a Drupal instance, we need to choose the default language as English. The installer will attempt to make the reasonable choice based on your browser language, and should display the page in your browser language.

Steps for enabling multilingual in your Drupal instance

Step 1: Install all translation modules 

Drupal comes with four core multilingual modules, the basic installation involve these four Drupal modules:

  1. Content Translation
  2. Language
  3. Interface Translation
  4. Configuration Translation
Languages

 

Step 2: Add language

Navigate to Configuration->Regional and language (/admin/config/regional/language)

Choose any preferred language from the language name list (Eg. French, Dutch). Now, click on Add language, then the language is yet to download and once the download is complete you'll be redirected to Languages page with a confirmation page. 

language translation

 

Step 3: Configuring content translation 

So, the goal is to make content, content block, custom menu link, taxonomy term and URL alias translatable. The basic requirement to translate all of this is content translation module. 

In the administrative menu, navigate to configuration > regional and language > Content language and translation (admin/config/regional/content-language). We need to go under Custom language settings and check on content, content block, custom menu link, taxonomy term and URL alias. However, on checking these entities all the related translatable checks will be shown below and makes these entities translatable. 

 

Custom language settings

 

We further have options to set the default language (English) or choose any of installed languages from the drop down as shown in the image below. 

 

Content Translation image 1

 

Finally, click on Save configuration. 

Step 4: Enable translation in content types

Go to your content type edit page and enable translation in the language settings pages. Assuming, we are translating from default language English to French. 

In Administrator menu, navigate to content (admin/content) and locate to any content item or by searching by the keyword in the title field. 

add language

 

Now, select Translate tab which is shown in the above image, click on add in the French language row. A new edit page with Title, Body and URL alias is displayed and go ahead and save this translation. We have converted the entity item's language to French. A new content item will be created with French language accordingly. 

We can find the language code "fr" in the URL once we view the content item. To revert back it to English we need to remove the "fr" keyword right after the domain name. For example, assuming the URL is mydummyproject.com/fr/node/5/translations/add/en/fr is a French translated page. we need to remove "fr" which is right after mydummyproject.com to switch back to English. 

Step 5: Enable interface translation module 

Interface translation is a core module which allows us to replace any string in the interface with a string that has been customised. This module plays a significant role in Drupal by translating any string and tries to translate the particular string to the current language of the interface. This module as also filters the untranslated string in the table. 

Navigate to Configuration > Regional and language > Interface translation to manage User Interface translations. 

 

conten translation image 2

 

Step 5 : Enable configuration translation module

Configuration translation module (core module) helps in translating configuration in different languages. Configurations like site name, vocabularies, menus, blocks can be translated using this module. 

Note : Content such as nodes, taxonomy terms, custom blocks, and so on are translatable with the Content Translation module in Drupal core and not with configuration translation module.

 

configuration translation

 

Some important translatable configuration elements

  1. Block
  2. Comment type
  3. Configuration entity type
  4. Contact form
  5. Content type
  6. Custom block type
  7. Date format
  8. Form mode
  9. Image style
  10. Language
  11. Menu
  12. Role
  13. Taxonomy vocabulary
  14. User fields
  15. View
  16. View mode
  17. Account settings
  18. RSS publishing
  19. System information

 

Additional information 

A very basic module called Language Switcher Dropdown exposes a new block that is comparable to the Language Switcher block that the Locale module by default provides. If installed, the module also works well with the Language Icons module as well.

To install via composer, use the below command : 

composer require 'drupal/lang_dropdown:^2.1'

After installing the module, navigate to Structure -> Block Layout. From there, locate to the Language Switcher block in the block list and place it in the appropriate region. In the image below, the language switcher block is positioned in the right sidebar.

language translation

 

Conclusion

Drupal serves a better way in building a multilingual website having more than 100+ languages and translating the website effectively. Drupal translation modules are core modules which provides a multilingual domain to translate the website as per clients experiences. 

Many thanks for these invaluable references: