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

Last updated by niklasP-6 2 months ago.

Assigned support staff: Lauren.

Author Posts
July 30, 2019 at 2:46 pm

niklasP-6

I am trying to: Im trying to create a shortcode that will print out a text based on a shortcode attribute. My problem is that when i add a attribute to the shortcode it will not display in translated language. If i remove the attribute it shows up. Also if i add a text next to the shortcode in the editor the shortcode also stops working in translated version. Im adding my shortcode and content to a ACF field WYSIWYG-field.

Link to a page where the issue can be seen:
hidden link <- Original version
hidden link <- Translated version.

Original version prints out:
"732" and "asdasd".
Translated version only prints out
"asdasd" <- that one does not have a attribute.

I expected to see: Shortcodes to work with attributes or other text next to the shortcode in the html editor.

Instead, I got: Shortcode is not printing out anything in translated page.

July 30, 2019 at 7:19 pm
July 31, 2019 at 12:40 pm #4314415

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I have escalated this to our 2nd Tier Support team. I will be working with the developers to find a resolution and will keep you updated here. Thanks for your patience while we continue to troubleshoot.

July 31, 2019 at 4:53 pm #4316887

niklasP-6

Great! I just wanted to say that I also tried to change to advanced editor but the resault was the same both with the shortcodes and the UL LI lists.

Thanks

July 31, 2019 at 7:42 pm #4317439

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for the update, I'll pass the information on to the developers.

July 31, 2019 at 8:45 pm #4317657

niklasP-6

Problem also accurs when i go into the Translated version in the "Wordpress page editor". If I add the shortcode with attributes to a field in the ACF Block it will not save that content. When i reload the page its empty. If i remove the attribute everything saves. In the original languange everything works fine.

August 1, 2019 at 7:31 am #4319271

niklasP-6

Hi Lauren,
Would you be able to ask the developers in what file this parsing of the shortcode is made?

August 1, 2019 at 12:07 pm #4321371

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thank you, I'll add these notes and ask for the information regarding the parsing. I'll update here as soon as I hear back.

August 5, 2019 at 10:34 am #4339837

niklasP-6

Hi Lauren,
Do you have any news on this subject? Did they tell you anything about what file it could be? Im in a bit of a hurry with this project.

August 5, 2019 at 7:39 pm #4342845

niklasP-6

Seems like the error is from this character (")... if its in the text it will not save. So maybe its escaping the special characters that is missing.

August 5, 2019 at 7:59 pm #4342941

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

So far, our developers have identified that there are two problems:-

1. The shortcode strings can not be translated like regular shortcode. This is not possible because this is part of a block attribute, not the regular content.
2. Even if shortcode strings are not translatable, the the whole shortcode is visible in the translation editor as a string but it is not copied to translated page when saved in Translation Editor.

I don't have a solution as of yet, but as soon as I have more information I will update here.

August 5, 2019 at 8:37 pm #4343031

niklasP-6

I did some searching in the database and found the rows where the data is stored. I compared both versions. This is what i found.

Shortcode problem

Working version: In this version they use (\) to escape the (") character. You can se that around 732.
"column1_group_column_0_text": "<p>[common_content commonid=\"732\"][\/common_content]<\/p>",

Not working version: In this version its missing the escape character (\)
"column1_group_column_0_text":"<p>[common_content commonid="732"][/common_content]s</p>"

UL LI LIST problem
Working version. In this version they save the \r\n\t in the database. This is invisible formating characters. They should not be visible when they are rendered later to web. (this shows the problems are related to the escape character (\))

"column1_group_column_0_text": "<_ul>\r\n\t<_li>UL LI LIST HERE<\/_li>\r\n\t<_li>It adds strange characters in translated version<\/_li>\r\n\t<_li>Yes i.<\/_li>\r\n<\/_ul>",

The not working version: Here you can see that the escape characters are gone... this will then be rendered as text.

"column1_group_column_0_text":"<_ul>rnt<_li>UL LI LIST HERE</_li>rnt<_li>It adds strange characters in translated versions</_li>rn</_ul>"

Note.. I had to add _ before UL LI in my examples above... This program was showing ul li formating otherwise.

August 6, 2019 at 3:15 pm #4349077

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for the additional information, I have passed this on to our developers. For this ticket, we are only dealing specifically with the shortcode issue. I have asked Radu to update you regarding the UL issue that you have a ticket with him for, so you should hear back soon on that issue.

August 7, 2019 at 1:23 pm #4355349

niklasP-6

Hi Lauren, have some updates.
Its all about the character ("). When i change that character to a (') then the shortcode works in an other language.

This problem also happens on normal links if they are written with (") as they are by the editor. ex. <a href="">link</a> the (") at the href breaks the translated page.

August 7, 2019 at 1:31 pm #4355395

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Yes, I literally JUST tested that on the Sandbox site, and reported back to the developers. They are working on the issue now, and I hope to have an update soon for you.