You are here

function i18n_node_i18n_translate_path in Internationalization 7

Implements hook_i18n_translate_path()

File

i18n_node/i18n_node.module, line 115
Internationalization (i18n) module - Node type handling

Code

function i18n_node_i18n_translate_path($path) {
  if (preg_match("!^node/(\\d+)(/.+|)!", $path, $matches) && ($node = node_load((int) $matches[1])) && i18n_object_langcode($node) && !empty($node->tnid)) {
    if ($translations = translation_node_get_translations($node->tnid)) {
      $result = array();
      foreach ($translations as $langcode => $node_translation) {
        $result[$langcode] = array(
          'href' => 'node/' . $node_translation->nid . $matches[2],
          'title' => $node_translation->title,
          'object' => $node_translation,
          // Performance: for node view add access information right away.
          'access' => !$matches[2] ? $node_translation->status : NULL,
        );
      }
      return $result;
    }
  }
}