Transifex

  • Documentation
  • Integrations
  • Drupal

Drupal

Join the beta

Our Drupal integration is currently in beta. If you're interested in getting access, please contact us.

Transifex’s Drupal integration lets you translate your Drupal site using Transifex. It works as an add on to Translation Management Tool (TMGMT), a popular module for Drupal localization. For now, only Drupal 7 is supported.

This guide will walk you through the process of setting up TMGMT, configuring the Transifex connector, sending content from Drupal to Transifex, and getting translations back in an automated way.

Before you can install the Transifex connector, you need to first install the TMGMT module along with its dependencies. Here’s how:

  • Assuming you have drush installed from inside your site’s folder, run the following command:

    drush dl tmgmt entity views ctools rules views_bulk_operations entity_translation --y
    
  • After you’ve pulled the modules, enable them all by requesting activation:

    drush en tmgmt_ui tmgmt_entity_ui tmgmt_node_ui --y

If successful, a Translate submenu should appear in the top admin bar of your Drupal site.

Configuring languages for your Drupal site

Next, you can add the languages that you want to translate your site to:

  • From the top navigation, head to Configuration. Then under REGIONAL AND LANGUAGE, click on Languages.

  • Click on +Add language.

  • Select a language from the list and then click Add language. Note that by default Drupal uses the generic version of a language, e.g. fr and not fr_FR. If a language you want isn’t in the list, you can add it through the Custom Language section.

  • Repeat Steps 2 and 3 to add all the languages you wish to translate your Drupal site to. 

Configuring translation sources

After installing TMGMT, you need to select which content types will be translatable. To do this:

  • From the top navigation, click on Structure. Then click on Content Types.

  • Select the content type you want to translate and click on the Edit link next to it.

    drupal-content-types.png#asset:4145

  • Click on the Publishing options tab on the left, then select Enabled, with field translation under Multilingual support

    drupal-publishing-options.png#asset:4146

    Note that existing content won’t inherit this configuration. It is only applied to new content. If everything worked, you should be able to see the translatable content under Translation > Sources > Content

You can further configure the translation of the content type by going to Configuration > Regional > Entity translation. Here, we recommend you set the Default language to your source language, and not Language neutral. On this page, you can also configure options such as Language fallback.

Enable localizable node titles

Note

This step is optional. However, it's recommended if you're translating articles.

By default, Drupal doesn’t support multiple values for the title field, i.e. the title of an article. To get around this, you’ll need to install the Title module by running the following command:

drush en title

Once you’ve done that:

  • Head back to Structure and select Content Types.

  • Select the content type you want to have localizable titles for.

  • Go to the Manage Fields tab and hit the replace link next to the title field.

Installing the Transifex connector

Now, we’ll install the Transifex Connector. This will allow you to send content from TMGMT to Transifex and get translations back. Run:

drush dl tmgmt_transifex
drush en tmgmt_transifex

Configuring the Transifex connector

Next, we’ll configure the module so it’s connected to your Transifex account:

  • From the top navigation, head to Configuration, then select Translation Management Translators.

  • Click on Edit next to the Transifex Connector.

    drupal-translator-configuration.png#asset:4147

  • Under TRANSIFEX TRANSLATOR PLUGIN SETTINGS, enter your Transifex API token. If you don’t already have a token, you can generate one from the User Settings page.

  • Enter the URL for the Transifex project you created earlier, which should look something like https://www.transifex.com/organization_slug/project_slug/. Be sure to include the https:// at the beginning and that there's no /dashboard/ at the end.

  • If you want translations to be automatically pulled back into Drupal using webhooks, enter a webhook secret. The secret can contain any type of character and be up to 128 characters long. Then in a separate tab, head to your project in Transifex and under Settings > Webhooks, add a new webhook. In the popup, set the URL to <https://yourdrupalsite.com>/tmgmt_transifex/webhook/ and the event type to All Event. Then set the status to Active.

    transifex-drupal-webhook.png#asset:4144

  • Back in Drupal, you can decide if translations should be pulled when it's 100% translated or 100% reviewed. By default, translations can only be pulled when it's 100% translated in a language. 

    drupal-pull-reviewed-only.png#asset:4148

  • Finally, you can control if the translations received by Transifex should be automatically inserted into Drupal. If so, enable Auto accept finished translations under the TRANSLATOR SETTINGS section. If your translation reviews are happening in Transifex, we recommend enabling auto accept.

    drupal-auto-accept-translations.png#asset:4149

  • Click Save translator to finish the configuration process.

