It seems that Menu translation currently does not provide support for translating item descriptions.

CommentFileSizeAuthor
#9 i18n-844208-9.patch573 bytesplach
#1 i18n-844208-1.patch2.85 KBplach

Comments

plach’s picture

Status: Active » Needs review
StatusFileSize
new2.85 KB

The attached patch allows to translate descriptions by slightly refactoring _i18nmenu_get_item() and friends. This shouldn't be a problem as it is a private function, hence this does not qualify as an API change.

miro_dietiker’s picture

just by skimming through the code:
how about refresh process? will the desc items be created?
why do you use 'title' as a key for the description?

plach’s picture

how about refresh process? will the desc items be created?

Yes, the strings are updated in _i18nmenu_update_item() and possibly in i18nmenu_localize_tree().

why do you use 'title' as a key for the description?

I don't :)

The key is 'menu:item:'. $link['mlid'] .':description'. However the output value used to render the menu item description is taken from $item['options']['attributes']['title'], hence the patch uses that one.

miro_dietiker’s picture

i was asking you for exactly this 'title'.. find below:

$item['localized_options']['attributes']['title'] = _i18nmenu_get_item_description($item);

and

+        $tree[$index]['link']['localized_options']['attributes']['title'] = _i18nmenu_get_item_description($link, $update);

Can you again try to explain me, why this needs to go through the 'title' attribute and not something like 'description'?
I might need to go through the whole menu build/translation process once to understand this in full detail.

plach’s picture

Can you again try to explain me, why this needs to go through the 'title' attribute and not something like 'description'?

Honestly I didn't have the time to study the menu code deeply, I just realized that the value typed in the "description" field of the menu item edit form is stored in the $item['options']['attributes']['title']; this value is copied into the $item['localized_options']['attributes']['title'] field on rendering to avoid using a translated value in the item edit form. Skimming through the menu code it seems there is a native support for the description translation through t(), but only if title and description are identical (see http://api.drupal.org/api/function/_menu_item_localize/6).

jose reyero’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks good.

Replying some question here, the menu 'title' attribute is the HTML 'title' attribute for menu links so everything looks fine to me.

Feel free to commit.

plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the DRUPAL-6--1 branch. Thanks!

Status: Fixed » Closed (fixed)

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

plach’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new573 bytes

The item description string is not removed when the menu item is deleted.

miro_dietiker’s picture

Status: Needs review » Fixed

Great plach. Fixed it in cvs.

Status: Fixed » Closed (fixed)

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