This patch introduces the hook hook_entity_translation_save(). It's fired whenever an entity translation is saved.
The idea is to give other modules the opportunity to react on translations.
The first module which implements this is entity_translation itself to deal with path-aliases the second one is pathauto.

There's another patch (#1155132: Add Entity Translation support to Pathauto) which integrates entity_translation stuff into pathauto.
To do so I had to make a small change in the entity translation form - now it's fully compatible to the pathauto node form alteration.

Another patch (#1155128: Enhance support for tokens) for the title module ensures that the tokens are provided in the correct language while using pathauto.

Comments

das-peter’s picture

I rewrote the patch after Dave Reid's feedback here #1155132-2: Add Entity Translation support to Pathauto

Besides the new hook the module contains now a lot more pathauto specific stuff. I tried to keep it as generic as possible but since pathauto works with predefined entity_types I had to use some ugly conditions.

das-peter’s picture

Title: Add hook for translation event » Integrate pathauto
StatusFileSize
new16.03 KB

Found some issues while writing tests.

plach’s picture

This looks great, thanks! Sorry for not being able to have a deep look to this yet. My only concern with the current approach is about having so much explicit dependencies on pathauto and nodes, when ET aims to handle entities in a general way.

However, sunday I'll have a full day to spend on Drupal and we should be able to move forward.

joostvdl’s picture

subscribe

joostvdl’s picture

Patch from #2 doesn't work with latest -dev release anymore

calculus’s picture

subscribe

das-peter’s picture

Rerolled to work with latest pathauto and entity_translation version.

das-peter’s picture

Added support for redirect module and some cleanup.

das-peter’s picture

Small fix for pathauto integration:
Pathauto handled new translation like existing nodes - this caused wrong initial settings. Now the dummy object passed to pathauto "emulates" a new node when adding a new translation.

das-peter’s picture

Just a second ago I got a ticket from a customer, asking where to set the pathauto settings in a translation.
Thus changed the name of the fieldset from "URL Alias" to "URL path settings" for the sake of consitency. :)

renat’s picture

das-peter, your patch from #10 works just great for me! I successfully updated aliases for my nodes (each of them in 3 languages). New node creation and translation is also OK.

Would be great, though, if it will be possible to add taxonomy support in future.

renat’s picture

Looks like I found a minor bug. We have entity translatable node type, for which we didn't add rules for alias creation (and there are no default rules applicable), i.e. it is impossible to make alias programmatically for it. In case you'll add node of this type, and then will try to translate it, you'll receive this message after translation submission:

Notice: Undefined index: pathauto in entity_translation_entity_translation_save() (line 571 of /var/www/test2.sky37.com/public_html/sites/all/modules/entity_translation/entity_translation.module).

If alias automatic creation is possible, but you'll suspend it with "URL path settings" for this node, there will be no problem.

das-peter’s picture

Hi renat, thank you for your feedback in #13 - the attached patch contains a fix for the mentioned notice.
Unfortunately I can't give you a time-line for taxonomy support. It shouldn't be a huge thing but I've to take a closer look first.

renat’s picture

das-peter, hi. Patch from #13 completely solved this problem, thank you.

jakonore’s picture

subscribe

giorgosk’s picture

#13 patch works great
please commit

plach’s picture

I'm sorry I couldn't work on this yet, but the patch albeit working cannot be committed as is, explained above.

Pisco’s picture

@planch can you explain further where you see problems and what you would like to change, so that others can help? This issue seems somewhat stuck.

plach’s picture

The problem with the current approach is that it involves making a lot of special casing for nodes, while ET aims to handle entities in ageneral way. I'm seriously considering to use CTools to solve the different entities needs though plugins. But this obviously is a thing that must be carefully considered, the only problem is I am very busy with translatable fields in core to work on ET at the moment.

plach’s picture

jeff.maes’s picture

+1 for patch in #13 ! Thanks!

Cyclodex’s picture

subscribe

brycesenz’s picture

subscribing.

I applied the patch in #13, which worked fairly well. However, I'm getting a bug - now when I go to bulk update my alias settings (URL Aliases->Bulk Update), the checkbox to update all content is missing. Is anyone else seeing this error?

Update: I cleared the cache and this was fixed.

plach’s picture

Thi is likely to be addressed in a totally different way, see #1282018: Improve UX of language-aware entity forms.

giorgosk’s picture

based on #13 patch here is a patch that applies to the latest dev of this module (from 2011-10-11)

Status: Needs review » Needs work
Issue tags: -title, -pathauto, -redirect, -di18nscb, -D7 stable release blocker
stano.lacko’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +title, +pathauto, +redirect, +di18nscb, +D7 stable release blocker
zambrey’s picture

Status: Needs work » Needs review
StatusFileSize
new9.69 KB

Rerolled patch as the one at #25 doesn't want to cooperate :)
This is very handy feature. Let's get this in.

matt3om’s picture

#29 works well.

zoltán balogh’s picture

Status: Needs review » Reviewed & tested by the community

#29 works very well. Thanks, it is a very important feature!

plach’s picture

Status: Reviewed & tested by the community » Postponed

I'm sorry but this won't be committed as is, see #24.

das-peter’s picture

I'm sad to see that this is postponed.
While I understand that we should go for "that one and only clean approach", I don't get it why this goal is more important than "have (temporary) working solution".

Especially because I can't believe that #1282018: Improve UX of language-aware entity forms will be ready soon and since there is this nice hook "hook_update_N()" which would perfectly support us migrating from the temporary to the perfect solution if it's ready.

plach’s picture

I'm working hard on #1282018: Improve UX of language-aware entity forms to have at least the functional side ready soon. I'm wary about committing a temporary fix because people might start heavily relying on it. However my plan is to release a second alpha before committing the UI revamp. If it won't be (functionally) ready in a week I'll commit this.

das-peter’s picture

Ok, that's a statement :) Thank you very much, I appreciate this!

plach’s picture

Status: Postponed » Needs work

I'm sorry but the patch cannot be committed as is:

+++ b/entity_translation.admin.inc
@@ -338,6 +353,31 @@ function entity_translation_edit_form($form, $form_state, $entity_type, $entity,
+      // Create temporary decoupled stuff to avoid sideeffects.

Typo

+++ b/entity_translation.admin.inc
@@ -338,6 +353,31 @@ function entity_translation_edit_form($form, $form_state, $entity_type, $entity,
+        // Dead ugly - but do we prefer to duplicate the pathauto form on our own??

Wrong comment wrapping. Can we have a less colloquial comment? Also below.

+++ b/entity_translation.admin.inc
@@ -338,6 +353,31 @@ function entity_translation_edit_form($form, $form_state, $entity_type, $entity,
+       module_load_include('module', 'redirect');

Wrong indentation.

+++ b/entity_translation.api.php
@@ -49,3 +49,17 @@ function hook_translation_info($types = NULL) {
+ * Allow modules tor react on translation events.

Typo

+++ b/entity_translation.api.php
@@ -49,3 +49,17 @@ function hook_translation_info($types = NULL) {
+ *   The entity which is translated.

This sentence looks odd.

+++ b/entity_translation.api.php
@@ -49,3 +49,17 @@ function hook_translation_info($types = NULL) {
+

Missing example.

+++ b/entity_translation.module
@@ -546,3 +546,134 @@ function entity_translation_edit_form_info($form) {
+ * @param $entity_type
+ * @param $entity
+ * @param $langcode

Missing parameter documentation.

+++ b/entity_translation.module
@@ -546,3 +546,134 @@ function entity_translation_edit_form_info($form) {
+  // The user needs the permissoin and pathauto has to be disabled.

Typo

+++ b/entity_translation.module
@@ -546,3 +546,134 @@ function entity_translation_edit_form_info($form) {
+  // Trigger pathauto if module is available

Missing trailing dot.

+++ b/entity_translation.module
@@ -546,3 +546,134 @@ function entity_translation_edit_form_info($form) {
+  // Group by language

Missing trailing dot.

das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new10.23 KB

Thanks for the feedback.
The attached patch should fix all the things you mentioned.

plach’s picture

Status: Needs review » Postponed

Ok, committed and pushed to the 7.x-1.x branch. Putting back to 'postponed'.

I did not the test this, I'm just confident this is actually RTBC as per the comments above. Everyone be warned that once the new UI is committed this might be reverted entirely.

das-peter’s picture

Thank you very much!
For removing it later I suggest a two step approach.
As soon as pathauto / redirect work with the new UI we remove the integration of those modules, but keep hook_entity_translation_save() for another cycle - giving other modules / dev's time to adapt.
The really ugly part is the recycled form parts of other modules - the hook itself is not that bad ;)

kristen pol’s picture

I just installed the *dev* version of entity_translation (dated Jan 12, 2012) and am using Pathauto 7.x-1.0. The automatic path aliases are working as expected.

Thanks!
Kristen

colan’s picture

The second last stanza is problematic:

  foreach ($language_nids as $language => $nids) {
    pathauto_node_update_alias_multiple($nids, 'bulkupdate', array('language' => $language));
    $context['sandbox']['count'] += count($nids);
    $context['sandbox']['current'] = max($nids); 
  }
  $context['message'] = t('Updated alias for node @nid.', array('@nid' => end($nids)));

The last line produces end() expects parameter 1 to be array, null given in entity_translation.module:749 because $nids does not exist outside the scope of the above foreach() loop. Due to the lack of documentation here, it's difficult to determine if $language_nids should be used instead, or if that line needs to be moved into the loop (at the bottom).

So this needs some work, but leaving as postponed as this can be taken care of whenever this issue get un-postponed. (However, it is currently broken in the dev branch, as this is already committed.)

suppyx’s picture

Status: Postponed » Needs review
klonos’s picture

Status: Needs review » Needs work

...this is NW based on #41. We can set it to NR once we have an actual patch ready for review.

Wolfgang Reszel’s picture

Component: Code » Base system

I use the path pattern [nodesymlink:menu-link:parents:join:/]/[nodesymlink:menu-link:title], but I'll only get the path of the source language. There's even no foreign language path created.

plach’s picture

Status: Needs work » Postponed
StatusFileSize
new973 bytes

Here is a patch rolled against the ml_edit_form branch. Obviously it won't pass tests until it is merged in the main one, thus setting to postponed.

The juicy one is in the Pathauto queue, please review/test it: #1155132-18: Add Entity Translation support to Pathauto.

plach’s picture

StatusFileSize
new765 bytes

The previous patch did not work without having access to the pathauto widget.

plach’s picture

Status: Postponed » Fixed

Committed and pushed to the 7.x-1.x branch, thanks for your efforts!

klonos’s picture

FINALLY! Thanx, ...one less patch to babysit ;)

plach’s picture

:)

brycesenz’s picture

Status: Fixed » Active

I'm running the latest -dev versions of Entity, Entity Translation, and Pathauto. I have several nodes with translations using this module, and none of their translations have aliases generated with Pathauto, regardless of how many times I clear the cache or regenerate the aliases.

Has anyone else experienced this, or does anyone have any thoughts on what could fix this issue?

plach’s picture

Status: Active » Fixed
nikosnikos’s picture

@brycesenz yes I have the same problem. I reported it here in pathauto queue.

plach’s picture

Status: Fixed » Active

Reopening since we are missing bulk updates.

plach’s picture

FYI, CRUD hooks have just been reintroduced in #1224590: Introduce entity translation CRUD hooks.

plach’s picture

Title: Integrate pathauto » Integrate pathauto bulk generation
plach’s picture

Priority: Normal » Major
colan’s picture

#867578: Add drush commands for bulk alias updating/deleting is related. I was looking at ET issues when I was working on it.

bforchhammer’s picture

Status: Active » Needs review
StatusFileSize
new2.65 KB

Here's a stab at adding support for pathauto bulkupdates...

bforchhammer’s picture

StatusFileSize
new1.26 KB

Uh, last patch contained other stuff as well. Here's the proper one.

plach’s picture

Status: Needs review » Needs work
Issue tags: +title, +pathauto, +redirect, +di18nscb, +D7 stable release blocker

The last submitted patch, pathauto-bulk-fix-1155134-59.patch, failed testing.

bforchhammer’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB

Reroll against HEAD.

plach’s picture

Status: Needs review » Fixed

Committed and pushed with some adjustment, thanks!

plach’s picture

And a small follow-up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

eidoscom’s picture

Sorry for reopening the closed issue. I'm not exactly sure if I must post it this here but here it is...

The "patch" is not working with almost taxonomy related tokens. (I'm using the 7.x-1.0-beta2 version with patch included).

I have a token pattern like this:[node:field-myfield:parents:join-path]/[node:field-myfield]/[node:title] and when bulk updating the aliases get the original language tokens only of [node:field-myfield:parents:join-path] and [node:field-myfield] tokens.

Is perhaps a new issue related to tokens?? Thanks

plach’s picture

Ina ny case you should open a new issue, since this one was only about introdcuing the functionality.

  • Commit c8d5a47 on master, et-permissions-1829630, factory, et-fc, revisions authored by das-peter, committed by plach:
    Issue #1155134 by das-peter, GiorgosK, zambrey: Added Integrate pathauto...
  • Commit 3b9fdc4 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions authored by das-peter, committed by plach:
    Issue #1155134 by das-peter, plach, GiorgosK, zambrey: Added Integrate...
  • Commit e154e83 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions authored by bforchhammer, committed by plach:
    Issue #1155134 by bforchhammer, plach: Integrated pathauto bulk...
  • Commit 5848768 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions by plach:
    Issue #1155134 by plach: Handle only nodes having entity translation...

  • Commit c8d5a47 on master, et-permissions-1829630, factory, et-fc, revisions, workbench authored by das-peter, committed by plach:
    Issue #1155134 by das-peter, GiorgosK, zambrey: Added Integrate pathauto...
  • Commit 3b9fdc4 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench authored by das-peter, committed by plach:
    Issue #1155134 by das-peter, plach, GiorgosK, zambrey: Added Integrate...
  • Commit e154e83 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench authored by bforchhammer, committed by plach:
    Issue #1155134 by bforchhammer, plach: Integrated pathauto bulk...
  • Commit 5848768 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench by plach:
    Issue #1155134 by plach: Handle only nodes having entity translation...