Need to display Transalted (Localized) Vocabulary Name in Views field.



rondev’s picture

NIKS_Artreaktor’s picture

No it is not the same!

I have this setting already on. (Set Translation method to " Internationalization Views ")

In Views field we choose taxonomy term.
In the same time we have taxonomy term (translated)

What about Vocabluary name to display?
we have not it translated.

NoRiSs’s picture


I've got the same problem.
I've got the i18n and i18n_views moduls turned on and I have translated the all vocabulary names and the terms as well.
Then I wanted to make a list that is contains the terms grouped by the vocabulary names. So I made a block view. The list is displaying correctly in the original English language, but when I switch to French I have got the terms looking correct but the vocabulary names still appearing in the original English language.
The taxonomy vocabulary multilingual setting is the follows: "Localize. Terms are common for all languages, but their name and description may be localized."

In the block view I could chose the "taxonomy term name(translated)" field and it is displaying correctly in every language. But for the vocabulary name there is no option to chose translated verison even it has already translated to other languages.

Is there any solution for this issue?


nadav’s picture


decibel.places’s picture

Issue summary:View changes

I couldn't find a solution either, so I am using a custom template for the Vocabulary Name field.

I have a view that uses the Relationship: Taxonomy term: Entity translation: translations

Then I can display the fields:
Taxonomy vocabulary: Name
Taxonomy term: Rendered Taxonomy term

I copied the Views template views-view-field.tpl.php to my theme templates, and renamed it views-view-field--topics--page--name.tpl.php
(my View display is "page" and don't forget to rescan your templates!)

Another thing I like to do is group my custom Views templates by sub-folder "View Name" in the templates folder. I have a few of them for translated Views.
For example using Zen, sites/all/themes/{theme name)/templates/{view name}/views-view-field--topics--page--name.tpl.php

here is the code that returns the i18n_taxonomy_vocabulary_name for the vocabulary.

assuming that the Vocabulary machine name is the same as the Display name, but lowercase and with spaces replaced by underscores; if not, you need to do more lookups ;)

also, I could not find the vocabulary vid value in the $view, so I am looking it up by the machine name in the array returned by taxonomy_vocabulary_get_names()

= $row->taxonomy_vocabulary_name;
$vocabname = strtolower(str_ireplace(" ","_",$vocabname));
$vocabnames = taxonomy_vocabulary_get_names();
$vocabvid = $vocabnames[$vocabname]->vid;
$vocabulary = taxonomy_vocabulary_load($vocabvid);
$langcode = i18n_langcode();
$i18nvocab = i18n_taxonomy_vocabulary_name($vocabulary, $langcode);
Wtower’s picture

@decibel.places (#5) excellent workaround. Finally a breakthrough for such a miserable problem. In case anyone wonders there is also a function i18n_taxonomy_term_name (although a views field exists).