• Resolved alexz

    (@alexz)


    Hello,

    We are using MLP and we’re very happy with the architecture the plugin solves. We are a bit confused with the HTTP Redirect feature though. We have implemented a custom language switcher which works well. Except from if people sets English as preferred language in their OS but clicks on Swedish as preferred language on the site.

    When someone browse to a Swedish page that has a linguistic relationship to English in the plugin, MLP negotiates the visitor back to English.

    The language manager looks like this: http://take.ms/TmMEv

    Is there something we could tweak? We get recurring complaints that our WordPress-site loses the memory of the language they prefer.

    function mlp_navigation(
        $between = ' | ',
        $before  = '<p class="mlp-lang-nav">',
        $after   = '</p>'
    )
    {
        $links = (array) mlp_get_interlinked_permalinks();
    
        if ( empty ( $links ) )
            return '';
    
        $items = array ();
    
        foreach ( $links as $link ) {
            if ( isset ( $link['text'] ) ) {
                $text = $link['text'];
            }
            else {
                // take just the main code
                $first = strtok( $link['lang'], '_' );
                $text  = strtoupper( $first );
            }
    
            $items[] = sprintf(
                '<a href="%1$s" hreflang="%2$s" rel="alternate">%3$s</a>',
                esc_url( $link['permalink'] ),
                esc_attr( $link['lang'] ),
                $text
            );
        }
    
        return join( $between, $items );
    }

    https://wordpress.org/plugins/multilingual-press/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    do your links point to URLs with a noredirect query parameter?

    Kind regards,
    Thorsten

    Thread Starter alexz

    (@alexz)

    Hello Thorsten,

    Yes, we link like this from the switcher: http://publit.com/sv/?noredirect=sv_SE

    But if a person continue to navigate within the site, the user gets redirected back to English. Our Swedish userbase experience this like language-amnesia.

    Thanks!

    Hi there,

    I just tested your website, and I can’t confirm the mentioned behavior.

    You offer Swedish, English and German. I set my browser to request English (only), then visited publit.com (without any query arguments), and got displayed the English page. I then navigated through a few pages, which were all English.
    After that, I chose German, navigated here and there, without any problems.

    We use $_SESSION to store a chosen language, so one explanation would be disabled session (cookies). But that, of course, wouldn’t be English-only…

    Did you change anything?

    Kind regards,
    Thorsten

    Thread Starter alexz

    (@alexz)

    I haven’t changed how the cookies work at the site, if that’s what you are asking.

    Hey alexz,

    I meant that users who don’t accept cookies might be redirected to the language that the browser and MultilingualPress think works best.

    This is hard to reproduce/debug, and when I tested your site, everything worked fine for me. Sorry.

    Is there only one (or very few) Swedish user(s), or is it throughout your Swedish userbase?

    Kind regards,
    Thorsten

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirects back to english although you've chosen Swedish’ is closed to new replies.