Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sam0kc

    (@sam0kc)

    Okay, I found a solution. It’s actually my “plan B”.

    With a <select name=”langageSelect”> in the PHP file, here is the content of the JS file:

    document.querySelector('select[name=languageSelect]').onchange = setCookieAndReload;
    function setCookieAndReload() {
    	MsSepPreferredLanguage = document.querySelector('select[name=languageSelect]').value;
    	document.cookie = "preferredLanguage="+MsSepPreferredLanguage;
    	window.location.reload(true);
    }

    This is gonna set a cookie to remind the language preferences of the user..

    … and added in the functions.php file:

    function wpse_52419_change_language( $locale )
    {
        return $_COOKIE['preferredLanguage'];
    }
    add_filter( 'locale', 'wpse_52419_change_language' );
    Thread Starter sam0kc

    (@sam0kc)

    To precise something: the translations are handled with .po files, in the /language folder of the homemade theme…

    Thread Starter sam0kc

    (@sam0kc)

    It actually doesn’t help, because as said in the first post, the visitors of the website won’t go in the administration panel to set their preferred language

Viewing 3 replies - 1 through 3 (of 3 total)