I have site with a taxonomy that is set to localized mode. Translation seems to work well enough in core, except that I cannot get those fields to display properly in Views.

I know that the i18nviews is supposed to solve this problem, but it does not. What I was hoping to do is fetch all the translated data on a term and display the language appropriate content via a views preprocess or tpl override to circumvent this problem.

However, I've tried the i18n_taxonomy_term_name function (which returns an empty string) and the i18n_taxonomy_term_get_translation function (returns the term id).

I'm wondering if there are any functions that I'm overlooking to get translated data from the term. Any insights would be greatly appreciated at this point. I have only found one similar issue (#1188862: How to print translated taxonomy term?) but it was not helpful.

Thanks,
Rene

Comments

Jose Reyero’s picture

Status: Active » Fixed

See i18n_taxonomy_translate_terms()

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hatuhay’s picture

This function is what i18n uses to generate tokens i18n_taxonomy_term_name($term, $language);

mohammadjolani’s picture

user this


$term = i18n_taxonomy_localize_terms(taxonomy_term_load($tid));

print $term->name; 
// this will be loaded translated if you in English it will print the English 
// If you in ar, fr , ...... it will print the name translated else it will print the original

liquidcms’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

been struggling with this all night although i am sure i have done this numerous times before.

none of the functions above work.

i have a vocab set for localized terms: http://screencast.com/t/JZ0QUFMuQk0Z

and i have some terms which are translated: http://screencast.com/t/jZKPGkzQ

but there is no function i can see which will give me the translated term name:

i18n_taxonomy_localize_terms(taxonomy_term_load($tid)); => gives term only in EN (actually in current lang of the site)

i18n_taxonomy_get_tree($vid, $langcode); => gives nothing

i18n_taxonomy_term_name($term, $langcode)); => gives name only in EN

is it possible that Entity Translation is messing this up?

liquidcms’s picture

hmm.. testing again and now this works:

i18n_taxonomy_term_name($term, 'ar');

skyredwang’s picture

Status: Active » Closed (fixed)

#4 works.