+4 votes
122 views
Multilingual sites with Drupal

in CMS by (360k points)
reopened | 122 views

1 Answer

+5 votes
Best answer

First of all, if we want our site to be available in several languages, the most logical option is to add more languages ​​and then configure them so they can be detected.
Adding languages
Drupal by default has the support for languages ​​in its core, but it is not completely activated by default. Let's see how to activate it.
  • 1- To integrate the languages ​​with our site, activate the kernel module. We go to Configuration à Regional and Language to see the following options:

image

  • 2- We click on Languages and we will see that we only have English activated in our list for now:

image

  • 3- For our purposes we will work with predefined languages. Therefore, we choose the language of the list and click on the Add language button:

image

  • 4- After this Drupal will redirect you to the list of main languages ​​and your new language will have already been added to the list, now to add more languages ​​we repeat the previous process, in this example we add: Arabic, German and Polish .

image



The above table shows the names of the languages ​​we add, their code, their address, when we talk about address we refer to the way they are read, from left to right or vice versa.

Here we can choose which languages ​​to activate, sort or delete them from the list.

Detecting languages
Now that we have the languages, we realize that if we navigate through our site everything remains the same, because despite having added languages ​​we still need to tell Drupal how to interpret them, let's see:
  • We navigate to Configuration à Regional and Language > Languages > Detection and selection and we will see the following available options:

image


URL
If we activate this option, users can browse URLs in the following way: example.com/de/news/ or example / deutsch / news. This is a common configuration for multilanguage sites.

Session
We will use this option if we want to save the preference of the languages ​​in the user's session.

User
In this option, users can specify in the profile of their account which language is their preference.


image


Browser
If we activate this option Drupal will verify the language preference of our browser and will use it on our site.

Already described the different options we use one to implement the multilanguage option on our site.

For our purpose, we will keep the URL option and for this we will use the prefix of the route, since it is the simplest way of configuration. Let's see how we do this:
  • First we mark in the URL options and press Save settings .
  • Now we click on Configure in that method and we will see the options Path prefix and Domain . We will use the default option that is Path prefix .
  • Now we change the URL in our browser to include the prefix of the route. For example, problems German , example.com/de. In this way we can use the prefix for each of the languages ​​we add.
Switching between languages
We certainly do not want users to be manually changing the languages ​​by the URL so we create a block in Drupal so that we place it somewhere on our site to facilitate this task.
To create the block, navigate to Structure à Blocks and look for the user interface block: Language switcher . We position it in the place we want and we save the settings for the block, after activated it would look like this:


image


For example, we select that our site is in German and our login would look like this:


image


Drupal gives us the opportunity to not only create robust and versatile websites, but also has the goodness to make the same multilanguage a feature that will stand out on its own from other websites on the network.

by (2.2m points)
edited

Related questions

+3 votes
1 answer
asked Jun 23, 2019 in CMS by backtothefuture (360k points) | 83 views
+4 votes
1 answer
asked Jun 23, 2019 in CMS by backtothefuture (360k points) | 73 views
+4 votes
1 answer
asked Oct 2, 2019 in Windows 10 by backtothefuture (360k points) | 86 views
Please leave a comment about whether the solution works or not (with device model)   [X]Close
6,895 questions
6,992 answers
277 comments
2 users