i18n integration

Cito - March 31, 2009 - 23:46
Project:Vocabulary Index
Version:5.x-2.x-dev
Component:Translations
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

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.)

AttachmentSize
vocabindex.module.patch861 bytes
vocabindex.view_.inc_.patch763 bytes

#1

Xano - April 1, 2009 - 17:01
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:

<?php
/**
* 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;
}
?>

#2

Cito - April 1, 2009 - 21:34

Ok, here it is.

AttachmentSize
vocabindex.patch 9.14 KB

#3

Xano - April 1, 2009 - 21:37

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

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

#4

hatznie - April 2, 2009 - 14:14

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.

#5

Xano - April 2, 2009 - 14:36

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

#6

Cito - April 3, 2009 - 15:18

@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.

#7

Cito - April 3, 2009 - 15:18

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

#8

Xano - April 12, 2009 - 21:20
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.

 
 

Drupal is a registered trademark of Dries Buytaert.