Vocabularies and term settings for tagging content on multilingual Drupal sites

In the past two blog posts here, we've covered some of the basics for setting up a multilingual blog. We've seen that it's not the most simple process when translations are involved. Now we are going to look at the Drupal taxonomy system a bit more and at modules that are handy for working with and translating terms. While we are looking at this from the perspective of tagging blog posts, none of this should be specific to blog content. You should be able to follow the steps here to tag any kind of content. Note: This tutorial is for Drupal 6.x, but has some applicability to other major Drupal versions.

Create a tagging vocabulary...

Create a tagging vocabulary

We actually did this in a previous blog post, but it provides a good "starting point" for exploring tags in greater depth.

We want the vocabulary to translatable and we've found that "localizing" terms sometimes doesn't provide as good features where other modules (e.g. tag clouds, related content blocks, term selection widgets, etc) are concerned. It's a bit more work to manage creating a separate term for each language, but it will save us some headache. (Actually, we had the headache, but you don't have to ... or at least you'll probably find things go easier if you just use the "Per language terms" option.)

Since it's a free-tagging vocabulary we can select "Tags" and "Multiple select"

Select tags and multiple select

We are going to allow authors to create new tags, if necessary, and each post might receive several tags. As I wrote before, although we technically want to "require" them, this may introduce issues when it comes to uploading or importing content, etc.

The Taxonomy Manager module is well worth having around...

Drupal Taxonomy Manager module

We can start by anticipating some of the terms we'll be using and entering them, assigning them to a language, and translating (adding equivalent terms for German and English). We can even create a hierarchy of terms, where it makes sense.

The especially nice thing about the Taxonomy Manager module is that it allows you to add multiple terms at once and has a better interface for matching translated terms. It's not perfect, though, so you may need to sometimes manage translations with the core "translation" system.

Even if you aren't running a multilingual site, Taxonomy Manager is awesome. You can merge existing terms or move terms from one vocabulary to another, or create a group of terms all at once, into the same branch of a hierarchical taxonomy tree (which is what we are doing in this screenshot). The terms, "Content translation", "Taxonomy translation", and "translation management" are all imported as child terms of "Translation", another term we've just created.

Translate terms to other languages

Translate terms to other languages

And now we can add new terms in another language (German, in this case), and simultaneously link them to the English term we have selected. So now we can tag an article in English and when we go to translate it to German, it will already have the German versions of those same tags.

Note: Be sure to click the "plus" icon to the right of your translation, or the new term (or translation link, if the term already exists in the other language) won't actually be created.

After clicking on "plus" you'll see your new term translation.

Your new term translation has been added.

This is what a successful translation of terms looks like. We can quickly do the same for our other terms.

Sometimes it's hard to translate terms which are the same... enter "Core" taxonomy translation.

Drupal taxonomy translation in core.

Some of the terms we use in Drupal are not translated when we use them in German, but we still need to provide a German version if we want to use those tags to categorize German content. For instance, I'm tagging this post with "Drupal 6", which is also "Drupal 6" in German. This can cause issues when it comes to selection of parents with the same name (but different languages), etc. In some cases you will need to use the core translation and relationship management.

You can find the "Translation" tab (in a vocabulary which is "per language") on the "list terms" page. Our "Tags" vocabulary has a "vocabulary ID" of 7, so the direct path to the Drupal translation interface is found at: /admin/content/taxonomy/7/translation

Below the existing translations you will see a "Create new translation" link. If you click on it, you'll be able to select terms from pairs of drop-down select lists for any terms which have already been created in German and English (or any language pair) and link them as translations. But unlike in Taxonomy Manager, we can't create new terms or re-assign the language of a term in this interface. It's a much slower process, but you will probably still find times you need to use it.

Be sure to check out the "Double Tree" tool

Drupal Taxonomy Manager Double-Tree tool.

The "Double Tree" tool is one of the nicer features of the Taxonomy Manager module. You can move terms from one language to another (useful if you've accidentally added a bunch of terms, but they were added as "language neutral" or into the wrong language). You can also move terms to another vocabulary or into a different position in the hierarchy of one vocabulary "tree".

The "merge" tool is another must-have feature in Taxonomy Manager

The merge tool in Taxonomy Manager is also highly recommended.

It happens. You create a term and then you create another term by accident -- one with the same meaning, but perhaps misspelled or using an alternative spelling. We don't want to categorize the same kind of content with two different tags, so we want to merge such terms back into one. This can be a problem if content is already tagged with both of the terms. Here I am merging two terms back into one term, but you can perform much more complicated merges, including adding a new term to replace existing ones.

The Translation table module is also useful for taxonomy translations

Drupal Translation Table module

Unfortunately, the Translation table module only provides "string translations" (localizations) of terms, so we won't have anything we can use it for in a "per language" vocabulary, but if our planned uses of the Tags vocabulary meant that we could use "localized" terms, this would be a very handy tool for us. It's still helpful for other vocabularies you might use on your site, such as the "Channels" vocabulary we use on Drupal.Cocomore, which drives the menuing system. If a term will work in both languages, we don't translate it, and otherwise we have an overview of terms that need translation and can easily enter them.

I'd personally like to see the Translation Table module extended to allow "per language" term linking and adding new terms in one language as translations of terms in another language. This module is also useful for managing other string translations, so is a useful tool to have in your translation took kit.

In our follow-up to this post, we'll be using our new Tags vocabulary to add a "Related content" links block and a "Tag cloud" block, and of course we need the terms in the "cloud" and linked articles to match the current user's language. The modules that provide these links are simple to set up... but to get them working in a multilingual environment can be a bit tricky. Stay tuned.