I'm using Vocabulary Index on a multilingual site with taxonomy and the i18n module. I have set up the translation mode for my vocabulary using the 2nd option: "Localize terms. Terms are common for all languages, but their name and description may be localized." Then I translated the vocabulary name, all the terms and their descriptions using the taxonomy translator page of the "Translation table" module. This works very well with the core features, but when I use Vocabulary Index, this is all displayed in the default language only.

The problem is that Vocabulary Index does not translate these terms, except in one place. But there, it uses the t() function. However, for translation of the taxonomy terms the tt() function should be used.

I have attached patches for the vocabindex.module and vocabindex.view.inc files which use the tt() function in all places where I think it's necessary. It works nicely for me.

(I'm not sure if tt() is available when i18n is not installed. If not, maybe we need to replace it with a dummy function in this case.)

Comments

xano’s picture

Status: Active » Needs work

Great initiative! :) Could you provide one large patch made with cvs diff -upN > foo_bar.patch from Vocabulary Index' root folder? This makes the patch more readable and therefore easier to review. We also need a wrapper function for this so Vocabulary Index doesn't require i18n. Something like this:

/**
 * Translate Taxonomy data.
 *
 * @param $object
 *   The term or vocabulary object to translate a property from.
 * @param $text
 *   What property to translate. Either 'name' or 'description'.
 */
function vocabindex_t($object, $text) {
  if (isset($object->tid)) {
    $id = $object->tid;
    $type = 'term';
  }
  else {
    $id = $object->vid;
    $type = 'vocabulary';
  }
  if (function_exists('tt')) {
    return tt("taxonomy:$type:$id:$text", $object->$text);
  }
  return $object->$text;
}
Cito’s picture

StatusFileSize
new9.14 KB

Ok, here it is.

xano’s picture

Whoa, that is one weird patch, hehe :-P

I'll take a closer look at it tomorrow, thanks! :)

aimevp’s picture

Hi,

Is it possible it isn't just a Vocabulary Index problem? I have the same issue in my views. I don't have this module installed.
My situation is this:

I have a multilanguage website with a page called downloads. I made a language neutral custom content type to upload files. And each upload is categorized by a vocabulary that I've setup with the "localize terms" option. Then I made a view where the terms are used in an exposed filter. I had hoped that when I translate my terms i would see the translation in my dropdown box but I hoped wrong.

Initially while making my vocabulary I selected "english" as language of my vocabulary because I thought you needed to select a starting point for the translation. But in my view there were suddenly no terms available when i switched the language.

When I deleted the language specification in the database (for voc. and all terms) I had better but not perfect results. Then I got the english terms when I switched the language but no translation.

So I'm wondering if this isn't a taxonomy or i18n issue? Or is it me who did something wrong?

Grtzzzzz,
Hatznie.

xano’s picture

Taxonomy does nothing with term translation. i18n works fine, Vocabulary Index just wasn't integrated with it well enough.

Cito’s picture

@hatznie: i18n provides the translation for taxonomy terms as a special feature. The only problem is that most modules - including Views - do not (yet) make use of this feature.

Cito’s picture

By the way, the Taxonomy Menu has a similar problem (http://drupal.org/project/issues/taxonomy_menu).

xano’s picture

Title: Taxonomies with localized terms are only displayed in the default language » i18n integration
Version: 6.x-2.x-dev » 5.x-2.x-dev
Status: Needs work » Postponed (maintainer needs more info)

I tried i18n 5.x-2.5, but I couldn't find the option for multilingual vocabularies I know from 6.x-1.0. We need to find out what's possible for Drupal 5 and create patches for both branches.

arski’s picture

Umm, I tried applying this patch but it doesn't seem to really work... a lot of rejects etc. Could you please update the patch to the latest version of (6.x) vocabindex? Thanks!

micheleannj’s picture

subscribing

micheleannj’s picture

Just dug around in the code and, it's not a robust solution, but you should be able to just change the following

function vocabindex_term_link($term, $vi) {
$term->path = taxonomy_term_path($term);
$term->name = check_plain(t($term->name));

to

function vocabindex_term_link($term, $vi) {
$term->path = taxonomy_term_path($term);
$term->name = check_plain(tt($term->name));

(it's "t" to "tt" in the last line).

The same thing would have to happen in the alphabetization functions too, or the sort order will be off...

eiland’s picture

just, enlighten me, does this now work for D6.3 I just installed it and it seems not to?

eiland’s picture

See http://truuk.climatesceptics.org/en/positie-van-de-boven - this page does only use 18n for the links, but not for the descriptions.

gritter’s picture

The solution in #11 did not work for me (error message), but with a slight modification, it's ok:
vocabindex-6.x-2.3, file vocabindex.view.inc, line 590:
Replace
$term->name = check_plain(t($term->name));
by
$term->name = check_plain(tt("taxonomy:term:$term->tid:name", $term->name));

xano’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Vocabulary Index 5.x-y.z is no longer supported.

eiland’s picture

Version: 5.x-2.x-dev » 6.x-2.3
Component: Translations » Code
Status: Closed (won't fix) » Active

yo xano, drupal five already died a long time ago!