Drupal 7. I have used the t() function to translate many string in different languages. I used English as default language, and added t('This is a new string') all around my module files, template files, etc.

The problem is that I have changed the original string names several times, and in some instances, I didn't delete the "duplicate" entries, so there is garbage. Is there a way of listing or retrieving all the t() strings that I added? Maybe comparing with a fresh Drupal installation and exporting a template *.po and using a program to compare the changes ?


1 Answer 1


One way to get rid of unnecessary entries in locales_source is to run the following:

DELETE locales_source 
FROM   locales_source 
LEFT JOIN locales_target lt 
using (lid) where lt.lid is null;

To get an idea of what this will remove from the table, you could check using:

SELECT count( * ) 
FROM locales_source 
LEFT JOIN locales_target lt
USING ( lid ) WHERE lt.lid IS NULL;

I got the idea from : http://julian.pustkuchen.com/en/drupal-7-performance-blown-localessource-table

In my case, I had a lot of stale content in locales_source. I also had many pages where content was tagged as being translated, but the page included many call t('...') calls, which added unnecessary entries to the table. Long story short, I was able to safely remove over a million rows of data and site performance went from absolutely awful to humming along nicely.

YMMV, but it worked for me.

  • Looks like for D8 it should work also. Could You confirm, please ? Feb 22, 2018 at 16:48
  • This is working for Drupal8 too
    – Vorapoap
    Apr 17, 2020 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.