Edward Ver Posted Friday at 01:05 PM Share Posted Friday at 01:05 PM 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 More sharing options...
elabx Posted Friday at 02:34 PM Share Posted Friday at 02:34 PM Try maybe: if($user->language->name == "en"){ //Processwire magic } 2 1 Link to comment Share on other sites More sharing options...
Edward Ver Posted Friday at 07:09 PM Author Share Posted Friday at 07:09 PM 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; ?> 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now