I read the several issues related to this problem, but still cannot say if I experience a bug, a missing features or lack of understanding.

I created a vocabulary named "glossary".
I set its translation mode to "Per language term"
The site has 3 languages: French, English and Greek
I created terms in English (default) and French.
Some terms are identical in both languages, there description being in the corresponding language
Other terms are different for the same meaning.

1) The glossary page behave this odd way
- Current language = English : display only English terms
- Current language = French : display all terms
- Current language = Greek : display only English terms

2) Whatever is the language's term, Glossary seems to pick the first it encounters to describe the term within content. Not any kind of relationship between the term language and the content language.

For example, I defined 3 terms
Automation (en) + english description
Automation (fr) + French description (2 versions of the same term)
Automatisation (fr) + French description (another translation of the same term)

I wrote these 2 words in 2 pages, one English and one French
Glossary displays the same descriptions in both cases
- the English one for Automation (2 versions, take the first)
- the French one for Automatisation (only a French term, take it anyway)

Is it the expected behaviour: no translation capabilities, terms must be defined only ones, no language, with the description field filled with all translations together
Do I miss something?
Is it a Bug?

Thank you

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

harrrrrrr’s picture

same problem here

Aleksic’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
Component: Documentation » Code
Category: support » feature

I have same problem. Do you plan to do something about capability for translation? It would be great for multilingual site.
Thanks

harrrrrrr’s picture

if you use different terms/language in taxonomy, you can change this function in glossary.module & it will work:

function _glossary_get_terms($format) {
  static $terms = FALSE;
  $show_all = variable_get('glossary_allow_no_description', FALSE);
  $taxonomy_image_enabled = module_exists('taxonomy_image');

  if ($terms === FALSE) {
    $terms = $synonyms = array();
    $vids = variable_get("glossary_vids_$format", 0);

    foreach ($vids as $vid) {
      $synonyms = _glossary_get_synonyms($vid);

      // Get all glossary terms and attach synonyms.
      // Omit terms without a description. those are usually container terms.
      $result = db_query(db_rewrite_sql("SELECT t.tid, t.name, t.description, t.language, COUNT(tn.nid) as nodes FROM {term_data} t LEFT JOIN {term_node} tn USING(tid) WHERE t.vid=%d GROUP BY t.tid, t.name, t.description ORDER BY LENGTH(t.name) DESC", 't', 'tid'), $vid, i18n_get_lang());
      while ($term = db_fetch_object($result)) {
        if ($term->nodes) {
          // If there were any nodes attached, we need to see if they were unpublished.
          $unpubs = db_result(db_query(db_rewrite_sql("SELECT COUNT(n.nid) FROM {term_node} tn JOIN {node} n USING (nid) WHERE tn.tid=%d AND n.status=0"), $term->tid));
          $term->nodes -= $unpubs;
        }
        if ($term->description || $show_all) {
          $term->synonyms = $synonyms[$term->tid];
          $term->synonyms[] = filter_xss($term->name);
          $term->vid = $vid;
		  if($term->language == i18n_get_lang()) {
			$terms[] = $term;
		  }
        }
        if ($taxonomy_image_enabled) {
          $term->image = taxonomy_image_display($term->tid);
        }
        else {
          $term->image = NULL;
        }
      }
    }
  }
	
  return $terms;
}
dademurphy’s picture

Title: How glossary works with translations (or does it really work with)? » Glossary Fix to make it language aware

//added access to the global $language
//made the sql query that loads the terms use the language in the where clause.

function _glossary_get_terms($format) {
static $terms = FALSE;
global $language;
$show_all = variable_get('glossary_allow_no_description', FALSE);
$taxonomy_image_enabled = module_exists('taxonomy_image');

if ($terms === FALSE) {
$terms = $synonyms = array();
$vids = variable_get("glossary_vids_$format", 0);

foreach ($vids as $vid) {
$synonyms = _glossary_get_synonyms($vid);

// Get all glossary terms and attach synonyms.
// Omit terms without a description. those are usually container terms.

$result = db_query(db_rewrite_sql("SELECT t.tid, t.name, t.description, COUNT(tn.nid) as nodes FROM {term_data} t LEFT JOIN {term_node} tn USING(tid) WHERE t.vid=%d and t.language = '%s' GROUP BY t.tid, t.name, t.description ORDER BY LENGTH(t.name) DESC", 't', 'tid'), array($vid,$language->language));
while ($term = db_fetch_object($result)) {
if ($term->nodes) {
// If there were any nodes attached, we need to see if they were unpublished.
$unpubs = db_result(db_query(db_rewrite_sql("SELECT COUNT(n.nid) FROM {term_node} tn JOIN {node} n USING (nid) WHERE tn.tid=%d AND n.status=0"), $term->tid));
$term->nodes -= $unpubs;
}
if ($term->description || $show_all) {
$term->synonyms = $synonyms[$term->tid];
$term->synonyms[] = filter_xss($term->name);
$term->vid = $vid;
$terms[] = $term;
}
if ($taxonomy_image_enabled) {
$term->image = taxonomy_image_display($term->tid);
}
else {
$term->image = NULL;
}
}
}
}

return $terms;
}

