Index: biblio.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.admin.inc,v retrieving revision 1.9.2.83 diff -u -F '^function' -r1.9.2.83 biblio.admin.inc --- biblio.admin.inc 20 Nov 2009 21:28:15 -0000 1.9.2.83 +++ biblio.admin.inc 8 Dec 2009 02:46:06 -0000 @@ -824,6 +824,9 @@ function biblio_admin_types_edit_form_su // Clear the cached pages and menus: menu_rebuild(); + + // Refresh translatable field strings. + biblio_locale_refresh_fields($tid); } function biblio_admin_type_mapper_page() { @@ -1044,6 +1047,9 @@ function biblio_admin_types_add_form_sub drupal_write_record('biblio_contributor_type', $ct_vals); } + // Refresh publication type string for translation. + biblio_locale_refresh_types($values['tid']); + drupal_goto('admin/settings/biblio/fields/type'); } function biblio_admin_types_hide() { Index: biblio.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.module,v retrieving revision 1.123.2.160 diff -u -F '^function' -r1.123.2.160 biblio.module --- biblio.module 4 Dec 2009 20:42:03 -0000 1.123.2.160 +++ biblio.module 8 Dec 2009 02:46:08 -0000 @@ -56,6 +56,103 @@ function _biblio_get_field_information($ return $fields; } +/** + * Translate field titles and hints through the interface translation system, if + * the i18nstrings module is enabled. + */ +function _biblio_localize_fields(&$fields) { + if (module_exists('i18nstrings')) { + foreach ($fields as $key => $row) { + $fields[$key]['title'] = tt("biblio:field:{$row['ftdid']}:title", $fields[$key]['title']); + $fields[$key]['hint'] = tt("biblio:field:{$row['ftdid']}:hint", $fields[$key]['hint']); + } + } +} + +/** + * Translate a publication type through the interface translation system, if + * the i18nstrings module is enabled. + * + * @param integer $tid + * The biblio publication type identifier. + * + * @param string $value + * The string to translate. + * + * @param string $field + * The publication type field to translate (either 'name' or 'description'). + * + * @return + * Translated value. + */ +function _biblio_localize_type($tid, $value, $field = 'name') { + if (module_exists('i18nstrings')) { + return tt("biblio:type:$tid:$field", $value); + } + return $value; +} + +/** + * Implementation of hook_locale(). + */ +function biblio_locale($op = 'groups', $group = NULL) { + switch ($op) { + case 'groups': + return array('biblio' => t('Biblio')); + + case 'refresh': + if ($group == 'biblio') { + biblio_locale_refresh_fields(); + biblio_locale_refresh_types(); + } + break; + } +} + +/** + * Refresh all translatable field strings. + * + * @param integer $tid + * Biblio publication type id whose field strings are to be refreshed. If not + * specified, strings for all fields will be refreshed. + */ +function biblio_locale_refresh_fields($tid = NULL) { + if (module_exists('i18nstrings')) { + if (isset($tid)) { + $result = db_query('SELECT d.* FROM {biblio_field_type} b INNER JOIN {biblio_field_type_data} d ON b.ftdid = d.ftdid WHERE tid = %d', $tid); + } + else { + $result = db_query('SELECT * FROM {biblio_field_type_data}'); + } + while ($row = db_fetch_array($result)) { + tt("biblio:field:{$row['ftdid']}:title", $row['title'], NULL, TRUE); + tt("biblio:field:{$row['ftdid']}:hint", $row['hint'], NULL, TRUE); + } + } +} + +/** + * Refresh all publication type strings. + * + * @param integer $tid + * Biblio publication type id whose field strings are to be refreshed. If not + * specified, strings for all fields will be refreshed. + */ +function biblio_locale_refresh_types($tid = NULL) { + if (module_exists('i18nstrings')) { + if (isset($tid)) { + $result = db_query('SELECT * FROM {biblio_types} WHERE tid = %d', $tid); + } + else { + $result = db_query('SELECT * FROM {biblio_types} WHERE tid > 0'); + } + while ($row = db_fetch_array($result)) { + tt("biblio:type:{$row['tid']}:name", $row['name'], NULL, TRUE); + tt("biblio:type:{$row['tid']}:description", $row['description'], NULL, TRUE); + } + } +} + function biblio_init() { global $user, $conf; drupal_add_css(drupal_get_path('module', 'biblio') .'/biblio.css'); @@ -1021,7 +1118,7 @@ function biblio_form($node, $form_state) ); $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE tid > -2 AND visible = 1'); while ($option = db_fetch_object($result)) { - $options["$option->tid"] = $option->name; + $options[$option->tid] = _biblio_localize_type($option->tid, $option->name); } if (!isset($node->nid) && !isset($form_state['storage']['biblio_type'])) {// only show the doi lookup and paste boxes if this is a new entry if($user->uid > 0 && phpversion() > 5 && !isset($form_state['storage'])) { @@ -1113,6 +1210,7 @@ function biblio_form($node, $form_state) while ($row = db_fetch_array($result)) { $fields[$row['name']] = $row; } + _biblio_localize_fields($fields); $form['other_fields'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, Index: biblio.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.pages.inc,v retrieving revision 1.1.2.106 diff -u -F '^function' -r1.1.2.106 biblio.pages.inc --- biblio.pages.inc 11 Nov 2009 21:01:50 -0000 1.1.2.106 +++ biblio.pages.inc 8 Dec 2009 02:46:09 -0000 @@ -636,8 +636,8 @@ function _biblio_filter_info_line($args) } if ($type == 'type' && $value > 0) { if (($pub_type = db_fetch_object(db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid=%d', $value)))) { - $value = drupal_ucfirst($pub_type->name); - $type = t("Type"); + $value = drupal_ucfirst(_biblio_localize_type($pub_type->tid, $pub_type->name)); + $type = t("Type"); } } array_shift($args); @@ -715,7 +715,7 @@ function _biblio_category_separator_bar( } $_text = $node->biblio_type_name; // $name = db_result(db_query("SELECT name FROM {biblio_types} as t where t.tid=%d", $node->biblio_type)) ; - $content .= theme_biblio_separator_bar($_text); + $content .= theme_biblio_separator_bar(_biblio_localize_type($node->biblio_type, $_text)); } break; case 'keyword': // added msh 08 aug 07 @@ -895,7 +895,7 @@ function _get_biblio_filters() { $option->biblio_year = _biblio_text_year($option->biblio_year); } $pub_years["$option->biblio_year"] = $option->biblio_year; - $pub_type["$option->tid"] = $option->name; + $pub_type["$option->tid"] = _biblio_localize_type($option->tid, $option->name); } while($auth = db_fetch_object($authors)) { Index: biblio_theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio_theme.inc,v retrieving revision 1.8.2.93 diff -u -F '^function' -r1.8.2.93 biblio_theme.inc --- biblio_theme.inc 24 Nov 2009 22:07:24 -0000 1.8.2.93 +++ biblio_theme.inc 8 Dec 2009 02:46:10 -0000 @@ -119,7 +119,7 @@ function theme_biblio_long($node, $base $openurl_base = variable_get('biblio_baseopenurl', ''); if ($openurl_base) $output .= theme('biblio_openurl', biblio_openurl($node, $openurl_base)); - $output .= '

'. t("Publication Type") .":

$node->biblio_type_name
\n"; + $output .= '

'. t("Publication Type") .":

". _biblio_localize_type($node->biblio_type, $node->biblio_type_name) ."
\n"; $output .= '

'. t("Authors") .':

'. $authors ."
\n"; $output .= '

'. t("Source") .':

'; $source = null; @@ -199,13 +199,14 @@ function theme_biblio_tabular($node, $ba $style_function = "biblio_style_$style_name"."_author_options"; module_load_include('inc','biblio',"biblio_style_$style_name"); $fields = _biblio_get_field_information($node->biblio_type, TRUE); + _biblio_localize_fields($fields); $rows[] = array( array('data' => t('Title'), 'class' => 'biblio-row-title'), array('data' => filter_xss($node->title, biblio_get_allowed_tags())) ); $rows[] = array( array('data' => t('Publication Type'), 'class' => 'biblio-row-title'), - array('data' => isset($node->biblio_type_name) ? $node->biblio_type_name : $node->biblio_type) + array('data' => isset($node->biblio_type_name) ? _biblio_localize_type($node->biblio_type, $node->biblio_type_name) : $node->biblio_type) ); if ($node->biblio_url) {