Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing an issue where the main language is Latvian, and while translating forms into English and Russian using WPML, the Gravity Form is being overwritten to English.
Solution:
We recommend the following steps to resolve this issue:
1. Edit the file at

wp-content/plugins/gravityforms-multilingual/inc/gravity-forms-multilingual.class.php

in the

Gravity_Forms_Multilingual

class.
2. Replace the code at line 772 from:

$st_context = $this->get_st_context( $form['id'] );
		// Cache.
		$current_lang = $sitepress->get_current_language();
		if ( isset( $this->current_forms[ $form['id'] ][ $current_lang ] ) ) {
			return $this->current_forms[ $form['id'] ][ $current_lang ];
		}

		$snh = new GFML_String_Name_Helper();

		$form = $this->populate_translated_values( $form, $st_context );

to:

$st_context = $this->get_st_context( $form['id'] );
		// Cache.
		$current_lang = $sitepress->get_current_language();
		if ( isset( $this->current_forms[ $form['id'] ][ $current_lang ] ) ) {
			return $this->current_forms[ $form['id'] ][ $current_lang ];
		}

		$snh = new GFML_String_Name_Helper();
 $check = new \WPML\Utils\DebugBackTrace();//add this
if ( $check->is_class_function_in_call_stack( 'GFFormDisplay', 'process_form' ) ) { //add this
	return $form;//add this
}//add this

	$form = $this->populate_translated_values( $form, $st_context );

3. Update the form and try to reproduce the issue.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by aigarsM 2 years, 11 months ago.

Assisted by: Osama Mersal.

Author Posts
January 28, 2022 at 7:44 am #10452601

aigarsM

Hello,

This is the same problem as described here https://wpml.org/forums/topic/wpml-overwrites-gravity-form/

The main language is Latvian and we are translating forms in English and Russian.

I followed supports instructions but still, the gravity form is being overwritten to English.

January 30, 2022 at 8:31 am #10463655

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I’ll be glad to help you today.

1) Could you please check if the issue persists in a minimal environment by following these steps?

1- Deactivate all the plugins except WPML, Gravity Forms, Gravity Multilingual.
2- Switch for a moment to a WordPress default theme like Twenty Twenty-one.
3- Update the original form.
4- Update the translation via WPML-> Translation Management. (https://wpml.org/documentation/related-projects/gravity-forms-multilingual/)

If the issue is gone, activate one by one to see which one is causing an interaction issue.

❌ Please backup your database and website before performing the above test ❌

2) If the issue persists in the minimal installation, would you please create a new test form and translate it to check if you will face the same issue?

Thanks for your cooperation

Regards,
Osama

February 4, 2022 at 8:35 am #10506203

aigarsM

I found the issue - in the "Gravity Forms Autocomplete" plugin there is an option to allow visitors to add a new option. When this option is enabled and the visitor adds a new option the whole gravity form is overwritten to a language the user is in.

Let's say the user has selected the Russian language as the website language and then proceeds to complete the form. In the form, he adds a new option to the autocomplete field and submits the form...Now in the CMS, the form will be in Russian!
This happens only when a person adds a new option from the autocomplete field!

I switched to Twenty Twenty-Two WordPress theme and the issue still persisted.

The "Gravity Forms Autocomplete" plugins support said that they can't help me and it's multilingual plugins fault.

"Gravity Forms Autocomplete" plugins page - hidden link

Any ideas on how to fix this issue?

February 4, 2022 at 8:54 am #10506279

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your update. Could you please login to this sandbox site and upload the "Gravity Forms Autocomplete" plugin? (hidden link)

After that, please create a test form and translate it, then try to replicate the issue. If the issue is replicable, kindly tell me the steps to reproduce it to consult our compatibility team regarding this issue.

Please note that this plugin is not officially compatible with WPML. You can check our computability list here. (https://wpml.org/plugin/)

Thanks for your cooperation

Regards,
Osama

February 4, 2022 at 9:33 am #10506557

aigarsM

Here is a video where I replicate the issue in the sandbox site hidden link

1)Open the form in a new tab (because when it will be overwritten to Russian you'll need a way to revert to the original language) hidden link
2)Go to the Russian page where this form is visible hidden link
3)The autocomplete CSS is broken so you'll need to remove the width property from the "select2-container"
4)Add a new option to autocomplete
5)Submit the form
6)Check if the form language has changed
7)If the language has changed then open the tab from the 1)step and save the form again so the form language will be English again

February 4, 2022 at 9:45 am #10506673

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for replicating the issue, the video, and detailed steps to reproduce the issue. Currently, I'm consulting our 2nd tier supporters, and I'll update you as soon as I get their reply.

I really appreciate your cooperation.

Thanks,
Osama

February 4, 2022 at 2:03 pm #10509443

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I've received our 2nd tier supporters' reply, and they found a workaround for this issue by the following steps:

1- Edit the (wp-content/plugins/gravityforms-multilingual/inc/gravity-forms-multilingual.class.php in \Gravity_Forms_Multilingual), and replace the following code Line 772

$st_context = $this->get_st_context( $form['id'] );
		// Cache.
		$current_lang = $sitepress->get_current_language();
		if ( isset( $this->current_forms[ $form['id'] ][ $current_lang ] ) ) {
			return $this->current_forms[ $form['id'] ][ $current_lang ];
		}

		$snh = new GFML_String_Name_Helper();

		$form = $this->populate_translated_values( $form, $st_context );

With the following code

$st_context = $this->get_st_context( $form['id'] );
		// Cache.
		$current_lang = $sitepress->get_current_language();
		if ( isset( $this->current_forms[ $form['id'] ][ $current_lang ] ) ) {
			return $this->current_forms[ $form['id'] ][ $current_lang ];
		}

		$snh = new GFML_String_Name_Helper();
 $check = new \WPML\Utils\DebugBackTrace();//add this
if ( $check->is_class_function_in_call_stack( 'GFFormDisplay', 'process_form' ) ) { //add this
	return $form;//add this
}//add this

	$form = $this->populate_translated_values( $form, $st_context );

2- Update the form and try to reproduce the issue.

I've applied these steps to the sandbox, and the issue seems to be fixed. Would you please check it and let me know if it works correctly?

Thanks,
Osama