Skip to main content
Image
Language

Keeping translations up to date in Drupal

Drupal is a widely used CMS ( Content Management System ) that offers multilingual support, allowing websites to present content in different languages. Keeping Drupal translations up to date is crucial to ensuring that your website users can access information in their preferred language. 

In this article, we'll explore two Drush commands, drush locale:checkand drush locale:update, that make it easier to manage and update translations in Drupal.

Multilingual translations in Drupal

Drupal's ability to support multiple languages ​​is one of its most notable features. Websites can be built to reach global audiences by offering content in multiple languages. Drupal uses a combination of modules and configurations to make this possible, providing a simple and effective administration experience.

The translations and the configuration they generate

With translations it sometimes happens that, when you work as a team with several coworkers on the same project, it comes time to export ( drush cex ) the configuration to make a commit to the repository and, suddenly... strike out! Hundreds of configuration files appear that you have never touched before.

This occurs because one of the core or contributed modules that the website has installed and enabled has updated its translations and your local website, the one you work on, does not have them updated. From the Drupal cron, the CMS itself is responsible for regularly checking for translation updates, among other tasks. This is when Drupal has detected changes in the translations, and they need to be exported and updated in all the environments in which they work.

Drush and the management of translations

Drush , the command line interface for Drupal, becomes an essential tool when it comes to managing translations. Two commands in particular, drush locale:check and drush locale:update , are essential to ensuring that translations are up-to-date and up-to-date.

drush drush locale:check is available since Drush 9.x
drush locale:update is available since Drush 9x

The command drush locale:checkprovides an overview of the status of translations on your Drupal website. Running this command provides a summary indicating whether there are translations that need to be updated. 

When launching it, we get a response like this:

juandels3@debian:/var/www/html/drupalsite$ drush locale:check
> [notice] Checked the translation of es for drupal.
> [notice] Checked the translation of en for admin_toolbar.
> [notice] Checked the translation of en for autocomplete_deluxe.
> [notice] Checked translation of en for better_exposed_filters.
> [notice] Checked the translation of en for block_class.
...
...
...
>  [notice] Message: Checked the available updates of interface translations for 
> 25 projects.

Once you have identified the translations that need to be updated, the next step is to use the command drush locale:updateto download and apply the most recent translations.

This command connects to the Drupal.org servers to get the latest translations and applies them to the site. It is a fast and efficient way to keep multilingual content always up to date.

Using drush locale:check and drush locale:update periodically

To keep Drupal translations up to date, it is advisable to run drush locale:checky drush locale:updateperiodically, especially in development or local environments, in case changes to the translations are detected and must be versioned through YAML configuration. This can be done manually or by automating the commands using a script or cronjob.

By performing these checks and updates regularly, you ensure that your Drupal website presents accurate and up-to-date content in your users' preferred language.

Join the Drupal Sapiens Community

Save content that interests you, connect with others in the community, contribute to win prizes and much more.

Login or create an account here

Featured

Last news