Index: biblio.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.admin.inc,v retrieving revision 1.9.2.80 diff -u -F^function -r1.9.2.80 biblio.admin.inc --- biblio.admin.inc 30 Sep 2009 15:48:25 -0000 1.9.2.80 +++ biblio.admin.inc 16 Oct 2009 20:57:50 -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.146 diff -u -F^function -r1.123.2.146 biblio.module --- biblio.module 30 Sep 2009 15:48:25 -0000 1.123.2.146 +++ biblio.module 16 Oct 2009 20:57:51 -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'); @@ -1032,7 +1129,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)) {// only show the doi lookup and paste boxes if this is a new entry if(phpversion() > 5 && !isset($form_state['storage']['biblio_doi'])) { @@ -1123,6 +1220,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_theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio_theme.inc,v retrieving revision 1.8.2.87 diff -u -F^function -r1.8.2.87 biblio_theme.inc --- biblio_theme.inc 30 Sep 2009 15:48:25 -0000 1.8.2.87 +++ biblio_theme.inc 16 Oct 2009 20:57:51 -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' => $node->biblio_type_name) + array('data' => _biblio_localize_type($node->biblio_type, $node->biblio_type_name)) ); if ($node->biblio_url) {