AaronCollier’s picture

Status: Active » Needs review

Needs a patch to test.

Mortel’s picture

First of all, sorry for my english...

I had a problem with the language switcher. I explain :

I have 2 languages (french and english) and I created 2 terms:
- Ordinateur (fr) (tid = 88)
- Computer (en) (tid = 89)

I went to "Ordinateur" page (http//site/glossary/term/88) and when I clicked English to translate that term, its link was "http://site/en/glossary/term/88" (it was supposed to be http://site/en/glossary/term/89), I had an empty page (I mean no term and no definition).

To fix my problem, I added this code at the end of glossary.module :

/**
 * Implementation of hook_translation_link_alter().
 *
 * Replaces links with pointers to translated versions of the content.
 */
function glossary_translation_link_alter(&$links, $path) {
  if (module_exists('i18ntaxonomy')) { 
	  if (preg_match("/^(glossary\/term\/)([^\/]*)(.*)$/", $path, $matches)) {
		foreach ($links as $langcode => $link) {
		  if ($str_tids = i18ntaxonomy_translation_tids($matches[2], $langcode)) {
			$links[$langcode]['href'] = "glossary/term/$str_tids". $matches[3];
		  }
		}
	  }
  }
}

Anyway, it works for me, my problem is solved :)

walwyn’s picture

subscribing

walwyn’s picture

1) The glossary page behave this odd way
- Current language = English : display only English terms
- Current language = French : display all terms
- Current language = Greek : display only English terms

This issue can be fixed by inserting:

      global $language;

      // See if this term is in current language
      if ($term->language != '' && $term->language != $language->language) {
        continue;
      }

after the following lines in glossary_overview (glossary.module L854:)

  if ($tree) {
    foreach ($tree as $term) {

The problem is that the call to taxonomy_get_tree($vid) is getting all of the terms for the vocabulary when the user's current language isn't the default one, so you have filter out the ones you don't want.

toastywaffles’s picture

Thank you Mortel! Was having the exact same problem, where switching the language of the site did not find the appropriate node id for glossary terms. This fixed it.

davemybes’s picture

FileSize
2.62 KB

Thanks Mortel, that worked nicely for the glossary page. I had to add some more code to allow for cases where the French and English term name was the same, but the description was translated. By default, the module seems to just grab the first one, which happens to be the English one in my case. This results in the tooltip being in English on French pages. So I added the language field to the term db_query, and then check against the language before adding the term to the list to be used for the tooltip. See the attached patch, which includes Mortel's above.

mkalkbrenner’s picture

Category: feature » bug
FileSize
681 bytes

Patch from #10 is obsolete and doesn't apply against dev version anymore. They solved the same problem differently. But the issue form #8 still exists. But the fix needs a small adjustment to not create warnings when i18ntaxonomy isn't installed. Here's an adjusted patch.

justingeeslin’s picture

I'm looking to make the Glossary work with multiple languages as well. I'll test this patch in the future and see how it goes.

justingeeslin’s picture

Hello,

I've noticed that the latest 6.x dev is still not ready for Glossaries translated into other languages.

Attached is a patch for the latest 6.x dev.

In this patch, I added a lot of t() functions and I had to sort terms by their translated equivalent word
The input filter/word filter is also working correctly.
I am not sure if I'm tackling all the issues of the above patches.
This seems to get the job done for me.

Nicolas Bouteille’s picture

Post #6 made my day !

Terms were translated but switching language from a term page was not leading to the translated term. Now it works ! Thanks Mortel

NancyDru’s picture

Status: Needs review » Closed (outdated)