I have a dynamic multilanguage website. My php echos the current language right, but javascript doesn't even if loading after body.
My php:
<?php echo $language ?>
This gives me english, portuguese, german or french accordingly to the one is being used.
when i try with javascript this way:
<script type="text/javascript">
function language() {
var ci = {
language : "<?php echo $language; ?>"
};
if(ci.language = 'portuguese') {
alert(ci.language);
return false;
fb_language = "pt_PT";
} else if (ci.language = 'english') {
alert(ci.language);
return false;
fb_language = "en_US";
} else if (ci.language = 'german') {
alert(ci.language);
return false;
fb_language = "de_DE";
} else if (ci.language = 'french') {
alert(ci.language);
return false;
fb_language = "fr_FR";
} else {
fb_language = "en_US";
}
};
</script>
<body onload="language();">
It always gives me portuguese in javascript, can't make it alert the right language, but in php it gives me the right language im using.