Multilingual custom javascript CTA button

Hello,
I’ve got one question. As much as I like this theme, I’ve just run into one pitfall, let’s say. I’ve created another Call to action button in the slider with the help of Custom javascript. The thing is that I run the website in two languages, however, I don’t know how to get the js button to Czech.

I’m using Polylang, so I’m wondering if there is any hook around to make another button for the Czech version, or the only way is somehow through the custom Polylang string translation?


The “travel with me” is the one that needs to be translated.

Thank you very much for your hint.
Jirka

Hello Jirka,

Please try replacing your current jQuery code with this one:

    jQuery(function($) {

      var myButton = '<a href="https://www.journeyisthegoal.com/" class="roll-button button-slider">Travel With Me</a>';
      var currentLang = $('html').attr('lang');

      if(currentLang == 'cs-CZ') { // Translated button
        myButton = '<a href="https://www.journeyisthegoal.com/another-link" class="roll-button button-slider">Translate Me</a>';
      }

      $( '.slide-inner' ).append(myButton);
      
    });

Adjust the translated button link and label in this line:

    myButton = '<a href="https://www.journeyisthegoal.com/another-link" class="roll-button button-slider">Translate Me</a>'; 

Regards,
Kharis

It works! Great! Thank you very much for your help :wink:
Jirka

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis