Note: This page is for Drupal 6. For Drupal 7 find https://www.drupal.org/node/1114016


The Taxonomy translation module (part of the Internationalization package) provides multiple options to translate taxonomy vocabularies and terms. For each vocabulary you'll have to choose one of four different modes defining 'multilingual' behaviors for the vocabulary:

  1. None. No multilingual options for this vocabulary (default).
  2. Localize terms. Terms are common for all languages, but their name and description may be localized.
  3. Per language terms. Different terms will be allowed for each language and they can be translated.
  4. Set language to vocabulary. The vocabulary will have a global language and it will only show up for pages in that language.

When a language is set for a vocabulary or term, only those items that match the current language will appear in taxonomy listings and when creating and editing nodes. If the language is set for a vocabulary, all the terms in that vocabulary will be automatically set to that language.

Per language terms

Creating terms with language is simple with the Internationalization package. For example, we created the vocabulary 'colours,' which has no language assigned to it, thus allowing terms in multiple languages within the same vocabulary.


Figure 1: Creating a vocabulary that will allow multiple language terms within it.

Creating multilingual terms
Figure 2: Creating a taxonomy term with English language.

Then we created the terms 'red', 'green', and 'blue' in English and 'rojo', 'verde', and 'azul' in Spanish. If we go to the 'Translation' tab and click on Add translation, we can choose a term for each language that will be part of this translation.
Translating terms
Figure 3: Creating term translations.

If we repeat this process for the three terms, we can see all the translations in the Translation tab
Term translation tab
Figure 4: Term translations.

Once we have terms and translations, only the correct terms for each language will show up while browsing the site. When we are editing a node, only the terms for that node's language will be available.

Localizable terms

These are terms that should be originally created in the site's default language, though they may be translated later using the Interface Translation features. Read more about user-defined strings.

An important limitation of localizable terms is that when using these vocabularies as Tags, terms can only be edited and created using the default language. If this doesn't suit your needs consider creating a different vocabulary for each language by using the 'Set language to vocabulary' option.

Comments

apdp1000’s picture

Hi, Thanks for the great tutorial.

What am I doing wrong?

I want my users to submit a form in one of two languages, which they choose. They must choose
from some taxonomy terms. I make some "per language" terms and associate translations, I flag "synchronize taxonomy terms"
on the content type. When I view the submission form, the taxonomy terms appear in the correct language in the select box,
according to the language chosen in the language switcher, which is cool, and the user then chooses the appropriate terms and submits the form.
But after the form is submitted and the node viewed, the terms do not change language according to the language selected in the language switcher but
persist in the language they were submitted in. What I want is for users to submit the form once, choosing from taxonomy terms in the language they understand,
but then other users should view the form in the langauge they choose. How can I do this?? Any help appreciated. My version is 6.x-1.0

mcload’s picture

"per language" setting should be working as you described, but it is not working. I had the same problem and submitted a bug report to http://drupal.org/node/367287 two weeks ago.

binhcan’s picture

I'm building Classical Chinese Furniture website and faced exactly the same problem you r facing now. And here is my answer to your problem.

If you want to use "synchronize taxonomy terms" you must choose the "Localize terms" options.

If you use "Per language terms" you must disable synchronization for terms.

Sadly life is like that. I also don't know what to do. I want the term url to be different for each language but if I do so the terms are not synchronized...

hades666evil’s picture

Hi,

For a multilanguage websiet with Localized terms, I've a function in a custom module where I need to print some terms attached to node. I use this code :

$terms = taxonomy_node_get_terms_by_vocabulary($myNode, $myVocabularyId);
foreach($terms as $term) { $text.= t($term->name);}
retrn $text;

But no way to get a term in another language than the original one.
Even if I use t($term->name, array(), "fr"); the term retured stay in english (the original language).
The terms are translated using the translation table module.

Any idea how to do this ?

hades666evil’s picture

Finally, I managed to do it using the i18nstrings tt function like that :

$terms = taxonomy_node_get_terms_by_vocabulary($myNode, $myVocabularyId);
foreach($terms as $term) { $text.=tt('taxonomy:term:'.$term->tid.':name',$term->name);}
retrn $text;
seg108’s picture

