Skip Navigation

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

Problem:
You are trying to translate the wpforms email body.
Solution:
While we work on a permanent fix, we recommend you try this temporary workaround. Please add the following code to your functions.php file:

add_filter('wpml_st_string_translation_before_save', 'sanitize_translation_before_save', 10, 1);
 
function sanitize_translation_before_save($translation_text) {
    $translation_text["value"] = str_replace("\n", "\r\n", $translation_text["value"]);
    return $translation_text;
}

This code modifies the translation text to ensure proper formatting. You can verify its functionality in the provided Sandbox, where the entries are logged in the installed "WP Mail Log" plugin.

If this solution does not resolve your issue or seems outdated, 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 needed, please do not hesitate to open a new support ticket at WPML support forum for further assistance.

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

Last updated by Marcel 6 months ago.

Assisted by: Marcel.

Author Posts
October 15, 2024 at 1:19 pm #16290960

petrH-5

Background of the issue:
I'm trying to translate wpforms email body with "String translation" and I will not respect line breaks as original text. Following official recommendation to use WPML Wpforms plugin and translate it with String translations.

Symptoms:
Line breaks in the wpforms email body are not respected in the translation.

Questions:
How to configure WPML to follow line breaks in translated text in email?

October 15, 2024 at 5:32 pm #16292216

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

do you have a staging environment available where I can conduct additional tests?

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT
-Please make a backup of site files and database before providing us access.
-If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Best Regards,
Marcel

October 16, 2024 at 4:22 pm #16296961

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

Thanks! Everything looks correct on your site.

I’ve set up a hidden link">sandbox environment and imported your existing forms to verify if there’s an incompatibility. I encountered the same issue, so I’ll be escalating this to our developers for further investigation.

Best regards,
Marcel

October 21, 2024 at 2:47 pm #16313096

Marcel
WPML Supporter since 02/2019

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

while our team works on this, I can share a temporary workaround. Please add this to your functions.php file:

add_filter('wpml_st_string_translation_before_save', 'sanitize_translation_before_save', 10, 1);

function sanitize_translation_before_save($translation_text) {
	$translation_text["value"] = str_replace("\n", "\r\n", $translation_text["value"]);
	return $translation_text;
}

You can find it as working on the provided Sandbox. The entries are in the installed "WP Mail Log" plugin. I will let you know here once this is fixed.

Best Regards,
Marcel