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

jrefano’s picture

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?

jrefano’s picture

so, i got it to work by using

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

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

Nchase’s picture

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

tomsm’s picture

I have the same issue.

jrefano’s picture

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.

seanB’s picture

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

tomsm’s picture

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

hukarusai’s picture

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>
tomsm’s picture

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

jhodgdon’s picture

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.

mandreato’s picture

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.

jhodgdon’s picture

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

mandreato’s picture

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.

habrda’s picture

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; ?>
mikegstringer’s picture

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; ?>
yang_yi_cn’s picture

Component: Code » Blocks

it should be


$term = taxonomy_get_term_by_name($title);
$title = i18nstrings('taxonomy:term:'.$term[0]->tid.':name', $term[0]->name); 
tangent’s picture

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.

Jose Reyero’s picture

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

Moving to the right module.

thelinhuk’s picture

Issue summary: View changes

This method works on Drupal 7 as well, I used one of the views template, in my case views-view-unfomatted-'VIEW-NAME' and following code on template:

// Get Taxonomy translation

   $taxonomy = taxonomy_get_term_by_name($title);
    $taxonomy_key = array_keys($taxonomy);
    $taxonomy_key = $taxonomy_key[0];
    $i18n_object = i18n_get_object('taxonomy_term', $taxonomy[$taxonomy_key]->tid);
    $target_langcode = $language->language;
    $translated_term = $i18n_object->localize($target_langcode);

    $vars['translated_track'] = $translated_term->name;

    print '<h3>'. $translated_track . '</h3>';
    foreach ($rows as $key => $value) {
        print '<div class="' . $classes_array[$key] . '">';
        print $value;
        print '</div>';
    }


dpayk’s picture

Just in case someone gets here looking for a solution why group fields are not translated in a normal view: The solution is to change the "Formatter" of the field from "Default" to "Default translated".

hommesreponse’s picture

@dpayk thank you!