I have installed the Glossary and i18n modules on my site, and I'm wondering how we could internationalise the Glossary module.

Glossary is a filter that searches for terms from a vocabulary in the text of nodes and adds their definition into the node.

The module appears to find the first instance of a term in the vocabulary that matches, regardless of language. This creates a problem when you have a term that is the same in two languages, for example:
"RAM" has a definition in English, and also has a definition in German. When on an English node the English "RAM" should be matched, on a German node the German "RAM" should be matched.

I would like to internationalise the Glossary module so that it checks the language of the node and then only searches the vocabulary for terms with that language. I was wondering how this should be done? Do we add a module into the i18n module? Or do we patch the Glossary module to check if i18n is active and then if it is, check the language?

Comments

AaronCollier’s picture

See #258843: i18n support for Drupal 6.x for work being done inside the Glossary module. Glossary worked fine for 5.x (see #233688: i18n support), but appears to have lost functionality in the shift to the new system of 6.x.

nancydru’s picture

I am the Glossary maintainer. I suspect this should actually be a support request. I just need to know how to identify which term is which language, if that is possible.

AaronCollier’s picture

It depends on the choice of language options for vocabulary. Under the translatable choice, each term has language set in term_data under the setting "language".
Example from my table:

INSERT INTO `term_data` (`tid`, `vid`, `name`, `description`, `weight`, `language`, `trid`) VALUES
(2, 2, 'NŠ', 'Primary School', 0, 'en', 1)

where N≈† = NŠ

Edit: And there's a function to check for translations:

/**
 * Get translated term's tid
 * 
 * @param $tid
 *   Node nid to search for translation
 * @param $language
 *   Language to search for the translation, defaults to current language
 * @param $default
 *   Value that will be returned if no translation is found
 * @return
 *   Translated term tid if exists, or $default
 */
function i18ntaxonomy_translation_term_tid($tid, $language = NULL, $default = NULL) {
  $translation = db_result(db_query("SELECT t.tid FROM {term_data} t INNER JOIN {term_data} a ON t.trid = a.trid AND t.tid != a.tid WHERE a.tid = %d AND t.language = '%s' AND t.trid", $tid, $language ? $language : i18n_get_lang()));
  return $translation ? $translation : $default;
}
nancydru’s picture

I did just see your response to http://drupal.org/node/233817. I just committed a change to all my db_rewrite_sql statements so they will hopefully get seen by i18n. This will be in the -dev version shortly. It was unnecessary in 5.x.

If you have a "language" column in term_data, then they have done something that is largely considered a no-no in Drupal. There is no "language" column in my term_data table, so they had to have modified a core table.

nancydru’s picture

Assigned: Unassigned » nancydru

As for calling functions to translate, I am extremely reluctant to do so. Glossary is already performance-bound and more calls and queries is too likely to push it over the edge and make it unusable.

nancydru’s picture

Assigned: nancydru » Unassigned

Wrong queue to assign it to myself

AaronCollier’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.