Setup OSF for Drupal for Multilingual Support

From OSF Wiki
Jump to: navigation, search

Setup a Multilingual Drupal Site

The first step for having a multilingual OSF for Drupal site, is to setup the multilingual modules of Drupal. Once Drupal is properly configured as a Drupal multilingual site, then you will be able to use the multilingual capabilities of different OSF for Drupal modules.

In this section, we will cover all the steps to perform to setup the baseline required to have enable the multilingual support of the OSF for Drupal modules.

One of the core set of Drupal Multilingual tutorials has been written by Gábor Hojtsy and is available here.

Enable the Local Module

The first step is to enable the Local module. This module is part of Drupal Core:

Multilingual 1.PNG

Once you checked the checkbox, save the modules settings.

Enable a New Language

The next step is to enable a new language in the Local settings. Go to the Regional and Language settings, and click the Languages link.

Multilingual 2.PNG

Then click the Add langauge link to add a new language that you would like to handle in your OSF for Drupal portal.

Important Note: make sure that the language you are adding in Drupal is supported by OSF. You should read the Multilinguality Capabilities of OSF documentation before continuing with this tutorial.

Multilingual 3.PNG

Once you click the Save configuration button, your Drupal instance will now be aware of the new language you just configured.

Update Language

Now that you handle a new language in Drupal, the next step will be to update the language packages available for this language. The first thing you have to do is to download the l10n_update Drupal module, and to enable it.

Once this module is enabled, you will go to the Configurations, and then click the Translate interface link.

Multilingual 4.PNG

Then you will click the Update tab.

Multilingual 5.PNG

What this section does is to help you adding and updating the language packages of all the modules you currently have on your Drupal instance, with the languages you selected previously. There you will have to choose update options that best fits you needs, and click the Update translations button.

Setup Language Detection

The next step is to choose how you want Drupal to detect the language to use to display the content into generated Drupal pages. There are multiple options to do that. Go to the Languages configuration section:

Multilingual 2.PNG

Then click the DETECT AND SELECTION tab:

Multilingual 6.PNG

Finally choose the mechanism you want to use to do this detection.

Install and Enable the i18n Module

The next step is to download and enable the i18n (internationalization) module. This module gives access to a series of multilingual API functions, and a multiple of user interfaces that will help us properly managing the multilinguality capabilities of Drupal.

Once the internationalization module is enabled, you should also enable the following modules:

  1. Block languages
  2. Field translation
  3. Menu translation
  4. Multilingual support
  5. Multilingual select
  6. Path translation
  7. String translation
  8. Variable translation

Enabling Multilingual Support for Every Content Type

The final step that will be required is to edit all the content type that you currently have on your Drupal portal, and to enable the multilingual capabilities of each of them that you want to translate. What you have to do is to edit one of the content type (the Page content type in this example):

Multilingual 7.PNG

The you have to click the Publishing options vertical tab. Finally you have to enable (with translation) the content type.

Once all these steps are done, you will be able to translate all the content types pages on your Drupal instance. However, this is out of the scope of this article. If you want more information about doing this, we strongly suggest you to read Gábor Hojtsy's series of articles covering these questions in details.

Multilingual Capabilities of OSF Entities

Multilingual capabilities of OSF Entities will only appears to the system administrators and content curators if Drupal's multilingual capabilities are enabled. However, once they are enabled, a series of new features will be available to the users.

Multilingual Implementation in OSF Entities

In this section we will cover how the multilingual capabilities of OSF Entities have been implemented. The translation mechanism that has been implemented for OSF Entities is similar to the Field Translation one in Drupal. This means that we don't create new resources every time we create translate an existing resource in another language. We simply translate the values of the fields, and assign a language for each of the values.

Let's take a Resource Entity. That Resource Entity has been initially described using the English language. This means that multiple fields have been defined for that Entity, and that the literals values of these fields are written in English.

