Skip Navigation

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

Problem:
The client is experiencing an issue where Gravity Forms sends email notifications in English, regardless of the submission language. This problem occurs even when the form submission is in a different language, such as Arabic.

Solution:
We recommend the following steps to address the issue:
1. Go to WPML → Theme and plugins localization, scroll down to Strings in the plugins, select Gravity Forms, and click the 'Scan selected plugins for strings' button.
2. After scanning, navigate to WPML → String Translation. Use the 'In domain' filter, select 'gravityforms', and use the search bar to find the exact string you want to translate.
3. If the issue persists, especially for registered users whose profile language is set to English, it might be due to WordPress prioritizing the user's selected language in their profile. You can inform your users to set their preferred language in the WordPress admin under Profiles->Your profile.
4. For further customization, consider using the wpml_switch_language_for_email hook or the determine_locale function.

If these steps do not resolve the issue or if the solution seems outdated or irrelevant to your specific 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.

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 9 months, 2 weeks ago.

Assisted by: Bobby.

Author Posts
September 23, 2024 at 10:29 pm #16212016

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

I have confirmed with our compatibility team that indeed this is expected WordPress behavior as previously stated and outside the control of WPML.

As this will require custom work we recommend reviewing also this WP hook as well https://developer.wordpress.org/reference/functions/determine_locale/

Unfortunately, custom solutions are not within the scope of the support on this forum which is why we suggest contacting a 3rd party certified developer for multilingual sites from here:
https://wpml.org/contractors/

September 24, 2024 at 9:20 am #16213346

sajaZ

okay, I understand that, thank you

is there a hook for the gravity forms notifications?

as I tried to change it with this code but I still receive the English emails, although the Local language is set to arabic

// Hook into Gravity Forms notifications to ensure the correct locale is applied for emails
add_filter( 'gform_pre_send_email', 'set_gravity_form_notification_locale_before_email', 10, 3 );

function set_gravity_form_notification_locale_before_email( $email, $message_format, $notification ) {
// Check the current language of the site using WPML
$current_language = apply_filters( 'wpml_current_language', null );

// Debug log for current site language
error_log( 'Locale for Notification: ' . $current_language );

// Switch WPML to the detected current language for email generation
if ( function_exists( 'do_action' ) && $current_language ) {
do_action( 'wpml_switch_language', $current_language );
}

return $email; // Continue with the email sending process
}

// Hook into determine_locale for other locale-based handling
add_filter( 'determine_locale', 'custom_determine_locale_based_on_site_language', 10 );

function custom_determine_locale_based_on_site_language( $locale ) {
// Check if this is a Gravity Forms submission
if ( isset( $_POST['gform_submit'] ) ) {
// Check the current language of the site using WPML
$current_language = apply_filters( 'wpml_current_language', null );

// Debug: log the current language
error_log( 'Current Site Language: ' . $current_language );

// If the current language is Arabic ('ar'), force the locale to Arabic
if ( $current_language === 'ar' ) {
$locale = 'ar'; // Set the locale to Arabic
} else {
// Otherwise, set the locale to English
$locale = 'en_US';
}

// Debug: log the determined locale
error_log( 'Determined Locale: ' . $locale );
}

return $locale;
}

September 24, 2024 at 12:45 pm #16214969

sajaZ

Actually the easiest way for me to fix this issue for now is to downgrade to Version 1.7.2
because in version 1.8.0 you marked this as an issue and fixed it but its not an issue, this is how the emails should work.

so if you can tell me which function I should modify ion the plugin it would be appreciated as none of my functions worked and I spent so much time on this issue so far and Im sure you have tons of other tickets open

fix.png
September 24, 2024 at 2:34 pm #16215616

Bobby
WPML Supporter since 04/2015

Languages: English (English )

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

Hi,

I have not seen any related tickets as this is an expected workflow with WordPress rather than a workflow that WPML enforces.

What you are referring to was handled as a fix and not as a new feature therefore there is no function I could provide that would overwrite this behavior, also it is not directly related to this workflow.

You are welcome to use the older version, however, please note that we do not recommend doing this as it is a version that is no longer supported.

For further custom work, you can consider contacting one of our recommended developers: https://wpml.org/contractors/