machine_name; return t('To translate the forum, edit and make it translatable, then translate the forum and its containers and sub-forums on the taxonomy administration page.', array('@edit' => url('admin/structure/taxonomy/' . $name . '/edit'), '@translate' => url('admin/structure/taxonomy/' . $name . '/translate'), '@list' => url('admin/structure/taxonomy/' . $name . '/list'))); } } /** * Implements hook_menu_local_tasks_alter(). */ function i18n_forum_menu_local_tasks_alter(&$data, $router_item, $root_path) { // Translate link to 'node/add/forum' on 'forum' sub-pages. if ($root_path == 'forum' || $root_path == 'forum/%') { $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0]->tid : 0); $forum_term = forum_forum_load($tid); if ($forum_term) { // Loop through all bundles for forum taxonomy vocabulary field. $vid = variable_get('forum_nav_vocabulary', 0); if ($vid && ($vocabulary = taxonomy_vocabulary_load($vid)) && ($field = field_info_field('taxonomy_' . $vocabulary->machine_name))) { foreach ($field['bundles']['node'] as $type) { if (isset($data['actions']['output'][$type])) { $data['actions']['output'][$type]['#link']['title'] = t('Add new @node_type', array('@node_type' => i18n_node_type_name($type, node_type_get_name($type)))); } } } } } } /** * Implements hook_form_FORM_ID_alter() */ function i18n_forum_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) { $vid = variable_get('forum_nav_vocabulary', 0); if ($vid && !isset($form_state['confirm_delete']) && isset($form['vid']) && $form['vid']['#value'] == $vid) { // Only two options for this vocabulary $replacements = array( '@item_name_multiple' => t('forum containers'), '@item_name_multiple_capitalized' => t('Forum containers'), ); $form['i18n_translation']['i18n_mode']['#options'] = i18n_translation_options_list($replacements, array(I18N_MODE_LOCALIZE, I18N_MODE_TRANSLATE)); } } /** * Implements hook_node_view(). * * Localize breadcrumb for forum nodes. */ function i18n_forum_node_view($node, $view_mode, $langcode) { if (_forum_node_check_node_type($node)) { if ($view_mode == 'full' && node_is_page($node)) { $vid = variable_get('forum_nav_vocabulary', 0); $vocabulary = taxonomy_vocabulary_load($vid); // Breadcrumb navigation $breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l(i18n_taxonomy_vocabulary_name($vocabulary), 'forum'); if ($parents = taxonomy_get_parents_all($node->forum_tid)) { $parents = array_reverse($parents); foreach ($parents as $parent) { $breadcrumb[] = l(i18n_taxonomy_term_name($parent), 'forum/' . $parent->tid); } } drupal_set_breadcrumb($breadcrumb); } } } /** * Translate forums list. */ function i18n_forum_preprocess_forum_list(&$variables) { $vid = variable_get('forum_nav_vocabulary', 0); if (i18n_taxonomy_vocabulary_mode($vid)) { foreach ($variables['forums'] as $id => $forum) { $variables['forums'][$id]->description = i18n_string('taxonomy:term:'. $forum->tid .':description', $forum->description); $variables['forums'][$id]->name = i18n_string('taxonomy:term:'. $forum->tid .':name', $forum->name); } } } /** * Translate forum page. */ function i18n_forum_preprocess_forums(&$variables) { $vid = variable_get('forum_nav_vocabulary', 0); if (i18n_taxonomy_vocabulary_mode($vid)) { if (isset($variables['links']['forum'])) { $variables['links']['forum']['title'] = i18n_string('nodetype:type:forum:post_button', 'Post new Forum topic'); } // This one is from advanced forum, http://drupal.org/project/advanced_forum if (!empty($variables['forum_description'])) { $variables['forum_description'] = i18n_string('taxonomy:term:'. $variables['tid'] .':description', $variables['forum_description']); } $vocabulary = taxonomy_vocabulary_load($vid); // Translate breadrumb and page title. $title = $vocabulary_name = !empty($vocabulary->name) ? i18n_taxonomy_vocabulary_name($vocabulary) : ''; $breadcrumb[] = l(t('Home'), NULL); if ($variables['tid']) { $breadcrumb[] = l($vocabulary_name, 'forum'); } if ($variables['parents']) { $variables['parents'] = array_reverse($variables['parents']); foreach ($variables['parents'] as $p) { if ($p->tid == $variables['tid']) { $title = i18n_taxonomy_term_name($p); } else { $breadcrumb[] = l(i18n_taxonomy_term_name($p), 'forum/' . $p->tid); } } } drupal_set_breadcrumb($breadcrumb); drupal_set_title($title); } }