Over in #925778: User edit title is broken (so is beta1-beta2 upgrade path) sun came up with a clever trick to solve the need of a per-page-request change of menu links for which he used hook_translated_menu_link_alter(). But, you'd never know from reading http://api.drupal.org/api/function/hook_translated_menu_link_alter/7 that the hook could remotely be used for that purpose.

Manarth came up with some pretty good documentation to explain this in http://drupal.org/node/925778#comment-3579198 but it was deemed too heavy for the part of the code it was in. It should instead be transferred and massaged to the PHPDoc of this function.

Comments

sun’s picture

Assigned: Unassigned » sun

The cause is that "translated" does mean the common meaning of "translation" or "localization". I guess this issue can be resolved by simply clarifying what "translated" means in the phpDoc first. The remaining, existing docs read fine for me.

jhodgdon’s picture

so you want to do this sun?

sun’s picture

Assigned: sun » Unassigned
Status: Active » Needs review
StatusFileSize
new2.88 KB

Pretty much complete starting point. Happy to review further patches, but won't have time to work further on this patch.

jhodgdon’s picture

A few things need fixing here -- I'll make a patch later today or tomorrow if someone else doesn't get to it first.

a) Typo: "property of the mnu link." (should be menu not mnu)

b) Looking at the code in http://api.drupal.org/api/function/_menu_link_translate/7, I think that we should add a line in the doc of hook_menu_link_translate_alter clarifying that it is only called if $item['options']['alter'] has been set. This is illustrated in the examples in hook_menu_link_alter, which is good, but it should be mentioned in this other hook too I think.

c) Looking at the code, I don't see where it declines to call this hook if the access flag is FALSE necessarily. So I don't think "after the user access to the link's target page has been checked and led to a positive result." is actually accurate? I see that it returns before the hook is invoked in some cases, but I don't see anything that returns after _menu_check_access($item, $map) if the access flag is false. Maybe that's a bug?

d) We should also clarify in the explanation of what "translated" means, that it also does localize the text (i.e. the normal meaning of the English word "translate").

jhodgdon’s picture

StatusFileSize
new2.82 KB

I just realized that the bit about the alter flag was there, but I didn't notice it due to where it was in the doc, so I moved it up.

Here's a new patch, with the changes noted in comment #4.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

dries’s picture

Status: Reviewed & tested by the community » Fixed

Nice clean. Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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