Hi,
I get this error when visiting http://mysite.com/taxonomy/term/[term_id]/%2A?language=fr
I found that it may be an error in

 function i18n_taxonomy_i18n_translate_path($path) {
  if (preg_match("/^(taxonomy\/term\/)([^\/]*)(.*)$/", $path, $matches)) {
    $links = array();
    // If single term, treat it differently
    if (is_numeric($matches[2]) && !$matches[3]) {
      $term = taxonomy_term_load($matches[2]);
      if (!empty($term->i18n_tsid)) {
        $set = i18n_translation_set_load($term->i18n_tsid);
      }
    }
    foreach (language_list() as $langcode => $language) {
      if ($term) {
        if (!empty($set) && ($translation = $set->get_item($langcode))) {
          $links[$langcode] = array(
            'href' => 'taxonomy/term/' . $translation->tid,
            'title' => $translation->name,
          );
        } 

where term is called but may be undefined.
I did this to make it working:

function i18n_taxonomy_i18n_translate_path($path) {
  if (preg_match("/^(taxonomy\/term\/)([^\/]*)(.*)$/", $path, $matches)) {
    $links = array();
+    $term = false;
    // If single term, treat it differently
    if (is_numeric($matches[2]) && !$matches[3]) {
      $term = taxonomy_term_load($matches[2]);
      if (!empty($term->i18n_tsid)) {
        $set = i18n_translation_set_load($term->i18n_tsid);
      }
    }
    foreach (language_list() as $langcode => $language) {
      if ($term) {
        if (!empty($set) && ($translation = $set->get_item($langcode))) {
          $links[$langcode] = array(
            'href' => 'taxonomy/term/' . $translation->tid,
            'title' => $translation->name,
          );
        }

Comments

camdarley’s picture

Title: Notice : Undefined variable: term dans i18n_taxonomy_i18n_translate_path() (ligne 380 in... » Notice : Undefined variable: term in i18n_taxonomy_i18n_translate_path() (ligne 380 in...
webflo’s picture

Title: Notice : Undefined variable: term in i18n_taxonomy_i18n_translate_path() (ligne 380 in... » Notice: Undefined variable: term in i18n_taxonomy_i18n_translate_path()
Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Fixed
StatusFileSize
new828 bytes

Commit 8313ada on 7.x-1.x. Thanks!

kelvinleehk’s picture

Thanks for the patch @camdarley and @webflo. It works beautifully on 7.x-1.3! :)

dimitriseng’s picture

I had the same issue and #2 fixes it, thank you!

robertstaddon’s picture

Fantastic fix! #2 works. Thank you @webflo.

batigol’s picture

Yep it's working like a charm. Thank you @webflo you are again very active and helpful.

Status: Fixed » Closed (fixed)

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