Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JPustkuchen/a101fa7ba257b8a7f8c3224f8bf5cc49 to your computer and use it in GitHub Desktop.
Save JPustkuchen/a101fa7ba257b8a7f8c3224f8bf5cc49 to your computer and use it in GitHub Desktop.
Drupal 8 CMS: Delete equal customized translation (source language string = target language string)

Drupal 8 CMS: Delete equal customized translation (source language string = target language string)

If you should encounter the problem that some translations are wrongly translated with the equal source language string (for example in our case there were German translations for "Author" translated with "Author" or "Published" with "Published"), you may use the following snippet to list them.

SELECT s.lid,s.source, t.translation FROM `locales_source` s
INNER JOIN locales_target t
WHERE s.lid=t.lid AND CONVERT(s.source USING utf8) = CONVERT(t.translation USING utf8) 
AND t.customized=1

To finally delete them, you may use something like this, but make a backup before and know what you're doing!

DELETE FROM locales_target WHERE lid IN (SELECT lid FROM (SELECT s.lid FROM locales_source s
INNER JOIN locales_target t
WHERE s.lid=t.lid AND CONVERT(s.source USING utf8) = CONVERT(t.translation USING utf8) 
AND t.customized=1) temp);

Clear & Update translations

Afterwards you may perhaps want to update your translations the following way: http://www.vaerenbergh.com/blog/drupal-8-reimport-all-translation-files

@vistar
Copy link

vistar commented Feb 15, 2021

It's working - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment