From 8ccaa8774df4c8dfbb0ff4b2ea11ba944e5bb19b Mon Sep 17 00:00:00 2001 Message-Id: <8ccaa8774df4c8dfbb0ff4b2ea11ba944e5bb19b.1366039160.git.isakic@ws4.(none)> From: =?UTF-8?q?Ivan=20=C5=A0aki=C4=87?= Date: Mon, 15 Apr 2013 17:19:11 +0200 Subject: [PATCH] Remaking patch --- .../entity_translation/entity_translation.module | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sites/all/modules/entity_translation/entity_translation.module b/sites/all/modules/entity_translation/entity_translation.module index c89b8ec..c609d08 100644 --- a/sites/all/modules/entity_translation/entity_translation.module +++ b/sites/all/modules/entity_translation/entity_translation.module @@ -1911,3 +1911,26 @@ function entity_translation_pathauto_alias_alter(&$alias, array &$context) { } } } + +/** + * Implement hook_i18n_translate_path(). + * + * Used by i18n_hreflang for creating translation links for SEO + */ +function entity_translation_i18n_translate_path($path) { + $links = array(); + + // Translate node paths only for now + if (preg_match("!^node/(\d+)(/.+|)!", $path, $matches) && ($node = node_load((int) $matches[1]))) { + $languages = language_list('enabled'); + $links = array(); + foreach ($languages[1] as $language) { + $links[$language->language] = array( + 'href' => url($path, array('absolute' => TRUE, 'language' => $language)), + 'title' => $language->native, + ); + } + } + + return $links; +} -- 1.7.10.4