Drupal is a registered trademark of Dries Buytaert
Views Bootstrap 5.5.2 Minor update available for module views_bootstrap (5.5.2). oEmbed Providers 3.0.0 Major update available for module oembed_providers (3.0.0). Emulsify Tools 2.2.0 Minor update available for module emulsify_tools (2.2.0). amazee.ai Private AI Provider 1.3.4 Minor update available for module ai_provider_amazeeio (1.3.4). highlight.js Input Filter 2.0.0 Major update available for module highlightjs_input_filter (2.0.0). Webform QR Code Element 1.4.0 Minor update available for module webform_qr_code_element (1.4.0). Comments Order 4.0.0 Major update available for module comments_order (4.0.0). Comments Order 3.0.4 Minor update available for module comments_order (3.0.4). oEmbed Providers 2.2.4 Module oembed_providers updated after 7 months of inactivity (2.2.4). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Translate Tool

503 sites Security covered
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.

Activity

Total releases
2
First release
Jun 2026
Latest release
1 month ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

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