Last active
August 29, 2015 14:18
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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