• Hello, I’m just developing my website online and despite setting the plugin to redirect on the first time one visits it to their preferred language, it apparently didn’t work.

    Is there something else I should be doing besides checking the box?

    Perhaps could it be that when it looks for a “br” for Brazilian Portuguese it just doesn’t find on the browser since the most common definition of it is pt-br?

    I’m using Version 1.9.16

    Thank you for this amazing plugin.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Alex Gor

    (@alexgff)

    It works, just before testing the first time visit delete cookies.

    Thread Starter MuninMunin

    (@muninmunin)

    …I don’t think so?

    I tried on opera with no cookies, tried in another pc inside my network and two phones that never accessed the website. All have Portuguese as their language but it only opens on the English default, never redirects to /br.

    Only action taken android’s chrome that likes to be all independent and translate by itself.

    Do you have any suggestions?

    Thread Starter MuninMunin

    (@muninmunin)

    @alexgff

    I finally got some time to check out what is wrong with the redirect feature and… surprise! It doesn’t work exactly like I guessed. This probably is the case for any variation of one language.

    I didn’t test the actual cookie setting yet because I honestly have no experience with this kind of thing, but I threw this piece of code while on the /br page of my website:

    <?php
    
    $lang1 = WPGlobus::Config()->language; // how you guys usually check for language
    
    $redirect1 = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ); //line used on redirect
    
    echo "<h1> Your browser language is " . $lang1 . " while redirect thinks it is " . $redirect1 ."</h1>"
    
    ?>

    And the result was…

    “Your browser language is br while redirect thinks it is pt”

    The two variables you’re using are conflicting.

    The issue is probably not with the actual object trying to redirect but how it is comparing, like I stated before, WP-globus set in Brazilian Portuguese considers it as “br”, logically so because it wants to differ itself from “pt”.

    However browsers present themselves as “pt-br” ALWAYS, and so do web pages on html’s lang property. the substr is taking the “pt”, looks up if my the website has a “pt” lang, which it doesn’t, and doesn’t redirect.

    Again, I could be wrong, because I didn’t find what is using public static function redirect( $language ) {

    But this is most likely what it seems to be.

    Now for my case I’ll likely throw an if statement on the redirect object and pray I remember that if the software updates. But this is a problem that is probably making many users not even know their website is not redirecting, and undermining your own work.

    I know I’m no one to ask you guys to fix a service you’re doing for free, and I’m not. However, please perhaps next time not just dismiss a report and mark as solved?

    Plugin Contributor Alex Gor

    (@alexgff)

    This task is in our backlog list.

    Thread Starter MuninMunin

    (@muninmunin)

    Thank you, this is all I needed to hear.

    And again, thank you so much for this amazing plugin, it is my favorite thing in the entirety of wordpress.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘First time redirecting not working?’ is closed to new replies.