Connect Drupal with Smartcat
With Smartcat and the TMGMT connector, you can send content from Drupal to Smartcat for translation, manage the translations in your Smartcat account, and then send them back to Drupal.
What you need
TMGMT module
Smartcat plugin
Cron manager module
To install the TMGMT module:
1. Download the ZIP-archive or copy the tar.gz download link from the official website.
2. Enable the Update Manager Module in the Admin panel of your Drupal website by ticking the relevant box.
3. Select Add a new module and paste the link into the archive/upload the archive into the window that opens.
4. Choose Enable recently added modules from the Next Steps list and select the modules used by TMGMT in the Translation Management section. Click Proceed .
Select the languages you want to work with in the Language and Region settings of your website.
In case of success, you will see new “Translation” tab in the Drupal interface.
To install the Smartcat module:
1. Download the ZIP-archive or copy the tar.gz download link from the official website.
2. Add it to your website as a new module as described above.
3. Enable the Smartcat Translator by ticking the relevant box in the Translation Management section.
To install Cron manager module:
Download the ZIP-archive or copy the tar.gz download link from the official website.
Add it to your website as a new module as described above.
Enable the Ultimate Cron by ticking the relevant box in the Other section.
Setting up the integration
In your Smartcat account:
1. Navigate to Settings- >API on the left-hand side menu to generate an API key.
2. Click Create New Key to open the following dialog:
3. Copy the API key as well as your account ID.
On your Drupal website:
1. Navigate to the Providers tab in the Translations section of your Drupal website and select Smartcat.
2. Paste your API key and the account ID into the corresponding sections, and select your preferred server.
3. Click Save.
In case of success you might see confirmation message:
The translation process
There are 2 ways to set up the translation workflow:
On Demand Translation – to manually send required articles for translations.
Continuous Translation – automatically send each newly created or updated article (of the specified type/s) as a new job item to the preconfigured translator.
On Demand Translation setup
1. Navigate to Structure -> Content Types and select Operations -> Edit for each content type you want to translate.
2. Navigate to the Language settings tab and select Enable translation and Show language selector for these content types.
3. The selected sources will be available in the Sources section of your Providers tab.
4. Tick the ones you want to translate right away, select the source and target languages and click Request translation.
5. Select Smartcat as your translation provider and submit the job*.
*Please note that a job is created for each target language. To translate one text into several languages at once, tick the relevant box.
6. Smartcat will create a project for each job you submit. These are also available in the Jobs section of your Drupal website. You can monitor the progress of translations in the Translation Job Messages.
7. To complete the job, approve all the selected segments in Smartcat.
8. To push the translations back, enter the relevant job on your Drupal website and click Download translations.
9. Enter the job, approve the translations and click Publish . The target language version of your article will be generated and published.
Translating custom fields
1. Navigate to the Content types section of your website’s Structure, and add a new field for the material you want to edit.
2. Select the type of field, e.g. plain text, list or image.
3. Fill in the rest of the data, e.g. Alt-text, category, or tags, and click Save.
4. Return to the Configuration section and tick the fields you want to translate, e.g. title, tags, etc.* and click Save. If you tick no fields, only the title will be translated.
*Please make sure the fields you select can be translated.
5. Submit the material for translation as described above. Review the translations in the Editor* and push them back to Drupal.
*The only field that can’t be translated for now is the Category field as it’s uploaded from Drupal as a numeric value.
Continuous Translation setup
Go to the main translation page by clicking "Translation" from the toolbar
Make sure there is a configured continuous translator on the "Providers" page. In this case, it is the Smartcat provider.
Open "Jobs" menu tab and click on "Add continuous job"
The page provides several configuration options including translator selection, label, source and target language. By default, the continuous settings block displays a list of content types available for translation.
Click "Save job" to complete the process.
Each newly created article (of the selected type/s for continuous translation) will be automatically created as a new job item and sent to the preconfigured translator.
The continuous translation process is provided via a scheduler thanks to Cron. TMGMT and Smartcat provide special scheduler tasks that will automatically send and receive translation from Smartcat. These tasks will be automatically launched thanks to Cron, which will automate the localization process.
Continuous Translation setup
First, you need to make sure that the Ultimate Cron module is installed.
Ultimate Cron extends Drupal’s native cron features and expands control over repeating jobs.
The following manual will explain how to enable translation jobs to run repeatedly.
Go to the TMGMT settings page, “Translation” > “Settings”.
Enable “Submit continuous job items on cron” option placed under “Performance settings” block. We recommend specifying the value 5 in the "Number of job items to process on cron" field. This is the number of jobs that will be processed in one iteration of continuous translation. In other words, this is the number of documents that will be uploaded to Smartcat at one time.
Make sure Ultimate Cron is enabled. “Extend” > “Install new module” enables site administrators to install new modules.
Go to “Configuration” > “Cron” > “Cron Jobs”. It provides an overview of available cron runs.
Look for “Default cron handler” provided by “Translation Management Core” and “Smartcat translator” and click the “Edit” button.
a. Translation Management Core: Responsible for submitting and updating translations in the Smartcat project.
b. Smartcat translator: Responsible for receiving translations from Smartcat, as well as importing into Drupal.
The Cron edit page provides several settings related to the TMGMT cron job. Using the “Run cron every” option, it is possible to set an interval for the cron job to run on.
Make sure the cron job is enabled and finish the process with “Save”.
If you have added a continuous job and configured Cron, the continuous localization process will start working. The Cron tasks that were described above will run automatically depending on the interval that you specified.
For testing purposes, you don't have to wait for Cron to run the necessary tasks, so you can use the "Run" button that each task has separately.
Automatic run of cron tasks
In order for tasks to automatically run every minute or every 15 minutes (depending on the settings), you need to ensure that the Cron trigger is always running.
Go to Configuration → System → Cron → Run cron. Here you will find a special link that you can follow to run Cron. We recommend setting up this link to be called automatically every minute so that tasks run consistently.
To do this, you need to go to your server settings. If you are using Linux, then run the command:
crontab -e
*/1 * * * * wget -O - -q -t 1 https://your_drupal_cron_link > /dev/null
Save your changes. Now the cron scheduler will automatically send a request every minute to the link you specify, which will ensure stable running of tasks.
How to check if everything works
Let's imagine that you have 10 articles that are in your continuous job.
When you run a cron task from Translation Management Core, the first 5 articles will be sent to Smartcat. There is currently no option to select an existing project in Smartcat. Therefore, if this is the first content submission, the project will be automatically created and linked to the continuous job. In the future, all content will go into this project.
In the "Translation -> Jobs items" tab you can find articles sent to Smartcat; they will have the status "In progress". Job items with the status "Inactive" are those that are waiting to be sent to Smarcat.
Don't forget to filter items by the "states" parameter.
If you run the cron job from Translation Management Core again, the following 5 articles (which are in Inactive status) will be sent to Smartcat.
Sending in batches is necessary in order to avoid "timeout" problems during task execution.
This way you can run the cron job until all documents are sent to Smartcat. As a reminder, this will happen automatically if Cron is configured.
Now let's translate one of the articles into Smartcat and try to get the translation back into Drupal.
Now, in order to get translations back into Drupal, you need to run a cron task from Smartcat translator.
This task will automatically receive all job items that are in the "In progress" status and try to get translations from Smartcat.
Articles that have been translated and successfully imported into Drupal will receive an "Accepted" status.
Did this article help you find the answer you were looking for? If not or if you have further questions, please contact our support team.