Delete a source string and the target translations in Drupal 8 | Drupal 8

Delete a source string and the target translations in Drupal 8

Submitted by editor on Wed, 12/23/2015 - 17:40
Question

How to delete a source string and the translations of this string in Drupal 8 ?

As you haven't a Delete button on interface translation page, you can't do that from the translation interface. But you can do in a small custom module.

Example : Delete string ID 346, 'Home'

      $lid = 346;
      $con = \Drupal\Core\Database\Database::getConnection();
        $con->delete('locales_source')
            ->condition('lid', $lid)
            ->execute();
        $con->delete('locales_target')
            ->condition('lid', $lid)
            ->execute();

Note:

To get the lid,

  1. Goto User interface translation (/admin/config/regional/translate)
  2. Search your string
  3. Right click on the string to delete and click on 'Inspect Element' (On FireFox)
    • You have an ID like id="edit-strings-346-original"
    • The string ID is 346

Add new comment