Navigation überspringen

Open

Reported for: Gravity Forms Multilingual 1.7.2

Topic Tags: Compatibility

Overview of the issue

If you are using the Gravity Forms Polls Add-On plugin, you may experience issues where poll results do not display translated content when viewed in languages other than the default. This issue primarily occurs when the shortcode parameter is set to mode="results". Translations function correctly when the mode is set to mode=“poll“.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/wp-content/plugins/gravityformspolls/class-gf-polls.php file.
  • Look for line 2140.
  • Just before:
    1
    $gpoll_output['summary'] .= $field['field_label'] . '</div></div>';
  • Add this code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    // WPML Workaround for compsupp-7316 - Part I
    if ( class_exists('Sitepress') ) {
        $wpml_question = $field['field_label'];
        $textdomain = 'WordPress';
        $string_name = 'WPML Workaround : '.substr($wpml_question, 0, 20);
     
        $wpml_default_lang = apply_filters('wpml_default_language', NULL );
        $wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
     
        if ($wpml_default_lang == $wpml_current_lang ) {
            do_action( 'wpml_register_single_string', $textdomain, $string_name, $wpml_question );
        }  
        // Apply the translation to the string
        $wpml_question = apply_filters('wpml_translate_single_string', $wpml_question , $textdomain, $string_name);
     
        $field['field_label']   = $wpml_question// Replace the title
    }  
  • Then, look for line 2184.
  • Replace:
    1
    $gpoll_output['summary'] .= sprintf( "<div class='gpoll_choice_wrapper'><div class='gfield_description gpoll_choice_label%s'>%s</div>", $selected_class, rgar( $input, 'label' ) );
  • With:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    // WPML Workaround for compsupp-7316 - Part II
    if ( class_exists('Sitepress') ) {
        $string = rgar( $input, 'label' );
        $textdomain = 'WordPress';
        $string_name = 'WPML Workaround : '.substr($string, 0, 20);
     
        $wpml_default_lang = apply_filters('wpml_default_language', NULL );
        $wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
     
        if ($wpml_default_lang == $wpml_current_lang ) {
            do_action( 'wpml_register_single_string', $textdomain, $string_name, $string );
        }  
        // Apply the translation to the string
        $string = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name);
     
        $wpml_poll_label   = $string// Replace the title
    }
    $gpoll_output['summary'] .= sprintf( "<div class='gpoll_choice_wrapper'><div class='gfield_description gpoll_choice_label%s'>%s</div>", $selected_class, $wpml_poll_label );

Eine Antwort hinterlassen

Bitte bleiben Sie beim Thema und verhalten Sie sich anderen gegenüber respektvoll. Wenn Sie Hilfe bei Problemen benötigen, die nicht mit diesem Beitrag zusammenhängen, nutzen Sie unser Support-Forum, um einen Chat zu starten oder ein Ticket einzureichen.

Sie können diese Tags verwenden:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>