Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drasgardian’s picture

I found a way to get these to translate. Unfortunately I haven't quite figured out how to create patches since things moved over to git.

All I did was add the t() function around $variables['element']['#title'] at the bottom of nice_menus.module

i.e.

/**
 * Generate the HTML output for a single menu link.
 *
 * Function is a backport of Drupal 6
 */
function theme_nice_menus_menu_item_link($variables) {
  if (empty($variables['element']['#localized_options'])) {
    $variables['element']['#localized_options'] = array();
  }
  return l(t($variables['element']['#title']), $variables['element']['#href'], $variables['element']['#localized_options']);
}

vordude’s picture

FileSize
613 bytes

It looks like that's probably a good fix. I'd like another set of eyes with some translation knowledge to take a look at this, please, If there are other issues on this front, let's get them squared away.

Thanks.

vordude’s picture

Status: Active » Needs review
FatherShawn’s picture

Version: 7.x-2.0-beta2 » 7.x-2.0
Status: Needs review » Needs work

Throwing a t() function at this did not work on my multi-lingual site. We need to use the i18n api. See #1236450: Translated menu items show in all languages [Nice Menus] .

I'm willing to help get this working...

FatherShawn’s picture

Looking at the code, I see that the i18n api is called but doesn't work for me. I'm under time pressure for a project, so I've switched this one to the superfish module which is translating properly in my project. I like nice_menu so I'm still willing to help down the road as time permits...

guldi’s picture

Status: Needs work » Needs review

Ok, I found the bug. (7.x-2.0)

File: nice_menus.module
Lines: 450, 473

Change this:
'#title' => $menu_item['link']['link_title'],
to this:
'#title' => $menu_item['link']['title'],

If someone could please review this and create a patch?

Thanks!

mesr01’s picture

Was having the same issue here. #6 solved it.

Now version 7.x-2.1. This fix should probably be commited to dev.

nikosnikos’s picture

Version: 7.x-2.0 » 7.x-2.1
FileSize
1.71 KB

#6 solved the bug for me too.
Here's the patch
I couldn't make a patch on dev version because there's no file in it yet.

aschiwi’s picture

Honestly cannot reproduce this issue with a clean install of Drupal. The menu items translate nicely without the patch. Are there any steps to reproduce this behavior?

Either way, patch in #8 applies cleanly and menu item translation still works after applying.

guldi’s picture

It's correct buddy. Trust me.

$menu_item['link']['link_title'] is not translated, but $menu_item['link']['title'] is.

Don't know your setup. But the project I needed this is over since february. I don't remember what exactly the setup was and I also don't have time to reconstruct it.

Also when you review the whole context of the code you will conclude ['title'] as correct.

aschiwi’s picture

@guldi: I was just trying to help the issue queue by reviewing the patch and all I'm saying is I cannot reproduce the problem in a brand new Drupal install with just i18n, nice_menus installed and testing with two languages. vordude gave me this issue to check and I'm no coder, but I still wanted to leave my result after spending almost 2 hours on creating a setup to review this. I think this patch is small enough to be rtbc'ed but I cannot judge the code and don't see the problem with current installs of i18n and nice_menus, so just reported my result :)

So either a coder says it's okay to make the change even if it doesn't solve a problem or someone else can reproduce the problem and see if this fixes it.

guldi’s picture

allright. :)

nikosnikos’s picture

