I tried to retrieve the current ICL language with this code but it doesn't work.
var getLangCode = '<?php echo ICL_LANGUAGE_CODE; ?>';
alert(getLangCode);
Do you know how can I get the current language code with javascript ?
Thanks in advance !
You just need to place the quotes in the right places.
Remove quotes before <?php
and after ?>
and surround the PHP constant with double quotes.
var getLangCode = <?php echo '"' . ICL_LANGUAGE_CODE . '"' ; ?> ;
alert(getLangCode);