Then when the multilingual capabilities of the module kicks-in, we are able the translate the same Resource Type Entity in other languages. This means that all the fields that accepts literal values can be translated in other languages (the ones enabled in the Drupal portal).

Multilingual 8.PNG

Once an Entity got translated in one or multiple languages, OSF Entities will merge all the translated fields in a Canonical Resource. It is that canonical resource that is saved in OSF.

Translating Resource Type Entities

It is really easy to translate existing Resource Type Entities once the Drupal portal's multilingual capabilities are properly configured. If you edit any Resource Type Entities, then you will see a new TRANSLATE tab.

Multilingual 9.PNG

What you will see in this tab is one row per language configured on the Drupal portal. Then you will have the list of translations for that entity that you are editing. If the TITLE column for one of the language is empty, it means that the entity is not yet translated.

Multilingual 10.PNG

If you click the edit link of any translation of that entity, you will get to a new edit page where you will be able to edit entity using the selected language. Then you will see appearing a message that warn the user that he is currently translating the entity in French (or the selected language from the previous step). Every literal that will have written in that French translation page will be tagged with the French language. Every time that a search will be performed in French, or that this entity will be viewed in French, we will see the translation that has been defined in that page.

Multilingual 11.PNG

Once the user click the Save button, the new translation will be saved into OSF and will be available to all the system that uses that information.

A Word about Revisioning

The multilinguality capabilities of the OSF Entity module has no impact on the revisions capabilities of the module. Every modifications to the entity, in any language, will be accordingly revisioned into OSF. If you click the REVISIONS tab, you will be able to see, compare and manage all the revisions, in any language.

Multilingual Capabilities of OSF FieldStorage

Multilingual capabilities of OSF FieldStorage will only appears to the system administrators and content curators if Drupal's multilingual capabilities are enabled. However, once they are enabled, a series of new features will be available to the users.

Multilingual Implementation in OSF FieldStorage

In this section we will cover how the multilingual capabilities of OSF FieldStorage have been implemented. The translation mechanism that OSF FieldStorage supports is Drupal's Node Translation. Field translation is not currently supported by the osf_fieldstorage field storage type (so, it is not supported by the OSF FieldStorage module). The Node Translation mechanism means that every time you translate a content type page, you are creating a new content type entity that uses this new language.

Multilingual 18.PNG

As you can see, every translation will result in a new resource that will be saved in OSF.

Translating Content Type Entities

For every content type that you want to translate, you have to make sure that its multilingual support is enabled. For every such content type, you have to edit it, and then clicking the Publishing options vertical tab and to select one of the Multilingual support option that are available.

Multilingual 7.PNG

Once this is done, you will be able to change the language of each entity of that content type.

The next step is to edit one of the content type page that you want to translate. Once you found the page to edit, you will see a new option Language appearing in the edit form. From that drop-down box, you have to select the language used for describing that page.

Multilingual 15.PNG

Once you selected a language other than Language neutral, you will see a new TRANSLATE tab appearing in the user interface. If you click on that tab, you will get to the translation page for this entity.

Multilingual 17.PNG

In this translation page, you have multiple options. First you will see the list of languages supported by the Drupal portal. For each of these languages, you will see if it has been already translated or not. It is has been translated, you will see the title of the translated page, otherwise you will see n/a. If there is a language for which you don't have a translation, you will see a add translation link in the operations column. By clicking on that link, you will be redirected to a new edit form that will let you write everything you want, in that selected language, for describing that entity.

Multilingual Capabilities of OSF SearchAPI

The OSF SearchAPI does support multilinguality without having to configure anything. What it does is to detect the language currently used by the user that perform a search query and will use that language to send the Search query.

The only think that is necessary is to make sure that the OSF Search web service endpoint does support that language.

Multilinguality and Search Templates

When will come the time to create the search templates for a multilingual Drupal portal, the Drupal themers will have to take care, and make sure they properly manipulate the entities to use the proper language to display in the search resultset.