Index: auto_nodetitle.module =================================================================== --- auto_nodetitle.module (revision 29579) +++ auto_nodetitle.module (revision 29596) @@ -78,17 +78,18 @@ * Sets the automatically generated nodetitle for the node */ function auto_nodetitle_set_title(&$node) { - $types = node_get_types(); + $type = node_get_types('type', $node->type); $pattern = variable_get('ant_pattern_'. $node->type, ''); + $nodetype = _auto_nodetitle_tt("nodetype:$node->type:0:name", $type->name); if (trim($pattern)) { $node->changed = time(); $node->title = _auto_nodetitle_patternprocessor($pattern, $node); } else if ($node->nid) { - $node->title = t('@type @node-id', array('@type' => $types[$node->type]->name, '@node-id' => $node->nid)); + $node->title = t('@type @node-id', array('@type' => $nodetype, '@node-id' => $node->nid)); } else { - $node->title = t('@type', array('@type' => $types[$node->type]->name)); + $node->title = t('@type', array('@type' => $nodetype)); } // With that flag we ensure we don't apply the title two times to the same node. $node->auto_nodetitle_applied = TRUE; @@ -130,6 +131,9 @@ * @return a title string */ function _auto_nodetitle_patternprocessor($output, $node) { + if(variable_get('ant_translate_'. $node->type, 0)) { + $output = _auto_nodetitle_tt("ant:$node->type:0:title", $output); + } if (module_exists('token')) { $output = token_replace($output, 'node', $node); } @@ -162,6 +166,12 @@ t('Automatically generate the title if the title field is left empty'), ) ); + + $form['auto_nodetitle']['ant_translate'] = array( + '#type' => 'checkbox', + '#title' => t('Translate the title'), + '#default_value' => variable_get('ant_translate_'. $form['#node_type']->type, 0) + ); if (module_exists('token') || user_access('use PHP for title patterns')) { @@ -230,18 +240,33 @@ switch ($op) { case 'delete': variable_del('ant_'. $info->type); + variable_del('ant_translate_'. $info->type); variable_del('ant_pattern_'. $info->type); variable_del('ant_php_'. $info->type); break; case 'update': if (!empty($info->old_type) && $info->old_type != $info->type) { variable_set('ant_'. $info->type, auto_nodetitle_get_setting($info->old_type)); + variable_set('ant_translate_'. $info->type, variable_get('ant_translate_'. $info->old_type, '')); variable_set('ant_pattern_'. $info->type, variable_get('ant_pattern_'. $info->old_type, '')); variable_set('ant_php_'. $info->type, variable_get('ant_php_'. $info->old_type, '')); variable_del('ant_'. $info->old_type); + variable_del('ant_translate_'. $info->old_type); variable_del('ant_pattern_'. $info->old_type); variable_del('ant_php_'. $info->old_type); } break; } } + +/** + * Wrapper function for tt() if i18nstrings enabled. + */ +function _auto_nodetitle_tt($name, $string, $langcode = NULL, $update = FALSE) { + if (module_exists('i18nstrings')) { + return tt($name, $string, $langcode, $update); + } + else { + return $string; + } +} \ No newline at end of file