So, I'm trying to modify the Facebook Devkit script that is in my index.php to change depending the on the website's active language, but I'm not sure how to access the active language variable. I have tried both var lang ="<?php echo $lang; ?>";
which produces empty quotes, and var lang = document.documentElement.lang
just get me the browser language, not the active language on the site.
I know I could do this with a language specific template and just change the language value manually, but I don't foresee doing any other language specific stuff at the style or template level, so I think a quick regex fix would be better.
Update: If anyone is interested here's the code I used. Not pretty, but it works for my use case:
<script>(function(d, s, id) {
var lang = "<?php echo JFactory::getLanguage()->getTag();?>";
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
if (lang !="en-GB"){
js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.8";
} else {
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
}
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>