'Paths', 'description' => 'Path translation.', 'page callback' => 'i18n_path_admin_overview', 'access arguments' => array('administer site configuration'), 'file' => 'i18n_path.admin.inc', 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); $items['admin/config/regional/i18n_translation/path/list'] = array( 'title' => 'Paths', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); $items['admin/config/regional/i18n_translation/path/add'] = array( 'title' => 'Add path translation', 'page callback' => 'drupal_get_form', 'page arguments' => array('i18n_path_admin_form'), 'access arguments' => array('administer site configuration'), 'file' => 'i18n_path.admin.inc', 'type' => MENU_LOCAL_ACTION, 'parent' => 'admin/config/regional/i18n_translation', ); $items['admin/config/regional/i18n_translation/path/edit/%i18n_path_translation_set'] = array( 'title' => 'Edit path translation', 'page callback' => 'drupal_get_form', 'page arguments' => array('i18n_path_admin_form', 6), 'access arguments' => array('administer site configuration'), 'file' => 'i18n_path.admin.inc', 'type' => MENU_CALLBACK, 'parent' => 'admin/config/regional/i18n_translation', ); return $items; } /** * Implements hook_url_outbound_alter() */ /* function i18n_path_url_outbound_alter(&$path, &$options, $original_path) { if (!empty($options['language'])) { $langcode = $options['language']->language; $original = $options['alias'] ? drupal_get_normal_path($path, $langcode) : $original_path; if (($translations = i18n_path_get_translations($path)) && !empty($translations[$langcode])) { $path = $options['alias'] ? drupal_get_path_alias($translations[$langcode], $langcode) : $translations[$langcode]; } } } */ /** * Get translations for path */ function i18n_path_get_translations($path) { static $translations; if (!isset($translations)) { $translations = drupal_static(__FUNCTION__, array()); } if (!isset($translations[$path])) { $translations[$path] = db_query('SELECT p.language, p.path FROM {i18n_path} p INNER JOIN {i18n_path} ps ON p.tsid = ps.tsid WHERE ps.path = :path', array(':path' => $path) )->fetchAllKeyed(); } return $translations[$path]; } /** * Implements hook_language_switch_links_alter(). */ function i18n_path_language_switch_links_alter(array &$links, $type, $path) { if (($translations = i18n_path_get_translations($path))) { foreach ($translations as $lang => $translated_path) { $links[$lang] = i18ntranslation_link($path, $langcode); } } } /** * Implements hook_i18n_object_info(). */ function i18n_path_i18n_object_info() { return array( 'path' => array( 'title' => t('Path'), 'translation set' => array( 'class' => 'i18n_path_translation_set', 'table' => 'i18n_path', ), ) ); } /** * Implements hook_i18n_translate_path() */ function i18n_path_i18n_translate_path($path, $language) { $translations = i18n_path_get_translations($path); if ($translations && isset($translations[$language->language])) { return $translations[$language->language]; } } /** * Load translation set. Menu loading callback. */ function i18n_path_translation_set_load($tsid) { return i18n_translation_set_load($tsid, 'path'); }