Skip Navigation

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 18 replies, has 2 voices.

Last updated by Bobby 2 weeks, 4 days ago.

Assisted by: Bobby.

Author Posts
September 11, 2024 at 9:47 am #16165512

sajaZ

Background of the issue:
I am experiencing an issue where Gravity Forms always sends email notifications in English, even when the form submission is in a different language (e.g., Arabic). The form has submissions in multiple languages, including Arabic and English. I am using multilingual support, and the site has both English and Arabic content. Link to a page where the issue can be seen: hidden link

Symptoms:
Regardless of the submission language, Gravity Forms notifications are sent in English. I expected the emails to be sent in the same language as the submission. Instead, I got the English email as it is without translation.

Questions:
Why are Gravity Forms email notifications always sent in English, even for non-English submissions?
How can I configure Gravity Forms to send email notifications in the same language as the form submission?

September 11, 2024 at 11:09 pm #16168312

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

I believe that is expected behavior, the email notifications send to the admin will be in the default language and will not change based on the language the form was included in.

Regarding to the emails you send to the users, you should be able to translate all through WPML->String Translation.

Let me know your results, please.

September 12, 2024 at 9:02 am #16169674

sajaZ

the email notification that is sent to users is not translated, for the admin its All fields so doesn't need to be translated

September 13, 2024 at 12:55 am #16173782

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for confirming.

Go to WPML → Theme and plugins localization.
Scroll down to Strings in the plugins and select Gravity Forms.
Click the Scan selected plugins for strings button to confirm.

Once finished go to WPML → String Translation.
Using the In domain filter, select gravityforms. You can also use the search bar to find the exact string you want to translate.

Let me know your results, please.

September 13, 2024 at 1:14 pm #16175637

sajaZ

I appreciate your help.

I already have the forms translated, and I checked the steps in the documentation on how to translate them and as you can see in the screenshot the translation says Completed.

I translated the field titles and it shows in Arabic, I translated the emails but I receive it only in English as the User who submits the form, either logged in or out.

Untitled.png
September 13, 2024 at 7:30 pm #16177612

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. Providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

September 16, 2024 at 7:03 pm #16185364

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for providing the access details!

Here’s what I’ve done:

Verified the Email Confirmation: I checked that the email confirmation is correctly translated.
Resent the Gravity Form for Translation: I made sure it's properly translated.
Conducted a Test Submission: I opened the test form in an incognito tab and submitted a test, utilizing the Email Logging plugin to capture the email activity on the server.
As illustrated in the screenshot and the email logger, the email was sent out in Arabic, as expected.

NOTE: I am deactivating the plugin now for email logging 'WP Mail Logging', feel free to re-activate it if you would like to perform the same test.

Screen Shot 2024-09-16 at 12.02.33 PM.png
Screen Shot 2024-09-16 at 11.56.47 AM.png
September 17, 2024 at 8:46 am #16186873

sajaZ

Thank you so much for taking the time and testing it.

this might seem crazy but it's not working, I tested it twice from logged in account and from incognito, I am already using WP SMTP for emails logging, but I thought it might be the email log plugin you used that made it work, so I tried again with the WP Mail Logging and still got English emails.

I don't understand how it worked with you, I submitted tons of times and I was always getting English emails.

Untitled.png
2Untitled.png
September 18, 2024 at 5:20 am #16191025

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Interesting behavior, I did the same thing once again, except this time I used my work email and I received it in AR.

See screenshot.

1. I visit hidden link
2. Add name and email
3. Works OK

What are your results if you test from a different browser or computer? For example your phone or a laptop?

Screen Shot 2024-09-17 at 10.18.21 PM.png
September 18, 2024 at 10:17 am #16192258

sajaZ

after doing some testing, if the email is not registered on the website it is receiving the right language, but if the email is registered on the website, its getting the English email always

when I checked, most users have this Site Language as English in their profile.

lang.png
WPML.png
September 18, 2024 at 6:01 pm #16194973

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Thank you for sharing this information! That makes sense as when sending emails to registered WordPress users, the language used is the user's preferred language based on what they set it as within their User Profile.

You can inform your users that they can set their preferred language in the WordPress admin under Profiles->Your profile.

As this is expected WordPress behavior, you might be able to create some custom work that would overwrite it, I'd suggest reviewing this hook that could possibly help.
https://wpml.org/wpml-hook/wpml_switch_language_for_email/#:~:text=Allows%20you%20to%20switch%20email%20language%20to%20user's%20preferred%20language&text=description:,not%20registered%2C%20nothing%20will%20happen.&text=(string)%20The%20user%20email.

September 19, 2024 at 7:43 am #16196376

sajaZ

Thank you but this doesn’t make any sense, as in woocommerce, events and even membership the emails will be sent depending on the page language you submitted from, so I expect the forms to be like that too.

September 19, 2024 at 11:13 am #16198138

sajaZ

// Global variable to store the form language
global $gf_form_language_for_email;
$gf_form_language_for_email = '';

// Step 1: Store the form submission language after the form is submitted
add_action( 'gform_after_submission', 'store_form_language_for_email', 10, 2 );
function store_form_language_for_email( $entry, $form ) {
global $gf_form_language_for_email;

// Get the language code of the form using WPML
$form_language = apply_filters( 'wpml_element_language_code', null, array(
'element_id' => $form['id'],
'element_type' => 'post_gravity_form',
) );

// Store the form language in a global variable
if ( $form_language ) {
$gf_form_language_for_email = $form_language;
}
}

// Step 2: Use the wpml_switch_language_for_email hook to switch the email language
add_action( 'wpml_switch_language_for_email', 'switch_email_language_based_on_form_submission', 10, 1 );
function switch_email_language_based_on_form_submission( $user_email ) {
global $gf_form_language_for_email;

// Check if the form language is set
if ( ! empty( $gf_form_language_for_email ) ) {
// Switch WPML to the form's language before sending the email
do_action( 'wpml_switch_language', $gf_form_language_for_email );
}
}

it didn't work also

September 20, 2024 at 7:09 pm #16203971

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for updating me!

This is a known and expected behavior of WordPress as it will always prioritize the user's selected language in their profile.

If a user is registered they can edit this on their own.

However, I am checking in with my team further and will update you once I have some feedback.

September 21, 2024 at 1:03 pm #16204875

sajaZ

thank you, but this behavior only affects Gravity Forms and it's recently only started to happen as before if I submitted from the Arabic website I used to get Arabic emails which now I don't.

I would appreciate your help with the function that would make it possible to send the email responses depending on the language the user submitted not his profile language.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.