Sending content to Transifex

Now that the configuration process is done, you're ready to send content from Drupal to Transifex for translation: 

  • Click on the Translation menu item at the top of your admin bar. Then select the Sources tab. 

    drupal-translation-sources.png#asset:4150

  • Using the checkboxes, select the content you want to translate. Then hit Request translation.

    drupal-translation-content.png#asset:4152

  • On the next page, you can give the translation job a name (label) and select the target language for the job. Be sure Transifex translator is the selected translator.

    drupal-translation-checkout.png#asset:4153

  • Click Submit to translator to send the content to Transifex. For each node in Drupal, there will be a corresponding resource in Transifex. You can see the new job under the Jobs tab of the Translation page.

  • Repeat Steps 2 to 4 to create jobs for additional target languages.

Translating content

Once your content is inside Transifex, you have a number of translation options:

Pulling translations back into Drupal

After your translations are done, you can get them back into Drupal automatically or manually.

Automatically get translations back

If you have webhooks enabled, then translations will be pulled automatically either when a language is 100% translated or reviewed. When this happens, the translations retrieved will be automatically applied on the site. 

For more details on setting up webhooks, see Step 4 in the Configuring the Transifex connector section above.

Manually getting translations back

To get translations back manually:

  • Click on the Translation menu item at the top of your admin bar. Then select the Jobs tab. 

  • Click on the manage link next to the job you want to get translations for.

    drupal-translation-jobs.png#asset:4154

  • In the TRANSLATOR INFORMATION section, click on Check for updates. This will pull translations from Transifex into Drupal.

    drupal-check-translation-update.png#asset:4155

Adding a language switcher to your site

Now that you have your translations back in Drupal, you need to offer your visitors a way to pick which language they want to view content in. To do this:

  • Head to Configuration in the top navigation. Then under REGIONAL AND LANGUAGE, click on Languages.

  • Select the DETECTION AND SELECTION tab.

    drupal-detection-selection.png#asset:4218

  • Under the User interface text language detection section, you can choose how the language of the user interface is determined and prioritize the detection methods. It's worth noting that the user interface is made of miscellaneous text strings used through the site, e.g. the label on a submit button, and it's different from your content. No matter what you choose, we recommend enabling the URL option.

    drupal-ui-text-detection.png#asset:4219

  • Then in the Content language detection section, choose how the content language should be detected. If the language of the content should match the language of the user interface, then enable the Interface detection method and drag it to the top of the list.

    drupal-content-language-detection.png#asset:4220

  • Hit Save settings at the bottom of the page to finalize the changes.

  • Next, from the top navigation, head to Structure and then select Blocks.

  • Next to Language switcher (User interface text), select where you want the language switcher to appear.

    drupal-language-switcher-block.png#asset:4229

  • Hit Save blocks at the bottom of the page.

A new, text-based language switcher will be added to your site. 

drupal-language-switcher.png#asset:4230

If you prefer to let users switch languages using a dropdown, you can try other modules such as Language Switcher Dropdown.

Translating user interface content

In Drupal, you can translate the interface as well as the content. While content such as the words on an "About us" page might vary from site to site, the interface, made of labels such as "Submitted by," is standardized across all Drupal sites. Because of this, you can take advantage of the translations already done by the Drupal community. You just need to import them to your site. Here's how you can do this:

  • Head to https://localize.drupal.org/download and download the language file(s) you want. Make sure the ones you get are suited for Drupal 7.x.

  • Head to Configuration in the top navigation. Then under REGIONAL AND LANGUAGE, click on Translate interface.

  • Click on the IMPORT tab.

  • Choose the file you downloaded earlier along with the language it corresponds to, then hit Import.

    drupal-language-import.png#asset:4235

  • Repeat Steps 3 and 4 for other languages you want to support.

Tip

To automate this process, you can use the Localized Drupal Distribution module.