I m trying to implement this code to have different files to load for german, spanish or english browser languages of choice. The case is that with my spanish IE I still get the english file.
<?php
if (is_home()) {
if (preg_match( /de-DE/i , $_SERVER[ HTTP_ACCEPT_LANGUAGE ])) {
include(TEMPLATEPATH . /german-navbar.php );
}
elseif (preg_match( /es-ES/i , $_SERVER[ HTTP_ACCEPT_LANGUAGE ])) {
include(TEMPLATEPATH . /spanish-navbar.php );
}
else {
include(TEMPLATEPATH . /english-navbar.php );
}
}
I used both HTTP_ACCEPT_LANGUAGE
, and HTTP_USER_AGENT
.
This is the test of the site, if anyone wanted to check it, with german or spanish as a language of choice in the browser : http://paragraphe.org/janette/
I have my Firefox in english and is working nice, but I can t be sure the code is working for spanish and german cases.
I found the snippet in this SO thread, but I m a bit lost at this point.
Thanks so much for any input,
EDIT: the code does work in Firefox (but not IE).