I have a site which contains thousand of unused (and not translated) strings.
I would like to remove them to light up my database.
For the records,those strings where created because the original language of the source files has changed and because of some ugly code like t("$variable" bla bla")
My idea is to remove all the untranslated strings (which will contain used string) because the used strings will be auto-repopulated when needed. Here is the code I plan to use:
$locale_storage = \Drupal::service('locale.storage');
$strings = $locale_storage->getStrings(['translated' => FALSE);
foreach ($strings as $string){
$string_to_del = $locale_storage->findString(['source' => $string->getString()]);
$locale_storage->delete($string_to_del);
}
Is it safe?