+5 votes
by (725k points)

Hi,

I would like to add Spanish as a second language for my Drupal website. How should I configure internalization module?


1 Answer

+1 votes
by (1.5m points)
selected by
 
Best answer

Very briefly, behind this word hides the process that makes a site can be in more than one language. Another related word is the location that is the necessary process for a site to be in a specific language. In other words, during the first process, the necessary characteristics are enabled to translate texts, dates, etc. and in the second process they are translated into a specific language.

 

It is clear that both words are long enough to make it difficult to pronounce or write them. This is why some curious acronyms are used for them: i18n and l10n respectively. Its origin, once it is known, is as evident as it is original: each acronym is the first and the last letter of the word separated by the number of letters that separate them. For example, internationalization is an i , 18 letters and a n .

 

The i18n process is very simple in Drupal if done at the right time and the necessary precautions are taken.

 

One problem with the i18n Drupal process is that it considers that the texts that we enter in the forms of the Web are in the default language of the site. If we want to change the default language once we have developed a site, we will have to review all the texts that we have introduced to adapt them to the new language. Consequently, the moment a site is due is just after its installation .

 

Let's go on to describe the i18n process:

 

1. Installing modules

 

Drupal includes in its distribution by default two modules for i18n sites: Locale and Content translationThe primer allows you to configure what the languages of the site will be, what the default language will be and how the language to be displayed will be chosen. The second allows the contents to be translated, linking a content with its translations so that it is possible to change the language without having to change the page.

 

Both are necessary but they are not enough . It is necessary to install several modules that make other elements of Drupal internationalizable. These modules are included in the i18n package (except for the one that allows i18n views, which has recently been moved to the i18nviews modules , with a view to Drupal 7). It is advisable to enable them all (with the exception of Poll i18naggregate and Profile translation if we are not going to use these modules).

 

2. Activating languages

 

The time has come to tell the system what languages will be available on the site.

 

We go to "Site configuration> Languages". On this screen a list of the active languages and their characteristics appears and which of them is the default language.

 

We click on "Add language". In this screen we can select the language of a list or introduce ourselves the information about the language.

 

We follow the previous process as many times as necessary, until we have all the required languages activated.

 

3. Setting which language will be displayed at any time

 

All the previous work will not be useful if we do not tell Drupal what language to show at all times.

 

We go to the "Configure" tab of the language screen. Drupal offers several options, but the most recommended, and the most simple one, is the so-called "Path prefix only".

 

By marking it, the system will select the language based on a prefix in the address of the pages that it will insert itself. Thus, our pages in Spanish will be of the form "http: // example .com / en / pagina / de / ejemplo".

 

problem may arise if we select this option and a language other than English as the default language (as we will see later). Drupal considers that the default language should not have a prefix. As the initial default language is English, it has no prefix configured. When changing the default language, a conflict occurs: neither the default language nor the English have a prefix. The solution is simple, we go to the detail page of the English language and we put a value in the field "Path prefix", usually "en".

 

4. Latest details

 

The system is already internationalized. But two or three details are missing to finish the process.

 

I have spoken in previous points about the default language. To select a default language other than English, we must go to Site configuration> Languages, mark the language we want to be our default language in the "Default" column and accept the form. As I mentioned earlier, all text strings that have been created in system forms must be manually translated into the new language by default. Some examples of these chains are the names and descriptions of the types of contents or the names and descriptions of the menus.

 

These modules include a block that allows you to toggle between the languages of a page. We must enable it as we normally enable blocks and place it in the place that suits you according to our design.

 

Although we have enabled the languages we will not see our page more than in English. This is normal, since we have not imported the translations. Although there are other ways to do it, nowadays, the fastest and most efficient way to do it is installing the module l10n_update , which automatically updates all the translations of all the modules that we have in our Drupal.


Most popular questions within the last 20 days

...