You are here

function i18n_string_refresh_cleanup in Internationalization 7

Clean up left over strings for text group

3 calls to i18n_string_refresh_cleanup()
i18n_string_refresh_group in i18n_string/i18n_string.admin.inc
Refresh all user defined strings for a given text group.
i18n_string_refresh_uninstalled_modules in i18n_string/i18n_string.admin.inc
Purge uninstalled modules.
_i18n_string_batch_refresh_cleanup in i18n_string/i18n_string.admin.inc
Batch callback, delete old strings

File

i18n_string/i18n_string.admin.inc, line 84
Helper functions for string administration.

Code

function i18n_string_refresh_cleanup($group) {
  $lids = db_select('locales_source', 's')
    ->fields('s', array(
    'lid',
  ))
    ->condition('textgroup', $group)
    ->condition('version', 0)
    ->execute()
    ->fetchCol();
  if ($lids) {
    drupal_set_message(t('Performing cleanup for text group %textgroup, deleting @count left over strings.', array(
      '%textgroup' => $group,
      '@count' => count($lids),
    )));
    db_delete('locales_target')
      ->condition('lid', $lids)
      ->execute();
    db_delete('locales_source')
      ->condition('lid', $lids)
      ->execute();
    db_delete('i18n_string')
      ->condition('lid', $lids)
      ->execute();
    return count($lids);
  }
  else {
    return 0;
  }
}