The translation problem appears when the i18n menu configuration is "Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized." and a menu item is "language neutral" (so it's a "Menu items without language").
My default site language is english. If I translate this item in french I always see it in english even if I'm on the french version of my site.

Patch #8 fix this kind of translation.

yareckon’s picture

This is definitely a problem we ran into today that resulted in us having to hunt around and finally disable nice menus. nikosnikos describes the correct context to reproduce this -- set a menu to be translatable with a fallback to localization via string translation. What happens is that with nicemenus the fallback to string localization does not work. I can't say if the patch has the right strategy to fix this, but the problem is real.

justafish’s picture

I've tested this and can reproduce the issue. Changing to $menu_item['link']['title'] fixes the issue. See the equivalent (kind of) at http://api.drupal.org/api/drupal/includes%21menu.inc/function/theme_menu...

One liner patch attached.

justafish’s picture

Status: Needs review » Reviewed & tested by the community
Wuk’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
FileSize
871 bytes
1.02 KB

There are two places to change 'link_title' to 'title'.
Created patch against dev.

Tested with i18n menu with localized and translated items.

For 2.1 patch is in translate-menu-item-1050352-17-v2.1.patch file.

rhayun’s picture

#17 solved the bug for me!!! thanks

yugi’s picture

Patches in #17 solved the issue with me as well. Thanks!

bessone’s picture

#17 worked for me on 7.x-2.1, thanks!

revnoah’s picture

I'm glad I found this post. I nearly threw out the module due to this unexpected problem.

JordanMagnuson’s picture

Great patch! Any chance of getting it committed?

kreatIL’s picture

#17 worked for me, too. It would be great to have this patch commited

DevElCuy’s picture

Priority: Normal » Major

I'm maintainer of module Menu token. I confirm that patches at #17 fix the issue here and also make Nice menus compatible with Menu token, which makes both modules even more powerful.

fraweg’s picture

Hello develCuy,

for me the translations with menu token works not completly. The menu is translatetd but the sitename without token is changed but with menu token the sitename is not translated.

Best regards
Frank

mohs3n71’s picture

Version: 7.x-2.x-dev » 7.x-2.1

this patch doesn't fixed my problem ...

Wuk’s picture

Version: 7.x-2.1 » 7.x-2.x-dev

What patch did you use and what version of nice menus?

xiukun.zhou’s picture

xiukun.zhou’s picture

Status: Reviewed & tested by the community » Needs review
DYdave’s picture

@fraweg, @mohs3n71, thanks very much for your comments and reporting.
We would greatly appreciate your feedback on the patch submitted by xiukun.zhou at #1590424-9: Token in menu item title not replaced if i18n menu translation is active.
Additionally, if it doesn't work or you encounter other issues, could you please provide more information (that could include screenshots, ideally) on the problems encountered? That would greatly help us trying to reproduce the issues and come up with a fix or appropriate solution.

I've tested the patch from #17, along with #1590424-9: Token in menu item title not replaced if i18n menu translation is active, applied against, respectively, nice_menus-7.x-2.1+3-dev (2012-06-13, at 94f4988) and menu_token-7.x-1.0-beta3+1-dev (2012-12-22, at 1e251fd) and everything seems to work fine/as expected with with i18n menu with localized and translated items.

This ticket has now been opened for almost a year already and I guess we would all greatly appreciate if this patch could potentially be rolled in/committed, after marking RTBC.

Note: After investigation, it seems the issues that you reported at #25 and #26 are not directly related with the issue discussed in this ticket and seem to relate with rather a different issue: #1590424: Token in menu item title not replaced if i18n menu translation is active from Menu token, in which develCuy is a maintainer.
So we would highly appreciate develCuy's feedback as well, which would also help confirming further if this attempt to fix these issues is successful or needs more work.

Feel free to let us know if you would have any other questions, concerns or issues on any of these patches, we would surely be glad to provide more information.

Any feedback, testing, reporting, questions, comments or issues would be highly appreciated.
Thanks again very much to all in advance.

malberts’s picture

Any updates?

Patch in #17 works for me (nice_menus-7.x-2.1+3-dev) in the scenario described in #13 (menu set to "Translate and localize" and menu item set to "Language neutral".

xiukun.zhou’s picture

Status: Needs review » Fixed

Thanks a lot to nikosnikos, DYdave, develCuy, Wuk, justafish, svovik1 and everyone else for the great work on the patches, testing, reviews and reporting.

It's more time this got committed and I went ahead and had this rolled at: 7.x-2.x: c031a01.

Marking this as fixed.

Please let me know if you would have any other questions, comments, issues or concerns on any of these changes, I would be glad to provide more information.
Thanks again to everyne for the help and great work on this issue.

Cheers!

Status: Fixed » Closed (fixed)

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