Drupal I18n

Posted onby admin
Drupal I18n

Edit: Please follow Gábor Hojtsy's excellent series on translation in D7, if you're not already following it. It's more up-to-date and more authoritative. You'll probably be interested in Drupal 7 Multilingual: What's new in I18N.

Drupal has long been a leader in the ability to present a website in multiple languages. In Drupal 7 we continue that tradition: Field translation or 'content translation' made it into Drupal 7, but it's not obvious from a plain Drupal 7 install how you would use it.

As a Drupal engineer, I mainly worked on Dutch government related Drupal projects. This includes intranets and information portals. Mostly in the role of technical lead or consultant. Most of these websites were developed as being 'webrichtlijnen-proof', wich means that they are easily accessible by people with a visual handicap.

  1. Internationalization (i18n) module This is a complete manual and step-by-step guide for building multilingual websites with Drupal and the Internationalization (i18n) package. Drupal 7.x has some built-in multilingual support to provide a localized user interface and translatable content. However, not everything is yet localizable/translatable.
  2. Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up. Sign up to join this community.

This article is fundamentally about content translation, not about interface translation, which is a completely different thing in Drupal (and always has been). Interface translation is about prompts, labels, menu entries and the like, all of which are handled by the core locale module and various contrib modules like i18n. I will explain how to import basic interface translation files, however.

Drupal 6 has a node translation system which basically allows you to make 'translation sets' of nodes. You start with a node in a source language (and set the language on that node), and then you can create additional translations of that node to other languages. So for example, we might start with a node in English, then use the 'translate' tab to add additional nodes in different languages that are tied to that original node. That node translation system is still supported in Drupal 7, but it doesn't support translation of CCK fields, and is quite awkward in reality because you're dealing with a number of separate nodes, instead of translations of a single node. Edit: See Gabor's comment below for more on this, and considerations regarding it.

Drupal 7 got field translation (yay!), also referred to as 'content translation', which is an entirely different thing. In content translation you have a single node, but with different translations for each field on the node that should be translatable. And the body is a field. Unfortunately the title is not a field, and therefore is not translatable, but more on that later. To restate this: In Drupal 7 'content translation' there is just one node, and translatable fields on it are translated to provide the translations, but are still part of that single node. The gotcha in field translation (content translation) though is that in core it didn't get a user interface. As a result the contrib Entity Translation module improves content translation and provides a UI and works alongside the core content translation module, and it's fundamental to the approach described here.

Here is the process I went through to set up a basic multilingual site:

  1. The core field translation facilities have no user interface, so you'll need the Entity Translation module. After installing and enabling it (which also enables translation and locale modules), you may need to run update.php.
  2. You need to enable languages for your site.
    • Add languages at admin/config/regional/language
    • Download interface translation files from http://localize.drupal.org
    • Import interface translations into the configured languages at admin/config/regional/translate/import (under 'Translate Interface'
    • Click 'Enabled' on the languages you've configured
    • At 'Detection and Selection' (admin/config/regional/language/configure), choose how you want languages to be chosen. My experience is that URL selection is the best approach, so you'll need to configure subdomains or some related approach. Note that when you use URLs you need to enter the full URL including 'http://'. There doesn't seem to be any error checking on this. Also remember to click 'enabled' on the strategy that you choose.
    • On the same 'Detection and Selection' page, in the lower section of the page under 'Content language detection' select 'Interface', so that the same language is chosen for content language detection as for interface language detection.
  3. Enable translation of nodes and any other entities that should be translatable at admin/config/regional/entity_translation.
  4. Enable 'Multilingual support: Enabled, with content translation' on the content type edit form under 'Publishing options'. For example, for a content type named 'example', this would be at admin/structure/types/manage/example/edit in the 'publishing options' fieldset.
  5. For each field that should be translatable, go to field settings and check 'users may translate this field'. For the body field of the 'example' content type, this would be at admin/structure/types/manage/example/fields/body/field-settings.
  6. Now you can create and translate fields.
    • Create a node and set its language to a specific language.
    • When you've saved it a 'Translate' tab will appear allowing you to translate into other configured languages.
    • Click 'Add translation' to add translations for the fields that have translation enabled.
    • Make sure to publish the translation. Publication is unfortunately hidden in the collapsed-by-default 'translation options' fieldset

Drupal I18n Sync

Some gotchas regarding field translation:

Drupal I18n Translations

  • The Title module is required to make titles translatable. This currently only works for nodes, not entities. All the work is actually being done in #924968 so you have to apply the patch from that issue.
  • Entities other than nodes are not translatable out of the box. The entity must be specifically enabled to allow its fields to be translated. das-peter will elaborate on this later.

Drupal Views I18n

Since I'm a newbie at the D7 translation scene, I'm sure there are errors or omissions here, so please correct this and I'll update the article based on your corrections.

Drupal I18n

Edit: If you're interested in this article you'll want to follow Gabor's series beginning with http://hojtsy.hu/blog/2011-jan-19/drupal-7039s-new-multilingual-systems-....