Jump to content

Using different javascript for multilanguage website


Edward Ver
 Share

Recommended Posts

How to load a different js for another language? I'm new to PW, and my first time developing a multi language website in PW too. I came across a problem where I have to load a different js for english for example.

Norwegian (default lang): <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-no.js" defer></script>

How to load it if the url is mydomain.com/en.

 

Thank you in advance.

 

Link to comment
Share on other sites

That works! Thank you so much!

<?php if($user->language->name == "en-gb"): ?>
    <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-en.js" async></script>
    <?php else: ?>
        <script src="<?php echo $config->urls->templates; ?>assets/scripts/cookieconsent-init-no.js" async></script>
<?php endif; ?>

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...