0

the problem is I am making dual language website with JS and CSS only. Language change is triggered with button, here's a sample of JS for reference:

function languageSwitch() {
  var state = $('.lang-pl:visible').length ? 'pl' : 'en';
  if (state === 'pl') {
    $('.lang-pl').css('display', 'none');
    $('.lang-en').css('display', 'inherit');
  } else {
    $('.lang-en').css('display', 'none');
    $('.lang-pl').css('display', 'inherit');
  }
  return false;
}

Everything looked great, but I hit a brick wall when it came to translating submit button. On regular fields like labels and even [acceptance] it wasn't problem and it worked like a charm:

<label> <span class="lang-pl">Imię i nazwisko *</span> <span class="lang-en">Name and surname *</span> [text* your-name] </label>

But with this code submit button isn't working- it's showing 'lang-pl' version before and after switching languages:

[submit <span class="lang-pl">Wyślij</span> <span class="lang-en">Send</span>]

Anyone have idea how to solve it?

  • Have you tried setting css displayto block or inlineinstead of inherit? Also, is your languageSwitch() function called at all? It's defined in your code, but not actually called. – Pim Sep 25 '18 at 8:09
  • Just tried, didn't work- I am not sure about Contact Form 7 itself- maybe built-in elements like [submit] wasn't made for my purpose – pixelove Sep 25 '18 at 8:12
  • Is your languageSwitch() function called somewhere? – Pim Sep 25 '18 at 8:14
  • Yeah, it's starting at document.ready(); and all parts of website works perfectly- that one button isn't. – pixelove Sep 25 '18 at 8:20
  • I would say it's an issue with your conditional $('.lang-pl:visible').length, maybe you can try to grab the current language from another element and then run the rest of the code. – Pim Sep 25 '18 at 8:26
0

Just found solution:

I've switched default [submit] with

<button id='submit' class='wpcf7-form-control wpcf7-submit'><span class="lang-pl">Wyślij</span> <span class="lang-en">Send</span></button>

and it works like a charm, now just styling in CSS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.