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 6.88 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Kor 1 year, 10 months ago.

Assisted by: Kor.

Author Posts
July 7, 2022 at 10:05 am #11621365

cristinaC-5

I am trying to translate image excerpts with Media Translation, but it seems it doesn't support newlines.
I have tried with '', '\n' and the simple enter but after i save the translation it removes them (except for the '\n' which is stored as text).

Is there a way, even by code with an action or a filter, to keep newlines?

Best Regards

screen.png
July 8, 2022 at 6:03 am #11628111

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for contacting WPML support.

I've checked your screenshot and I think I know what you're trying to do there. These media fields are actually being sanitized.

To prevent this, you can use this workaround:-

IMPORTANT : Please make sure you've backed up.

Edit the file \wpml-media-translation\classes\media-translation\class-wpml-media-save-translation.php line 53 to line 61 and replace

if ( isset( $_POST['translation']['title'] ) ) {
				$post_array['post_title'] = sanitize_text_field( $_POST['translation']['title'] );
			}
			if ( isset( $_POST['translation']['caption'] ) ) {
				$post_array['post_excerpt'] = sanitize_text_field( $_POST['translation']['caption'] );
			}
			if ( isset( $_POST['translation']['description'] ) ) {
				$post_array['post_content'] = sanitize_text_field( $_POST['translation']['description'] );
			}

with

if ( isset( $_POST['translation']['title'] ) ) {
				$post_array['post_title'] = ( $_POST['translation']['title'] );
			}
			if ( isset( $_POST['translation']['caption'] ) ) {
				$post_array['post_excerpt'] = ( $_POST['translation']['caption'] );
			}
			if ( isset( $_POST['translation']['description'] ) ) {
				$post_array['post_content'] = ( $_POST['translation']['description'] );
			}

Then, please try again and see if it works for you.

Thanks!

Kor

The topic ‘[Closed] Media Translation not supporting new lines’ is closed to new replies.