• Hello Takayuki,
    I wanted to ask you if you think there was a way I could get Bogo to save the language preference a user chooses. Do you know if this can be easily implemented? Is it something you’d be interested in adding to Bogo?
    I know it’s available in Polylang and WPML, both of which I also use in different settings/situations but I’m very interested in seeing this in Bogo. If you could point me in the right direction, I could take a crack at trying to implement it myself as I’m sure you’re quite busy yourself.

    Thanks buddy

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Of course Bogo remembers each user’s language preference. It’s stored in the usermeta database table.

    Thread Starter orangeworx

    (@orangeworx)

    Hey there and thanks for responding. I think I didn’t explain myself properly. I said user but I should have said visitor. I don’t plan on having registration open for my site so the usermeta db table wouldn’t be accessed for site visitors. I would just like to save the language choice so that when the visitor returns, the site would load previous selection. I wonder if this is only done by cookies.

    Thanks

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Bogo sets lang cookie that contains the locale code of the front page the visitor last accessed.

    Thread Starter orangeworx

    (@orangeworx)

    Ok that’s pretty awesome! So in theory I can have a one-time popup as a language selector with a checkbox to remember preference? would that be difficult to implement? not that familiar with cookie control through a form or if doable either.

    edit: btw thanks a lot, I really appreciate the support!

    • This reply was modified 7 years, 7 months ago by orangeworx.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    In theory, yes. Setting the cookie is done in bogo_init() in bogo/bogo.php, looking into the function will be a help.

    Hello,

    This thread partially runs along the lines of a question I have.

    Currently we have a fully UK English website, we wish to have a small selection of pages available in a German alternative.

    In tests we’re running if the visitor first hits a UK Only page, then browses to a page that has a German version, chooses German via the switcher, then browses away to a different page that’s UK Only… then when they return to a page with the German option, they are not automatically shown the German page.

    I assume, by how you described your cookie working, as soon as they hit a page where only UK version exists, then the cookie amends to UK local for future pages.

    I guess one work-around would be to have a German duplicate of EVERY page, even if that supposed German page actually kept its English text. But a better solution would be that the cookie keeps track of the actual switcher choice the visitor makes.

    I added some lines of code to save user language on the following cases:
    yoursite.com/?lang=en
    yoursite.com/en

    I only needed to show the right language that I already translated with loco translate plugin. With some extra changes it could be possible to show automatically the right language for the page.

        $lang = bogo_get_lang_from_url();
    
        if ( $lang && $closest = bogo_get_closest_locale( $lang ) ) {
            bogo_set_cookie(bogo_get_closest_locale( $lang ));
            return $bogo_locale = $closest;
        }
    
        if(isset($_COOKIE['lang'])) {
            $default_locale = $_COOKIE['lang'];
        }
        return $bogo_locale = $default_locale;
    }
    
    function bogo_set_cookie($locale) {
        setcookie( 'lang', $locale, 0, '/' );
    }
    
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Language selection saved as preference’ is closed to new replies.