vectorbross / vb_bulk_translate
Queue translatable entities and translate them on cron with a TMGMT translator.
Package info
bitbucket.org/vectorbross/vb_bulk_translate
Type:drupal-custom-module
pkg:composer/vectorbross/vb_bulk_translate
Requires
- php: >=8.1
- drupal/core: ^10.3 || ^11
- drupal/tmgmt: ^1.15
Requires (Dev)
None
Suggests
- drupal/tmgmt_deepl: Required to translate interface strings and to translate Layout Builder inline blocks immediately.
- drush/drush: Process the queue with drush queue:run vb_bulk_translate.
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-20 08:18:51 UTC
README
Queues translatable entities and translates them on cron with a TMGMT translator (e.g. DeepL).
Usage
- Settings (
/admin/tmgmt/bulk-translate/settings): choose the TMGMT translation provider, the time cron may spend on the queue, the user translations are created as and, optionally, automatic queueing of all missing translations on every cron run. - Queue (
/admin/tmgmt/bulk-translate): filter on type and missing language, select entities (or all matching entities) and the target languages and add them to the queue. The queue is processed on cron, or right away with "Process queue now".
The queue can also be processed with Drush: drush queue:run vb_bulk_translate.
How it works
- Every queue item is one entity and one target language. A TMGMT job is created for it and the translation is accepted automatically.
- Existing translations are skipped unless "Translate existing translations again" is checked.
- Only entities of bundles with content translation enabled are listed. Inline (non-reusable) blocks are not listed, they are translated with the layout they belong to.
- Layout Builder: like the copy widget of layout_builder_at, the translation gets its own copy of every inline block of the source layout. The copies are translated in one extra job and converted to the target language. This only works with providers that return the translation immediately (DeepL); with other providers the translation keeps waiting in TMGMT. Translations requested in the TMGMT UI get the same treatment when their job item is accepted (core empties the layout of a new translation).
- Blocks referencing child blocks (accordion, tabs, timeline, quotes) need
their reference field marked as embedded in
tmgmt_content.settings(embedded_fields), so the child blocks are translated with their parent. The child blocks are copied along with their inline block, so every language has its own child blocks and they can be edited independently.vb_bulk_translate_post_update_localize_child_blocks()gives layouts that were translated before their own copies. - When the provider is not available (e.g. no API key) the queue is suspended and the items are kept. Items that fail are listed on the queue page and are not retried automatically.
Interface strings
Custom code gets no interface translations from localize.drupal.org, so
vb_bulk_translate_post_update_translate_interface_strings() translates them
with DeepL (the provider selected in the settings must be a DeepL translator).
- The custom modules, themes and profiles are scanned for
t(),->t(),->translate(),new TranslatableMarkup(),formatPlural(),new PluralTranslatableMarkup(),@Translation(), the Twigtandtransfilters, the{% trans %}tag andDrupal.t()/Drupal.formatPlural(). Only literal strings (and literal contexts) are found. - For every configurable language (English only when "translate English" is enabled) the missing translations are added as customized translations, so imports from localize.drupal.org keep them. Existing translations are not touched.
- The source strings are written in English and Dutch, DeepL detects the source language per string. Placeholders are not translated; translations that lose a placeholder are skipped and logged.
- Without an available DeepL translator the update is skipped with a message, so deploys do not fail.
A post update runs once. To translate strings added later, add a new post
update that calls
\Drupal::service('vb_bulk_translate.interface_translator')->translateMissing().