The queue
Changing a whole entity type at once can take a long time. The drush ecdl:dlet command therefore does not change anything itself. It adds one item per entity to a queue named entity_change_default_language, and a queue worker changes the entities later, one item at a time.
Before
Section titled “Before”The demo site has an English article, Latest news, with a Spanish translation. A fourth article, Hidden gems, has no Spanish translation.

Put the entities in the queue
Section titled “Put the entities in the queue”Queue every article for Spanish.
$ drush ecdl:dlet node es --bundle=article -y
// Are you sure you want to change the default language of these entities to // Spanish?: yes.
[OK] Entities enqueuedThe queue now holds one item for each article. Drush lists the queues and their sizes.
$ drush queue:list -------------------------------- ------- --------------------------------- Queue Items Class -------------------------------- ------- --------------------------------- entity_change_default_language 4 Drupal\Core\Queue\DatabaseQueue -------------------------------- ------- ---------------------------------Run the worker
Section titled “Run the worker”Cron runs the worker for up to 60 seconds per run. To run it by hand, use the queue command.
$ drush queue:run entity_change_default_language [notice] Skipped node 4: it has no es translation and the item does not ask to create it. [success] Processed 4 items from the entity_change_default_language queue in 0.09 sec.
Hidden gems was skipped, and the module logged why. To create the missing translation, queue the type again with --create-missing. Only the entities not yet in Spanish are queued.
$ drush ecdl:dlet node es --create-missing -y$ drush queue:run entity_change_default_language [success] Processed 1 items from the entity_change_default_language queue in 0.09 sec.Queue item shape
Section titled “Queue item shape”Your own code can add items to the same queue. An item is an array.
| Key | Meaning |
|---|---|
entity_type |
Required. The entity type id. |
entity_id |
Required. The id of the entity to load. |
default_langcode |
Required. The new default language. |
preserve_languages |
The languages to keep. A missing key or NULL keeps every translation, and an empty array keeps only the new default. |
preserve_legacy_default_language |
Whether to keep the old default language as a translation. |
create |
Whether to create the new default translation when the entity has none. |
follow_fields |
Names of reference fields to follow, on top of the entity reference revisions fields. |
attempts |
How many times the item failed before. The worker sets it. A missing key counts as 0. |
Items queued by 1.0.x are still processed as they were.
Skips, failures and retries
Section titled “Skips, failures and retries”The worker logs everything it does not change, in the entity_change_default_language channel.
- A skipped item is logged at notice level, with the entity and the reason, and deleted. The reasons are an entity type that does not exist or is not enabled in the settings, an entity that no longer loads, an entity that is not translatable, an entity already in the target language, and an entity without a translation in the target language when the item does not ask to create it.
- A failed item is logged at error level and queued again with one more
attempts. Retries run in the same cron orqueue:runpass. - After 5 attempts the item is given up, with a last error log entry, and it is not queued again.
A change that fails stores nothing, so a retry starts clean. Read the recent log entries with Drush.
drush watchdog:show --type=entity_change_default_language