Handy SQL for translations

Here are a few handy SQL snippets for dealing with translated content on a Drupal site. These will be helpful if you are trying to translate a site and need to work out what content hasn't been translated yet.

1. Find nodes that haven't been translated.

SELECT 
  nid, title, language 
FROM node 
WHERE nid=tnid AND nid NOT IN (SELECT tnid FROM node WHERE language="es")

2. Find blocks that haven't been translated.

SELECT *
FROM locales_source
WHERE source IN (SELECT body FROM boxes) 
  AND lid NOT IN (SELECT lid FROM locales_target) 

3. Find blocks that are not in the locales_source table. These will be blocks that haven't been viewed in a translated language.

SELECT * 
FROM boxes 
WHERE body NOT IN (SELECT source FROM locales_source)

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options