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' );