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.
Author | Posts |
---|---|
September 16, 2023 at 7:22 am #14406047 | |
bart |
I am trying to: i had a post a few years ago, but the problem is still there 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, |
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. |
September 19, 2023 at 10:29 am #14418667 | |
bart |
thanks for the sandbox. what i did? when i added the second paragraf, the troubles started. see attached screenshots |
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. I guess this will be fixed in WPML 4.7, right? |
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, I really appreciate you staying on this issue to find a solution. Thanks again. |