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.
We assume that the starting point is a Drupal site with content already available in one language (source language). This guide will cover:
1.Globalization step, getting your Drupal site ready to be localized
- Installing the TMGMT plugin for localization
- Marking which content you want to localize
- Selecting languages to localize your content to
2.Linking your Drupal site with Transifex
- Adding Transifex plugin in Drupal and configuring it
3.Localizing Drupal content using Transifex
- Selecting content for localization
- Monitoring localization progress
- Getting localized content back and making it available on your Drupal site
4.Setting up an auto-update webhook with Transifex
First, get your Drupal website ready for localization. Since version 8, Drupal natively supports localization by including a TMGMT module in its core distribution. This module enables localization options for a Drupal website.
Visit the Drupal admin interface and go to Configuration > Content language and translation (grouped under ‘REGIONAL AND LANGUAGE’ widget)
You'll see a list of all localizable content. Check the content that you would like to localize (more details: https://www.drupal.org/docs/8/multilingual/translating-content)
Head to Configuration > Regional and language and choose Languages to add languages you want to localize to (i.e. target languages)
This is where you can add the languages.
Click + Add language to add a language from the list.
Or choose Custom language to add a custom language.
In the list of languages, if you click Edit, you'll see its language code and name and define it as a ‘Left to Right’ or ‘Right to Left’ language.
Go to the Translations tab.
Go to Providers.
Click Edit on the Line labeled as Transifex, to set up the provider.
In this form you can edit the provider settings.
Label & Description fields are a help text so add something basic and descriptive.
Provider plugin is where you pick any available translation services. If another localization plugin is available it will be listed here. Choose Transifex.
Provide the necessary information to link the Drupal website with your Transifex project.
Next, move to the languages mapping.
Each label locale represents the locale that Drupal uses for the language, each dropdown selection represents the locale Transifex is using.
Once you’re done setting the Remote language mappings, hit Save to update the provider setting.
Now that the configuration process is done, you're ready to send content from Drupal to Transifex for translation.
In the Drupal terminology, these localization requests are called Jobs.
In the Drupal admin interface go to Translations. The Jobs tab contains all the translation requests sent to translation providers.
Click on the Sources tab. This is where you can see a list of all your translatable Drupal content.
Choose the content you are interested in, choose the Source Language and Target Language from the dropdown.
After this, click the Request translation button to actually send the content for translation in Transifex.
You will see a progress bar Submitting Jobs and then a few notifications will appear.
This way the content was pushed to Transifex as resources. Opening Transifex, you will see the resource files that were created and that have the same name as the Drupal content.
Transifex and Drupal do not communicate in real-time about translation services. So to check the status of your translation Jobs you need to query the Transifex service.
In the Drupal admin interface go to Translations. Got to Jobs to see the list of all the translation jobs.
Select the translation job you're interested in and click on Manage to see its details.
Click on Check for updates in the Provider information widget.
This action will query Transifex and update Drupal with the translation progress information.
After the steps from the above section are complete, some additional steps are needed to fully display the localized content in your Drupal site.
Incoming localization jobs from Transifex are considered as “need review”.
Go to the specific translation Job. The content that was pushed from Transifex is in the yellow color and is marked as needing Review (in the Operations column).
Click Review to validate the incoming localization jobs from Transifex. You’ll see a list of all the content in the source and target languages.
Click Save as completed - this will review and complete the specific translation job, returning to the translation job overview page.
Having set up your language selectors for your Drupal site, these actions will make the localized version immediately available on your website!
You can skip the manual review of the incoming changes from the Transifex provider interface To do so:
- Visit the Drupal admin page and go to Translations > Providers.
- Choose Transifex and click Edit.
- Enable Auto accept finished translations.
This will enable auto-fetching translations from Transifex, once the content sent to Transifex is 100% translated.
Go to your Transifex Project settings > Webhooks and create a new webhook.
In the URL field add the Drupal domain of your site followed by ‘/tmgmt_transifex/webhook/’. Ex. if your Drupal domain is www.mydrupalsite.com you should add ‘http://www.mydrupalsite.com/tmgmt_transifex/webhook/’
Add a custom Secret Key; in the Event field select All events.
Make sure that the Webhook Status is Active and click Save Changes.
Navigate to the Drupal admin page, select Translation > Providers, select Transifex and then click Edit.
Go to Transifex plugin settings > Transifex webhook secret and add the Secret Key that you've added in Transifex.
If you want to get the translated content from Transifex when it is reviewed, check the related checkbox Pull only when a language is 100% reviewed.