Download & Extend

When grouping a view on taxonomy term, term is not translated

Project:Internationalization Views
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Title says it all... I have a view grouped on taxonomy term and I always get the default (English) no matter what. Anyone know what to do about this?

Comments

#1

i sorta got it to work by messing with my views-view-unformatted.tpl.php file, and instead of just printing $title i'm using:

print tt('taxonomy:term:name',$title);

however, this creates a NEW string, which i can easily translate, but i'd like to use the existing translation for the term. if i look at my translation interface search results, the proper textgroup and name looks something like "term:116:name" ... but since this is supposed to be multi-purpose, i can't use a static tid like that. i suppose i could look up the tid from the title text and jam it in there, but is there a way to do this i'm not understanding?

#2

so, i got it to work by using

<?php
print tt('taxonomy:term:'.$term[0]->tid.':name',$title);
?>

but that doesnt feel like the right way. any insight greatly appreciated.

#3

having the same issue, taxonomy terms on a node sorted ascending using arguments -> no translation showing up

#4

I have the same issue.

#5

you guys should try my theme layer fix (above). sure, it's a bit of a hack, but my site needed this functionality and i didn't have the time/expertise fix i18n views.

#6

I have this problem too! Am I forgetting a certain setting or is this really a bug?

#7

Yes, you can call it a bug.
I have been waiting some time for a fix allowing translation of taxonomy terms in views.

#8

Hi.. I have same problem and this is my solution.
- Edit $title in views-view-grid.tpl.php (my style)
- And use Translate interface...

      <?php if (!empty($title)) : ?>
        <td colspan="2">

        <?php
          $star
= strripos($title,'">')+2;
         
$leng = strlen($title)-strripos($title,'">')-6;
         
$term_name = substr($title,$star,$leng);
         
$title = str_replace($term_name,"",$title).t($term_name);
       
?>


            <h3><?php print $title; ?></h3>
        </td>

#9

Thanks for the tip. The disadvantage is that you have to translate every taxonomy term again using "Translate interface".

#10

I think this is the same issue as #976872: Taxonomy terms are not translated in Views, which has a patch (against the Views module) to fix this problem. I'm closing the other issue as a duplicate of this one.

#845616: i18n taxonomy: translating standard Views taxonomy term field also seems to be related, and also has a patch.

#11

I've investigated the function render() in ...\sites\all\modules\views\plugins\views_plugin_style.inc and found that the taxonomy grouping term is $title, but can't image how to translate it.

Maybe it should be added a function in i18nviews to extend views_plugin_style in the same manner i18nviews_handler_field_taxonomy does for taxonomy terms to translate them.

#12

You might check the patch I posted on #976872: Taxonomy terms are not translated in Views

#13

I'm sorry, I forgot to mention that I tried your updates on
...\sites\all\modules\views\modules\taxonomy\views_plugin_argument_validate_taxonomy_term.inc
...\sites\all\modules\views\modules\taxonomy\views_handler_argument_term_node_tid.inc
but it didn't fix this specific issue (view my bug description here: http://drupal.org/node/887720#comment-3710990).

I don't think that it's a duplicate of #976872: Taxonomy terms are not translated in Views.
Probably a fix similar to yours should be applied also to
...\sites\all\modules\views\plugins\views_plugin_style.inc
but I don't know PHP enough to do it.

#14

Hi.. this is my solution

1. in View set grouping by Term ID without Label
2. Edit views-view-unformatted.tpl.php for my style and instead of just printing $title i'm using:

<?php if (!empty($title)): ?>
    <?php $term = taxonomy_get_term($title); ?>
    <h3><?php print tt('taxonomy:term:'.$title.':name', $term->name);  ?></h3>
<?php endif; ?>

#15

I got this working using theming with a small tweak to the example code above:

In views-view-unformatted.tpl.php, change:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>

to:

<?php if (!empty($title)): ?>
    <?php $term = taxonomy_get_term_by_name($title); ?>
    <h3><?php print i18nstrings('taxonomy:term:'.$term[0]->tid.':name', $term[0]->name);  ?></h3>
<?php endif; ?>

#16

Component:Code» Blocks

it should be

<?php
$term
= taxonomy_get_term_by_name($title);
$title = i18nstrings('taxonomy:term:'.$term[0]->tid.':name', $term[0]->name);
?>

#17

Component:Blocks» Taxonomy

I've run into this bug as well. Is the bug in views or in i18n? I don't have time to look at the moment so I've implemented the theme work-around above.

Is doesn't seem that blocks is the appropriate component so I'm changing it even though taxonomy might not be the right one either.

#18

Project:Internationalization» Internationalization Views
Version:6.x-1.1» 6.x-2.x-dev
Component:Taxonomy» Code

Moving to the right module.