Hi, Any help appreciated.
All my 6.13 menu items are in the primary links menu, generated from vocabs and terms by Taxonomy Menu. Now trying to get multilingual menus working.
Vocabulary names are primary links tabs, with terms in drop downs - so I'm thinking "Per language terms" is not best match as the vocab name is not translated (and I use them as tabs). "Localize terms" seems to be ideal for place names, for which I have 2 vocabs, but is not suitable for my category vocabs. "Set language to vocabulary" seems a good choice for category vocabs, but failing to get this working. Primary menu tabs, although set for different languages, are not changing when I switch language. Also I notice that despite selecting language on vocabulary settings page, when I flip over to view the primary menu item settings, I see that each item's language setting is "all languages". If I were to change the individual menu item language settings, taxonomy menu will change them again when rebuilding menus.... Multilingual system setting for content selection is "Only current language". Language negotiation is "path prefix only". Am I better off switch to domain specific approach? Thanks in advance.

mikekasky’s picture

Check http://drupal.org/node/313302

You have to recreate the primary links menu, generated from vocabs and terms by Taxonomy Menu, in all your languages.

First create a menu PER language.

Second, fill each menu with exact same menu items only with menu title translated to the additional language.

Example:
primary-links (set to English) has Red, Green, Blue
primary-links-de (set to German) has Rot, Grün, Blau
primary-links-fr (set to French) has Rouge, Verte, Bleu

All three menus a completely independent of each other. But if placed in the same space on the page, they replace each other whenever the language is switched.

olmega’s picture

Thanks Mike I was fighting with taxonomy for hours! The easiest way to make it happen, it works without a problem, just great.

kasiawaka’s picture

To setup a Taxonomy that will use more then one language and will use Views to control how the nodes assigned to taxonomy terms are displayed, I used those steps:

1. Install and configure the environment
This was tested on a clean Drupal 6.16 installation with following modules installed and enabled:
- Content translation (core)
- Locale (core)
- Internalization 6.x-1.3 (i18n 6.x-1.3): Internalization, String translation, Synchronize translations, Taxonomy translation
- a few other basic modules, like CCK, Views, Pathauto and Token

2. Configure i18n module
This example uses English and French as the two languages used for Taxonomy. Please use your language of choice here.

1. Site configuration > Languages > List
- Added French
- Edited English, added 'en' (without '') as a prefix

2. Site configuration > Languages > Language negotiation: Path prefix with language fallback.

3. Site configuration > Languages > Multilingual system: Content selection mode: Only current language

3. Configure Content Type
Here we are going to edit chosen content type (in this case Page) to make it ready for multilanguage support. Edit Page Content Type and update:

1. Workflow settings -> Multilingual support: Enabled, with translation. Saved, opened again Page content type to edit and setup as below

2. Multilanguage options -> Options for node language > checkmarks next to "Set current language as default language for new content" and "Require language (Do not allow Language Neutral)"

3. Multilanguage options -> Synchronize translation -> checkmark next to the "Taxonomy terms". (IMPORTANT)

4. Create new Multilingual Taxonomy
I did it as it is described in the article on top of the page but to keep things in one place, I will repeat the steps here:

1. Created new taxonomy with the "Translation mode: Per language terms".

2. Added all English terms.

3. Added all French terms.

4. Edited the translation of this taxonomy (Translation tab) and assigned English and French terms to be each other translation.

5. Change default taxonomy view
To be able to control how the nodes assigned to the taxonomy terms are displayed, I've enabled the taxonomy_term default view and modified it:

1. Changed the View display type: Basic Settings > Row style: Fields

2. Added new filter: Node translation: Language = Current user's language

3. Added some fields I want to this view to display.

4. Did not change the Page display path, that will be done automatically by the Path module.

The result
I have bilingual taxonomy with nodes assigned to different terms. When I use the language switcher on the site, not only the content of the view changes accordingly (from EN to FR content) but also the View title changes from English term to French term and the URL path changes.

Troubleshooting
A few tips for those who will run into problems when setting this up on the site that already has some content. When I was setting up this multilingual taxonomy on the website that already had bunch of content and URL aliases in place and different Views that were suppose to display those taxonomy terms, nothing was working: the language switcher was not changing the taxonomy display and if it was, the View title was not switching between English and French.

