Hello,

I got the following issue when using i18n for taxonomy translation

Undefined property: stdClass::$vid dans i18n_taxonomy_term_name()

This appends on line 472 of i18n/i18n_taxonomy/i18n_taxonomy.module

I had to fix it with the code below

/**
 * Get localized term name unfiltered.
 */
function i18n_taxonomy_term_name($term, $langcode = NULL) {
    if ($term && isset($term->vid))
    {
        $key = i18n_object_info('taxonomy_term', 'key');
        return i18n_taxonomy_vocabulary_mode($term->vid, I18N_MODE_LOCALIZE) ? i18n_string(array('taxonomy', 'term', $term->{$key}, 'name'), $term->name, array('langcode' => $langcode, 'sanitize' => FALSE)) : $term->name;
    }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PasiC’s picture

Hi tehem,

thank You for posting, You've saved my life - I had exactly the same issue. Default language English with one more enabled, Hungarian.

Except for my version of Taxonomy Translation is 7.x-1.9

reszli’s picture

here's a patch for the above, that fixed the notice for me

ah_ma81’s picture

Hi @reszli .. i applied your patch and the patch in this issue https://www.drupal.org/node/1514794 and both removed the error ... thanks a lote.
but i have a big problem that any content type have Taxonomy Term Reference Tree Widget is very slow and it takes about 40 seconds to load the page.
Any help please will be appreciated.

pascalim’s picture

Re-rolled patch to apply cleanly on 7.x-1.x and replace isset() with property_exists.

pascalim’s picture

Issue summary: View changes
harshil.maradiya’s picture

Status: Active » Reviewed & tested by the community

i have tested this patch its working as expected

The last submitted patch, 2: i18n_undefined-property-fix_2093043_2.patch, failed testing. View results

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: i18n_undefined-property-fix_2093043_3.patch, failed testing. View results

pascalim’s picture

Updated patch as we are missing trailing whitespace and this is causing tests to fail.

pascalim’s picture

Status: Needs work » Needs review
prashantgajare’s picture

@pascalim Thanks, for the re-rolled patch! Tested LGTM

Vj’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed #9 works, marking it as RTBC.