Engine of a Mini Seven racing Mini
Photo: Copyright © 2009 Eelke Blok

How interface translations and config translations connect in Drupal

Today, something clicked for me. At some level, I guess I knew this, but apparently I didn't know this. Config translation and interface translation in Drupal are connected. This is the part I basically knew; when you do translation imports, config will often get updated translations. I didn't really know how they were connected, though.

I ran into this while trying out Message Subscribe, a module intended to connect Flag and Message modules to allow users to subscribe to content updates. It came with a flag named Content, which I wished to rename, because it did apply to content, but apart from that, the label isn't particularly descriptive. Since the site is in Dutch, I gave it a Dutch label, translating to "Subscribe to content". As soon as I saved it, the label to the top-level admin menu entry, that would usually read the Dutch translation of simply "Content", now also became "Subscribe to content". What? Surely there was something wrong here. I clicked around a bit, changed the label back and forth. I went to look in Interface Translation. Sure enough, the translation for "Content" had changed to "Subscribe to content". I changed it back. And the label of the flag changed too. How annoying, what is going on. So, I broke out XDebug.

I found that when saving the translated config, Drupal will check if there is default configuration anywhere matching the config ID, and compare any translatable strings to that. When a match is found, Drupal will then find the interface translation matching the original, and update the translation. Which I suppose makes perfect sense at some level and it actually means my idea for a "config translation module" doesn't really make sense; as long as there is default configuration that matches the configuration you want to allow your users to translated, they can use the standard interface translation.

In case you don't know what I mean with default configuration, I mean the configuration that is in config/install and config/optional directories in a module. The config in install will get installed no matter what (and presumably will complain if some dependency is not available), that in optional will only get installed when all dependencies are available.

I did create an issue for the Message Subscribe module. I already thought the flag label was too generic, but now I found it is actively causing issues for translated sites.

Add new comment