To solve that I:

1. Made sure that the Taxonomy is set to be "Translation mode: Per language terms".

2. Made sure that the Content Type is set to synchronize the Taxonomy translation (described in 3.3)

3. Deleted all Views that were controlling the display of the taxonomy terms. You can also export them and then delete them and when everything works well, import them back and see if they break anything.

4. Delete all URL aliases: Site building > URL aliases > Delete aliases

5. Re-create URL aliases for nodes: Site building > URL aliases > Automated alias settings: Under "Node path settings" put a checkmark next to "Bulk generate aliases for nodes that are not aliased". If you have a lot of nodes, you may need to repeat this procedure more then once - you will notice how many of them were created in the confirmation part on top of the screen. If there were 50, you may need to repeat this process until the confirmation shows "0 created".

6. Re-create URL aliases for taxonomy: Site building > URL aliases > Automated alias settings: Under "Taxonomy term path settings" put a checkmark next to "Bulk generate aliases for terms that are not aliased". If you have a lot of terms, you may need to repeat this procedure more then once.

7. Re-create URL aliases for users, if you were using it.

8. Make sure you are using the native "Language switcher" block to test the functionality. I stumbled upon a custom language switcher that was not working and it made me thing that the whole translation is not working. So, when in doubt, use the "Language switcher" block to test what you've setup.

Notes
I also tested the taxonomy with "Translation mode: Localize terms". I set it up, added English terms and used the "Site building -> Translate interface" to add French terms (I had to use the Refresh tab to make the translation recognize just added English terms).

This worked fine until I turned on the Path and Pathauto module and enabled taxonomy_term View to control how the nodes assigned to taxonomy terms are displayed. What happen at this point was that the View title was not anymore changing the Title to be English and French, according to the site language and also the URL was not switching between English and French URL.

I hope this long explanation will help someone to setup properly the multilingual taxonomy.

Kasia W

jiakomo’s picture

Thanks kasiawaka,
did you also manage to have translated vocabularies/term paths in URLs with pathauto? Because this is currently the only thing not working for me.

kasiawaka’s picture

Hi jiakomo,
Yes, I was able to have the URLs translated with the pathauto but only partially - the term is translated but the vocabulary is not.
For example, the vocabulary is "topic" and this is not translated but the vocabulary "aboriginal health" is, so for the English and French pages I have URLs:
http://www.nursesunions.ca/topic/aboriginal-health
http://www.fcsii.ca/topic/la-sant-des-autochtones

I also do a domain switch when switching the language, but you can ignore that part.

If you want to see this solution implemented, please visit http://www.nursesunions.ca (this is a live site, not a demo).
The "Topics" menu item displays all taxonomy terms from the "topics" category. You can pick any of the terms and switch the language to see how that works.

Hope that helps.

Kasia W

porg’s picture

@kasiawaka: Thank you for sharing your information in such a carefully documented style! Sadly, realizing a multi-lingual-site is still a PITA, and I am not referring to the tasty flat bread common in South-West-Asia, quite a complicated endeavor! Hence I really appreciate your documentation!

I would have taken the effort of creating Per language terms and synchronize its terms, so that each term gets its own ID, allowing it to be aliased in its native language, hence creating taxonomy-URLs per language. But as ONLY the term is translated, but NOT its parental vocabulary, the pathauto generated taxonomy URL is again not language pure, hence I am not going for it and rather use Localize terms and use taxonomy URL aliases in my sites most universal language (=English) or I may use their plain numerical IDs.

Important reminder: If you use taxonomy translation with Localize terms and use i.e. translation_table for translating your taxonomy (plus menu, and similar strings), then you shall create all your strings in the default language, then translate it into the other languages, and then not change the default language ever! If you later change the default language, then the taxonomy terms will only show up in the originally created language, regardless of what display language your reader chooses!

marcel66’s picture

Hello all,

Thank you for your tutorial.

I have used taxonomy_term_count_nodes($tid, $type = 0) before to transform my site in a multilingual one.... now I think it will be useful to have a function like taxonomy_term_count_nodes($tid, $type=0, $language=NULL)....

Do you have any other solution ?

Thank you all,
Marcel

ropazo’s picture

Take care of the following sentence: "(...) match the the current (...)".