Shortcode to add support for PolyLang plugin

Shortcode to add support for PolyLang plugin in field titles, descriptions and labels.

Make sure to:

  • Change Label name in Manage Fields (click image):

1

Label name must be (for English and Francais):

<span lang=”en-US“>Username</span><span lang=”fr-FR“>Nom d’utilizateur</span>

You can add as many languages as you need.

You must translate each field like in the e.g. above.

  • Add shortcode at the top of your page:

[wppb_polylang_compat]

Now when you change language with Language Switcher the fields language will change.

This is more like a hack to make it work.

/*
 * Shortcode to add support for PolyLang plugin in field titles, descriptions and labels.
 */

add_shortcode('wppb_polylang_compat', 'wppb_polylang_compat');
function wppb_polylang_compat($atts,$content=null){
   return "<script type='text/javascript'>
      jQuery(document).ready(function(){
         curr_lang = jQuery('html')[0].lang;
         jQuery('.wppb-user-forms li label > span, .wppb-user-forms li .wppb-description-delimiter > span').each(function(element){
            jQuery(this).hide();
            if ( jQuery(this).attr('lang') == curr_lang ){
               jQuery(this).show();
            }
         })
      });
   </script>";
}