Problem/Motivation

Manually created menu items that have the same title as menu route cannot be translated via the UI and is not being translated by the Drupal core (probably because they have customized value set to 1).

Steps to reproduce:

Create a menu item with user/login path entitled Log in
When you want add translation to it you'll get This object has no strings available for translation.
i18n_menu will not add this link to strings
Translate Log in string (built-in interface text group!)
Switch to another language and you should see that menu item in question is not translated

Proposed resolution

Fix the checks in _i18n_menu_link_localizable_properties().

Original report by @Berdir

The first function checks the title against the the router title and only allows translation if there is a difference.

The second function does not contain such a check (and the check also wouldn't work, because it seems the title is already translated if the title callback is t()).

This results in situations where you can not translate the menu title in the UI, e.g. for manually created menu links that point to a panels page with the same title. But when you visit the page, then it tries to translate it and obviously doesn't find a translation but still overwrites a possible t()-based translation with the untranslated source string.

I am not sure where exactly the error is and what the proper fix is, so no patch yet :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sinasalek’s picture

I have the exact same problem and upgrading to the latest dev snapshot also didn't fix it

das-peter’s picture

Status: Active » Needs review
FileSize
1.02 KB

I think the essential difference to check for that's missing here is if the link is customized (manually created in the UI).
Local tests look good so far.

Jose Reyero’s picture

Status: Needs review » Needs work

I don't think the patch fixes the problem.

The issue is not that we cannot add a translation for the link, but that the menu link is being translated -tried to- in _i18n_menu_link_localize() when it shouldn't be (because it is localized with 't')

So I think to fix this we should add the right check into _i18n_menu_link_localize(), which is something like: if title callback == 't' and 'title' == router title (link_title), then do not localize.
Optionally if that's too hard, we could just check whether the link title has already changed and if so, skip translation there.

About these conditions, see menu.inc _menu_item_localize()

Jose Reyero’s picture

Taran2L’s picture

Hi everybody,

I can confirm that I have similar issue and this patch resolves it.

Issue summary: manually created menu items that have the same title as menu route cannot be translated via the UI and is not being translated by the Drupal core (probably because they have customized value set to 1).

Steps to reproduce:

  1. Create a menu item with user/login path entitled Log in
  2. When you want add translation to it you'll get This object has no strings available for translation.
  3. i18n_menu will not add this link to strings
  4. Translate Log in string (built-in interface text group!)
  5. Switch to another language and you should see that menu item in question is not translated

Couple more thoughts on this.

  1. Why does i18n_menu skip the contributed modules provided links ? Is there a reason for that ?
  2. Why does i18n_menu skip the links which have the same title as a corresponding menu router? I believe core is responsible for page title translation (with t()), but not the menu links (because we should distinguish between these 2 terms)

Thanks!

Taran2L’s picture

Taran2L’s picture

Taking into account #3 check attached patch.

Actually, why do not allow each item translation, despite the fact that title for menu router (page title) is the same as menu title. This creates non-consistent behavior and very hard to explain for a site managers. It's very confusing.

anbarasan.r’s picture

The same condition needs to applied for the description field as well.

anbarasan.r’s picture

Updated the patch to include the description field as well.

pbuyle’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.63 KB

The attached path is a re-roll of #9 for latest 7.x-1.x-dev.

pbuyle’s picture

Status: Needs review » Reviewed & tested by the community

Patch passed test, it's a reroll of another patch which was a enhancement of a patch already confirmed as working by Taran2L in #5. It fixes the inconsistency and the observed bad behavior it causes.

The last submitted patch, 9: i18n_menu-inconsistent-translatable--check-1897696-9.patch, failed testing.

sinasalek’s picture

Patch in comment #10 fixed the problem for me

theo_’s picture

Just run into this issue, and patch from #10 fixed the issue for me but need to be re-rolled against dev.

Here is the updated version

franz’s picture

I confirm same issue with a menu link called "Register". Patch from #15 fixes it.

kristiaanvandeneynde’s picture

This has been RTBC for a long while now, time to get this in?

  • Jose Reyero committed 1e547cf on 7.x-1.x
    Issue #1897696 by Taran2L, pbuyle, anbuindia, theo_, das-peter:...
Jose Reyero’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks everybody.

Status: Fixed » Closed (fixed)

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