Activemenu doesn't work with i18n

mvc - May 3, 2008 - 15:05
Project:Active menus
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I see this was reported and fixed in 5.x, but I'm now having this problem with i18n 6.x-1.0-beta1 and activemenu 6.x-1.x-dev (datestamp 1208995217).

#1

antiorario - July 12, 2008 - 08:01

I think it's a conflict with locale.module. I disabled all i18n modules and the problem persists, but only if I choose "Path prefix with language fallback" under /admin/settings/language/configure. Choosing "Path prefix only" apparently doesn't affect Active Menus.

#2

antiorario - July 12, 2008 - 08:04

Ok I'll correct myself. Active Menus does not work if a language prefix is present in the URL. I hope I'll have some time in the next few days to try to understand the issue better.

#3

Dofer - July 27, 2008 - 01:45

Not sure that it will be the best or even right fix. But it works for me :)

<?php
function activemenu_get_request_path(){
    global
$language;
   
$lang = '';
    if(
module_exists('locale'))
    {
       
$ln_negotiation variable_get('language_negotiation', 0);
       
$lang_list = language_list();
        if(
$ln_negotiation == 1 || $ln_negotiation == 2)
        {
           
$lang = substr($_POST['path'], 0, strpos($_POST['path'], '/'));
            if(isset(
$lang_list[$lang]))
            {
               
$language = $lang_list[$lang];
            }
           
            if(isset(
$_POST['path']))
            {
               
$_POST['path'] = substr($_POST['path'], strpos($_POST['path'], '/')+1);   
            }
        }
    }
    return isset(
$_POST['path']) ? drupal_get_normal_path($_POST['path'], $lang) : FALSE;
}
?>

#4

Eleazan - August 14, 2008 - 11:13

#3 it works for me... thnx!

I have edited the .js for use with locale, but it only works with the 'default' language, and now works for all :) (need undo my changes in the js).

Note: do you need to have a "language path", else, doesn't work with these language.

Sorry, my English is so bad.

#5

Dofer - October 16, 2008 - 15:18

Noticed that my previous fix worked only if language was sent in url

<?php
function activemenu_get_request_path(){
    global
$language;
   
$lang = '';
    if(
module_exists('locale') && isset($_POST['path']))
    {
       
$_GET['q'] = $_POST['path'];
       
$language = language_initialize() ;
       
$_POST['path'] = $_GET['q'];

       
$lang = ($language != language_default()) ? $language->language : '';
    }
    return isset(
$_POST['path']) ? drupal_get_normal_path($_POST['path'], $lang) : FALSE;
}
?>

#6

mvc - October 21, 2008 - 14:01
Status:active» needs review

Dofer's patch works for me using language switching via path prefix. I've attached a patch file with that change in case anyone wants it. Since I haven't personally tested this using language switching via domain, I'll leave this issue as "patch (code needs review)" for now.

AttachmentSize
activemenu.module.254277.patch 741 bytes

#7

nedjo - October 24, 2008 - 04:46
Status:needs review» fixed

Applied, thanks Dofer and mvc.

#8

Anonymous (not verified) - November 7, 2008 - 04:51
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.