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
Comment #1
camdarley commentedComment #2
webflo commentedCommit 8313ada on 7.x-1.x. Thanks!
Comment #3
kelvinleehk commentedThanks for the patch @camdarley and @webflo. It works beautifully on 7.x-1.3! :)
Comment #4
dimitriseng commentedI had the same issue and #2 fixes it, thank you!
Comment #5
robertstaddon commentedFantastic fix! #2 works. Thank you @webflo.
Comment #6
batigol commentedYep it's working like a charm. Thank you @webflo you are again very active and helpful.