i recently worked on a multilingual project using drupal 6.3 and just found that there's something need to be changed or improved in drupal's multilingual support.
for example, i want to add a primary link "about us". first i creat a page with url path 'about', then i went to 'site building'->'menus', add a new menu item titled 'About' and pathed 'about' under primary links and then successed with system showed a message like this
The menu system stores system paths only, but will use the URL alias for display. about has been stored as node/49.
then i enabled translation for page, made some translation to other language for example chinese.
and then i enabled the switch language block and did some test. if i switched to chinese and click the 'about us' menu, it still show the english version due to its link pointing to node/49 and that's the english version.
then i tried contributed module i18n. if i enabled the i18n module, when switching to chinese, the menu 'about' is just disappeared because i18n module did some filter with its hook i18n_db_rewrite_sql().
so what's the solution?
solution no.1.
you can add each version of menu item to the menu links. for example, if i add an item 'about us' pointing to node/49 and another item 'about us' pointing to node/50(supposed this is the translation version of node/49) and enabled i18n module, then it worked as you expected.
the problem of this solution is that you must do some duplicated work. if you want your system to support more languages, you have to add more and more menu items. this solution is ugly.
solution no.2.
in drupal 6.3, path alias uniqued by name and language. for example, i could have an alias 'about' in language 'english' pointing to node/49, also an alias 'about' in language 'chinese' pointing to node/50. so if i store my menu item link with 'about' but not 'node/49' to the table menu_links, then i can get the right version of language when clicking the menu item, because function drupal_lookup_path() will pick up the most fitting source according alias name and current system language selection. to get this done, we need to modified the file menu.inc in include directory and menu.admin.inc in module menu. i made a patch and did some test, this works for me.
so my question is should we change the currently store type from normal path to alias in menu_links table?
sorry for the bad english.
| Comment | File | Size | Author |
|---|---|---|---|
| menu_links.patch | 2.46 KB | wilson98 |
Comments
Comment #1
strellman commentedI completely agree. I have the same issue. I figured out that I can name the alias "about" in each language and links will work fine, but not the menu system. You can't work around this with a fully qualified path http://mysite.org/about because you need the language prefix for /ro and /ru. So the only solution is to have either very big menus with node specific items duplicated in every language, or to create new menus for each language and show that block depending on language.
It would be so much easier if you could just use the alias. Maybe there is a reason we don't store it.
Maybe someday we can even put PHP in the menu or use Tokens to get to the content_profile of the user.
Comment #2
damien tournoud commentedNo. What you want is a link pointing to a translation group (or to use hook_translated_menu_link_alter() to dynamically alter the path of the node link). For Drupal 6, that's IMO the job of the i18n package.
Comment #3
strellman commentedDamien, is there a reason we can't store the URL alias?
Comment #4
ahallez commentedThe proposed solution gets my vote.
I want to use the select_translation module to have the correct translations selected in my views. This module requires that the i18n content negotiation is set to 'all content'. However if I do this, the menu items do not link to the correct translation of the pages.
Comment #5
strellman commentedI found a partial solution.
At /admin/settings/language/configure my setting was path prefix only and changing this to
Path prefix with language fallback
Seems to allow http://example.com/about to pull up Russian if that is my user preference.
Of course this only works if logged in. It doesn't use the language preference set in IE.
It sure would be great if the menu system kept the path alias like "about" or "home" instead of converting them to node/183.
Comment #6
jose reyero commented#1303518: Clean up the issue tracker. Close old issues without follow up.