Skip to content

Instantly share code, notes, and snippets.

@keeprock
Last active August 29, 2015 14:18
Show Gist options
  • Save keeprock/af19702e1c5b99795a90 to your computer and use it in GitHub Desktop.
Save keeprock/af19702e1c5b99795a90 to your computer and use it in GitHub Desktop.
Fix translation issue with taxonomy terms displayed via views module http://ggordan.com/post/localising-taxonomy-terms-in-views.html
/*
* Implementation hook_views_api()
*/
function CUSTOM_views_api() {
return array(
'api' => 3,
);
}
/*
* Implementation of hook_views_pre_render(&$view)
*/
function CUSTOM_views_pre_render(&$view) {
global $language;
foreach($view->result as $delta => $term ){
if(isset($term->tid)) {
i18n_string_translate_langcode( $language->language );
$localized_term = i18n_taxonomy_localize_terms( taxonomy_term_load( $term->tid ));
$term->tid = $localized_term->tid;
$term->taxonomy_term_data_name = $localized_term->name;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment