Drupal8 comes with many new features and improvements. Translation and localization are much easier with Drupal8 now. Drupal8 can be installed in 94 languages, it also supports multilingual features right out of the box, providing four core modules specifically for language support and translation.
In this blog, we will explore how to use the multilingual features in Drupal8.
Step 1: Enable the required Modules
Drupal8 has four core modules Language, Interface Translation, Content Translation & Configuration Translation which need to be enabled in order to use the multilingual feature.
Step 2: Adding a new language
After enabling the modules, navigate to Administration > Configuration > Regional and Languages.. This page will display the default language that has been chosen during the time of installation(English in our case). Languages that are added are displayed in this section giving feasibility to make them default.
Now click on Add language button to add a new language for the site. Select a language that has to be installed and click on Add language. Drupal will download the language package and install the new language to our site.
Step 3: User interface translation
While adding the language Drupal will carry out the interface translation also. The percentage of the interface translation is displayed under “Interface Translation ” column. As in above section, 98.2% of translation has been done for French. It varies from language to language. Click on the percentage area under Interface Translation. It will list out all the source strings available and the corresponding translated string. Here the editing can be done for translated strings and the strings which were not translated by default.
There is an option to import a language package manually also. The language packages for Drupal can be found at https://localize.drupal.org/download.The language package can be downloaded and can be imported from the import tab in the language configuration page. Drupal will update the translation for the selected language.
Step 4: Content Translation
4.1: Configuring translation for a content type
In Drupal8 it is possible to translate various entities e.g nodes, taxonomies, users, blocks etc. Translation option for an entity must be enabled to achieve this. Go to Administration > Configuration >Content language and select the content entity for which you want to enable the translation. Lets select content.
It will display all the content types available on the website and the content type is selected which has to be translated by checking the checkbox below the Translatable column. Once the content type is selected the individual fields for the content type will be listed. A particular field can be made translatable by checking the checkbox next to each field.
The default language can be configured for each content type individually here. Additionally, check the “Show select language selector on create and edit pages” option if you want the language selector on create and edit content pages. After doing all the configuration click on Save the configuration button.
Once the configuration is saved, The Translate link for the content type and the respective fields in the admin panel can be seen.
4.2: Translating the content
Now that the translation option has been configured for the content type successfully, different language version of the same content type can be created. Go to Administration > Add content and select a content type. The language can be chosen where we are writing in.
After the content is saved, The “Translate” tab is available.If a new language version has to be added it can be selected from the “Add” tab next to the language.
Step 5: Adding Language Switcher
The Language Switcher block allows users to switch between languages.Go to Structure > Blocks, select a region where the block has to be placed and click on “Place blocks” next to the “Language Switcher” block and save the block.
In this case, we used “Side Bar First” as our region.
Visiting the Home page, the Language Switcher will be working:
By these steps, we can achieve the Drupal8 Multilingual Feature.