I'm trying to change the include path of a php file with javascript if the user changes the language of the website.
I'm using this code to check if the language of the website is english or not.
<script type="text/javascript">
$(function() {
var pathname = window.location.pathname;
if (pathname.search('/en/') != -1){
//I wanna insert the new path here
}
});
</script>
And then I wanna change the include function from
<?php include 'navigation.php'; ?>
to
<?php include 'navigation_en.php'; ?>
Does anybody know how to make this work? Or do I have to check the pathname with php to change the php include function?
substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)gives you the language code in PHP