Closed (won't fix)
Project:
Internationalization
Version:
5.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Aug 2006 at 15:43 UTC
Updated:
4 Jan 2009 at 01:47 UTC
Jump to comment: Most recent file
Comments
Comment #1
Roberto Gerola commentedI have encountered the same problem.
Because the module overwrite the links adding the locale prefix, then Drupal cannot understand which menu
is selected.
I have solved, temporarly, creating a menu from scratch, not using menu module of Drupal, but it isn't a good solution, I admit.
Some patches to correct these problems have been released, but no one work for me.
An idea could be to create many different menus for every language and activate the correct block depending on the current language.
If you are interested, I've begun to write a new module to solve these type of problems :
http://drupal.org/node/81525
It isn't yet finished, but the basic features work correctly.
Comment #2
marc.bauIn general your module looks like well working! One thing that you may have not thought about and is very important - you are working with a session var and what will happen now with spiders? they will only spider your english content, while they are detected in this way - of detection is activated. spiders don't use cookies, so they will not follow your language switcher and get the content in different languages. This is a very big problem and for me a killer critera!
maybe you find a way to move the language to the hostname. My idea is "es.domain.com" or "en.domain.com"... then you are out of spiders pain, but possibly get other problems...
so - i think, this tons of bugs should better be fixed in i18n, however unusable and buggy this module is today.
Comment #3
Roberto Gerola commentedHi Marc.
Thank you for the hint.
I have updated the module.
Now it works correctly also with cache enabled (with two little changes to two system Drupal files).
And I've tried to make it spiders-friendly.
Substantially every page now has a link to its translated versions in the form : http://www.example.com?locale=it
If you are interested, I have published a post on my blog :
http://www.speedtech.it/drupal/localizermodule
Bye
Comment #4
marc.baubut you know - how difficult it is to get something in a search engine with url params attached?
This is why many websites have spider friendly urls without any url param... however dynamic the page is :-)
Comment #5
Roberto Gerola commentedHere there is a rewriting of the function menu_set_active_item located in menu.inc file that should fix
this behaviour.
(In the next days I'll prepare a patch file to submit)
Let me know !
Comment #6
Roberto Gerola commentedSorry, a mistake.
Here there is the correct code :
Comment #7
Bodo Maass commentedThanks for the patch. This looks very promising and does fix the secondary menus, but for me it stops the admin menu from expanding. I have the Navigation block enabled, and this block contains the admin menu. The secondary menu is in a separate block. So while the secondary menu expands now, the admin menu in the Navigation block doesn't.
Comment #8
Bodo Maass commentedHere is a slight modification that seems to fix the admin menu for me. This works in 4.7.3:
Comment #9
Bodo Maass commentedFinally, this depends on the locale module to be enabled and will cause errors if locale is turned off. To allow a more graceful degradation, it should check first if locale is available, so the line
should be:
Comment #10
Roberto Gerola commentedHi.
In the past days I've worked hard to figure out a way to remove this patch from Drupal core from my localizer module.
I don't use anymore i18n module but I was glad to share my code with you.
The important code is located and the function : localizer_menu_translate_all.
When the module translates the menu it also determine which items to expand
and simply change the type of the menu.
With this new function, also the patch to common.inc l() function is no more necessary
because it changes on the fly the path of the menu item.
I've attached the source code of my module if someone is interested to use some pieces
in i18n module.
Comment #11
joestewart commentedThe code in #8 does expand the menu however a side effect is the local task tabs ( view, edit, etc) are not shown now.
Any quick hints to get them to display as well? Or do others not have the same problem?
Jose - Is the menu not setting the active item ( not expanding) a confirmed bug now? What are plans to fix? On the site we are implementing this it totally breaks navigation without the fix. But with the patch administration is hindered greatly.
thanks,
Joe
Comment #12
karunadev commentedI can confirm that the menu "current", "active" state is not being set with Internationalization in place.
What was once:
Has become:
Comment #13
karunadev commentedLets try this again. Yes the active state is not working.
What was once
<li id="primary-link-1-current" > <a href="/about_khadro" title="How is Khadro?" class="active">About Khadro</a> </li>Is now:
<li id="primary-link-1" > <a href="/en/about_khadro" title="How is Khadro?">About Khadro</a> </li>Comment #14
orospakr commentedHi folks!
With the addition of a few more hacks, this patch takes a stock Drupal 4.7.4 () menu.inc and fixes both the missing tabs issue and the missing active highlight on translated nodes. I did it by creating a second copy of the menu_set_active_item() and menu_get_active_nontask_item() functions that contain the original stock logic. I then modified all the menu_* functions that are involved in producing the primary links to use the the original functions instead. It's not very pretty, but it gets the job done while we wait for a proper fix for menus and URL paths and i18n in general.
Yes, I know .5 is out, I imagine this should apply OK with maybe a hunk or two though.
This patch is not at all appropriate for any kind of merging, and the proper solution to this problem would be to have the menu system refactored so it no longer relies on paths to link together the menu hierarchy (and *cough* properly integrated i18n of some kind in Drupal core would be nice).
Good luck!
Comment #15
jose reyero commentedI'm a bit confused about all this. Are you talking here about path aliases with language prefix or without?
Would you please add actual path samples?
The fact that path aliases with language prefix have some problems with menu expansion and active links is a known issue. However I am not sure whether you're talking here about normal aliases of this other ones, with language prefix.
Whatever, the policy for i18n module since a while ago is that we won't add drupal patches into the module but anyway if someone wants to help compiling a list of available patches, will be welcomed.
I'm putting together some extensive documentation for i18n on Drupal 5. Path aliases with language prefixes will be an unsupported 'you-can-use-it-but-has-some-problems' feature for now. Thus the solution atm is to use different aliases for each language.
Comment #16
orospakr commentedI think it will only work on language path aliases, not custom ones, given the nature of Roberto and bodomaas' original patch.
It's all a nasty hack to begin with. Drupal's menu system is ass and really needs to be refactored/rewritten.
As I said before, this patch is only meant to tide people over until that day. It is not of appropriate quality to be merged into anything.
Comment #17
orospakr commentedAs for a sample usecase:
There are two nodes: one has the path /mynode and the other has the path /fr/mynode. Going to /fr/mynode would cause the menus to not expand as they would at /mynode, which gets very awkward when using i18n and category/taxonomy at the same time.
This patch "solves" this by fooling most of the menu system into thinking that you're actually looking at the English version of the page (which is what broke the tasks tabs.).
Comment #18
orospakr commentedI noticed that anonymous users could see the menu items if the patch was applied. I've made yet another nasty hack to 'fix' this. bleh.
Note this diff should be applied to the stock menu.inc.
PS. I mistakenly changed the title of the thread in one of my earlier posts. I've put it back.
Comment #19
orospakr commentedhmm, when you're editing a node all the menu items become active.
Oh well, it doesn't seem to be a really serious issue.
Comment #20
hass commentedif my menu isn't expanding this IS serious.
Comment #21
solide-echt commentedI'm also experiencing the 'all itmes active' issue, but I can't pinpoint where it goes wrong in the code. If I find a solution, I'll post it. I'm using a 4.6 version b.t.w (for historic reasons >_<)
Comment #22
solide-echt commentedDo you have any idea where I have to search for the cause ? I really don't have any clue
Comment #23
scb commentedI think this is not related to i18n. This is happening to me in 5.0 without i18n module installed. May be an error on my side, but I think it is a bug related to aliasing in general.
Comment #24
orospakr commentedYes, you're right.
Any kind of path rewriting (like i18n does) fouls up the menu system.
It uses the path string to store menus, which is the source of the trouble.
Comment #25
vinoth-kumar commentedIn drupal 5.3 the primary menu item is not highlighted when secondary items were selected, i need both the secondary item and the corresponding primary item are selected....
How to acheive this?
Thanks...
Comment #26
jose reyero commentedThis branch is not supported anymore. Consider upgrading to 5.x-2 or (better) 6.x