Change text based on language

I use Wordpress with a language switch to switch between different languages. Inside the templates, I use this piece of code to switch hard-coded text.

<?php if(ICL_LANGUAGE_CODE == 'en') { ?>
   This is english
<?php } else { ?>
   This is another language
<?php } ?>

I have a sidebar, but it is created through various widgets, so I can not put the same fix.

Using jquery, how can I target all text inside a specific div and replace it with something else?

If I put this jquery in the code above then this should work, right?

+4
source share
1 answer

jQuery/JS , PHP , , , PHP JavaScript, . , - :

$(document).ready(function() {
    var language = '<?php echo ICL_LANGUAGE_CODE?>';
    if (language == "EN") {
        $("#IDOFDIV").html("NEW HTML HERE");
    }
});
+2

All Articles