Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Entity Usage 5.0.0 Major update available for module entity_usage (5.0.0). Release: Entity Usage 8.x-2.3 Minor update available for module entity_usage (8.x-2.3). Release: Excel Serialization 2.2.0 Minor update available for module xls_serialization (2.2.0). Release: GraphQL Compose 2.4.2 Minor update available for module graphql_compose (2.4.2). Release: TMGMT DeepL Integration 2.4.2 Minor update available for module tmgmt_deepl (2.4.2). Release: Freja eID for Drupal 1.0.0 Initial release available for module freja_eid (1.0.0)! Release: Charts Plotly 1.0.5 Minor update available for module charts_plotly (1.0.5). Release: Kamihaya CMS 2.0.0 Major update available for distribution kamihaya_cms (2.0.0). Module Revived: Two-factor Authentication (TFA) 8.x-1.13 Module tfa updated after 10 months of inactivity (8.x-1.13). Usage Milestone: Easy Email Module easy_email crossed 10,000 active installs.

Translate Tool

535 sites Security covered Drupal 8–11
View on drupal.org

This module provides a development helper for managing translatable strings in multilingual Drupal sites. It allows developers to easily add or delete translations for strings directly within update hooks, post-update hooks, or installation hooks, with support for specifying context for fine-grained control.

Development helper for translation management

When developing a multilingual site, you might want to add new translatable strings and their translations in a hook_update_N(), hook_post_update_NAME(), Drush's hook_deploy_NAME(), or hook_install().

This module adds a service that can help you with that:

function hook_post_update_NAME(&$sandbox) {
  $tt = \Drupal::service('translate_tool');

  $tt->add('horse', 'da', 'hest');
  $tt->delete('horse');'
}

Or if you prefer a procedural interface (update and install hooks are procedural anyway):

function hook_post_update_NAME(&$sandbox) {
  translate_tool_add('horse', 'da', 'hest');
  translate_tool_delete('horse');'
}

You can also add a context:

function hook_post_update_NAME(&$sandbox) {
  $tt = \Drupal::service('translate_tool');

  $tt->add('horse', 'da', 'hest', 'my-context');
  $tt->delete('horse', 'my-context');'
}

Using context in a procedural style:

function hook_post_update_NAME(&$sandbox) {
  translate_tool_add('horse', 'da', 'hest', 'my-context');
  translate_tool_delete('horse', 'my-context');'
}

The default context is used if you don't specify one yourself.

Depends on

Dependencies of the latest stable release

  • locale Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jun 2026
Latest release
2 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
2.2.x-dev Dev 8–11 Jun 17, 2026
2.2.0 Stable 8–11 Jun 17, 2026