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.

Our next available supporter will start replying to tickets in about 8.38 hours from now. Thank you for your understanding.

Tagged: 

Assisted by: Nigel.

Author Posts
September 16, 2023 at 7:22 am #14406047

bart

I am trying to:
keep the text-format with breaks in the translated language. the original language has some breaks in it, if i copy this original into the wpml editor and check it online, the breaks are gone. so, i have to add them into gutenberg.
in case of any content-correction and saving wpml editor, the breaks are gone again.

i had a post a few years ago, but the problem is still there
https://wpml.org/forums/topic/translating-gutenberg-paragraph-breaks-are-lost-in-translation/

after some many years, it would be great to have a solution.

September 18, 2023 at 2:04 pm #14412989

Nigel
Supporter

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

Hi there

Could you clarify how you are currently editing the post (classic editor? block editor?), and how you are translating it (classic WPML editor? ATE?).

I want to test what you describe on my own site, but I'm not sure what to test.

September 18, 2023 at 5:19 pm #14414479

bart

Hi Nigel,
Thanks for your attention.
I am using the wpml editor, in picture 1 you can see the 2 languages.
In picture 2 you can see that the breaks are gone.
This is a problem that has been bothering me for several years, I am curious if anyone else has this problem.
if you want, i can give you access to my site.
best,
bart

02-tranlated-language.png
01-wpml-editor.png
September 19, 2023 at 10:11 am #14418589

Nigel
Supporter

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

I just checked this on my own site and it works fine, so I created a sandbox site to double-check and to share with you.

You can see in the screenshots how I've copied across the content in the translation editor, and how it correctly displays on the front end.

You can test the same on the sandbox site, logging in with this link: hidden link

Unless you spot something different from what you are doing, I would suggest on your site testing in a minimal install, with all plugins except for WPML and String Translation disabled, using a default WP theme.

Screenshot 2023-09-19 at 11.06.42.png
Screenshot 2023-09-19 at 11.07.18.png
September 19, 2023 at 10:29 am #14418667

bart

thanks for the sandbox.
i have added a post and could reproduce the error.

what i did?
at first add post with title + 1 paragraf.
when translating, it works fine at the first look.

when i added the second paragraf, the troubles started. see attached screenshots
hope you can reproduce and see the problem too.

Edit-Post-“check-soft-break-DE”-‹-Sandbox-—-WordPress.png
Translations-‹-Sandbox-—-WordPress.png
September 19, 2023 at 2:38 pm #14420463

Nigel
Supporter

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

OK, I was able to reproduce it, the key seems to be modifying the text once it has been copied in the translation editor.

I did an additional test and notice that the problem doesn't occur if you use the Advanced Translation Editor.

I'm raising this with my second-tier colleagues to see what they suggest, and I'll get back to you when I have some news.

September 20, 2023 at 9:58 am #14428603

Nigel
Supporter

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

It turns out the developers have recently been working on this very issue and have proposed a fix, but that isn't scheduled for release until the WPML 4.7 update, and I'm not sure when that will be published (we have version 4.6.7 due very soon, which this fix was too late for).

My colleague did suggest a workaround, which you may want to try if you don't want to wait for the official release.

That is to edit the file wp-content/plugins/wpml-string-translation/classes/class-wpml-st-string.php and immediately after this line (line 243 of the current version)

			if ( ! empty( $translation_data ) ) {

insert these lines:

                if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "wpml_save_job_ajax" && preg_match('/[\n\r]/', $translation_data["value"])) {
                    $translation_data["value"] = wpautop($translation_data["value"]);
                }
September 20, 2023 at 10:39 am #14429251

bart

I am already very grateful that this problem can be reproduced and a fix is on the way.

There is still 1 problem.
It wraps the content in a p-tag, even though there are already p-tags.
So the element gets a warning:
"This block contains unexpected or invalid content".

I guess this will be fixed in WPML 4.7, right?

Beitrag-bearbeiten-„test“-‹-URBANPRESENTS-—-WordPress.png
September 21, 2023 at 3:31 pm #14440855

Nigel
Supporter

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

I need to look into this a little more, evidently.

When I tried the fix on the staging site it isn't working (though the fix that is included in WPML itself is not necessarily the same as the workaround offered by my colleague).

I'm off tomorrow, so it will likely be Monday before I have a reply for you, but I'll be in touch then.

September 25, 2023 at 4:08 pm #14460487

Nigel
Supporter

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

Just to let you know I'm in discussions with my colleague about this, we've been getting mixed results with the workaround.

I'll update you when I have something concrete to share.

September 26, 2023 at 7:12 am #14463345

Nigel
Supporter

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

On the sandbox test site my colleague updated the workaround. He removed that which was added previously described above, and added this to the theme's functions.php instead:

add_action('wpml_st_string_translation_before_save', function($translation_data){
	if (! empty( $translation_data ) && isset($_REQUEST["action"]) && $_REQUEST["action"] == "wpml_save_job_ajax" && preg_match('/[\n\r]/', $translation_data["value"])) {
		$translation_data["value"] = wpautop($translation_data["value"]);
	}

	return $translation_data;
});

What I then noticed while testing it is that it worked well if in the translation editor you are using the Text tab of the text editors, but it produced the double-paragraph problem if you used the Visual tab of the text editors, so I recommend using the Text tab.

To re-iterate, this just relates to a workaround for the problem. The actual solution which will be incorporated in WPML 4.7 is a different solution.

September 29, 2023 at 7:03 am #14485837

bart

Hi Nigel,
Thanks for the workaround!
It is not perfect, but i can work better with it.
Looking forward to the WPML 4.7 version.

I really appreciate you staying on this issue to find a solution. Thanks again.

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