diff --git a/taxonomy_title.module b/taxonomy_title.module index 15ea147..cf9d55f 100755 --- a/taxonomy_title.module +++ b/taxonomy_title.module @@ -127,6 +127,9 @@ function taxonomy_title_process_page(&$variables) { */ function _taxonomy_title_get_title($tid) { $title = db_query("SELECT title FROM {taxonomy_title} WHERE tid = :tid", array(':tid' => $tid))->fetchField(); + if (function_exists('i18n_string_translate')) { + $title = i18n_string_translate(array('taxonomy_title', 'term', $tid, 'title'), $title, array('sanitize' => FALSE)); + } return $title; } @@ -147,6 +150,11 @@ function _taxonomy_title_insert_title($tid, $title) { 'title' => $title, )) ->execute(); + + // Translate the string if i18n is enabled + if (function_exists('i18n_string_update')) { + i18n_string_update(array('taxonomy_title', 'term', $tid, 'title'), $title); + } } } @@ -169,8 +177,8 @@ function _taxonomy_title_update($tid, $title) { ->execute(); // Add Suppot for i18nstrings. - if (function_exists('i18nstrings_update')) { - i18nstrings_update("taxonomy_title:term:$tid:title", $title); + if (function_exists('i18n_string_update')) { + i18n_string_update(array('taxonomy_title', 'term', $tid, 'title'), $title); } } @@ -213,26 +221,17 @@ function taxonomy_title_get_settings() { } /** - * Translate user defined string. Wrapper function for tt() if i18nstrings enabled. - * - * @param $name - * String id in the form taxonomy_title:term:[tid]:title - */ -function taxonomy_title_tt($name, $string, $langcode = NULL) { - return function_exists('i18nstrings') ? i18nstrings($name, $string, $langcode) : $string; -} - -/** - * Implementation of hook_locale(). + * Implements hook_i18n_string_info() */ -function taxonomy_title_locale($op = 'groups', $group = NULL) { - switch ($op) { - case 'groups': - return array('taxonomy_title' => t('Taxonomy title')); - case 'info': - $info['taxonomy_title']['refresh callback'] = 'taxonomy_title_locale_refresh'; - return $info; - } +function taxonomy_title_i18n_string_info() { + $groups['taxonomy_title'] = array( + 'title' => t('Taxonomy title'), + 'description' => t('Translatable custom page titles for taxonomy terms.'), + 'format' => FALSE, // This group doesn't have strings with format + 'list' => FALSE, // This group cannot list all strings + 'refresh callback' => 'taxonomy_title_locale_refresh', + ); + return $groups; } /** @@ -241,10 +240,10 @@ function taxonomy_title_locale($op = 'groups', $group = NULL) { function taxonomy_title_locale_refresh() { $results = db_query("SELECT tid, title FROM {taxonomy_title}"); while ($row = db_fetch_object($results)) { - i18nstrings_update("taxonomy_title:term:$row->tid:title", $row->title); + i18n_string_update(array('taxonomy_title', 'term', $row->tid, 'title'), $row->title); } - // Meaning it completed with no issues. @see i18nmenu_locale_refresh(). + // Meaning it completed with no issues. @see hook_locale_refresh(). return TRUE; } @@ -260,4 +259,4 @@ function taxonomy_title_theme($existing, $type, $theme, $path) { ); return $theme; -} \ No newline at end of file +} diff --git a/taxonomy_title.tokens.inc b/taxonomy_title.tokens.inc index 5fbb22b..a1abbe0 100644 --- a/taxonomy_title.tokens.inc +++ b/taxonomy_title.tokens.inc @@ -36,7 +36,11 @@ function taxonomy_title_tokens($type, $tokens, array $data = array(), array $opt $replacements[$original] = ($sanitize) ? check_plain($title) : $title; } else { - $replacements[$original] = $term->name; + $name = $term->name; + if (function_exists('i18n_taxonomy_term_name')) { + $name = i18n_taxonomy_term_name($term); + } + $replacements[$original] = $sanitize ? check_plain($name) : $name; } break; }