IF & else in Jquery - choosing a language code

Hello to the dedicated WPMU staff.

I have a beatifull Jquery code, which shows a beautiful map.

However the site is bilingual and I need to say to the site: if the lan is en En, display

<script src="https://maps.googleapis.com/maps/api/js?key=API&callback=initMap&language=en"
async defer>
</script>

Do I need to say "if" else" or is it possible to say just "if"?

I don't want to touch the rest of the code, which is quite complicated, how to I tell at the end of the jquery code if enlgish then

<script src="https://maps.googleapis.com/maps/api/js?key=API&callback=initMap&language=en"
async defer>
</script>

is there such an option?

  • Tyler Postle

    Hey Fortunella,

    Hope you're doing well today! I consulted with one of our more code savvy staff regarding your question here and we will need a bit more information.

    Is this:

    <script src="https://maps.googleapis.com/maps/api/js?key=API&callback=initMap&language=en"
    async defer>
    </script>

    In a template file or via a functions.php function perhaps? Wondering whether it's in a php file or not. If it is then we could use php like this:

    <?php if ($_GET[language']=='en' { ?> HERE JS <? }

    Otherwise touching the complicated js that you didn't include above may be necessary.

    Cheers,
    Tyler

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.