Skip Navigation

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

Problem:

Shortcodes added to links are not showing for translation.

Solution:

The user marked the ticket as resolved but did not mention what resolved it.

You can read my last reply to understand better about translating shortcodes with the Advanced Translation Editor.

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

Last updated by Itamar 1 year, 2 months ago.

Assisted by: Itamar.

Author Posts
September 24, 2023 at 4:18 pm #14453213

zenC

Hello there,

i am using elementor and wpml.
On one of my forms i would like to redirect to a dynamic URL:
hidden link id="amount"]
and on the translated page i want to redirect to:
hidden link id="amount"]?utm_source=DE

This is possible by updating the link using string translation.
The problem is, that when i update the page using ATE the string appears there as:
hidden link
and once i complete the translation in ATE it removes my parameter and the translated link in String Translation looks like this:
hidden link id="amount"]

So everytime i update the page of that form, my parameter gets removed.
I'm guessing it has something to do with those dynamic fields and ATE, since it also cannot display them.

September 26, 2023 at 8:47 am #14464561

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

We need to replicate this issue on a fresh WordPress installation. Then, I'll be able to escalate it to our compatibility team. For this, I created a test website with a clean WordPress install. You can access it through this link:

hidden link

With this link, you'll be directly logged in.

Could you please install the Elementor plugin and see if the issue is replicable on a clean WordPress installation?

Please configure WPML and Elementor as on your site (just the basic configurations needed to replicate the issue are enough). Please also ensure you install the latest version of the plugin. Please let us know when everything is finished, and you can replicate the problem.

Thanks,
Itamar.

September 27, 2023 at 8:40 am #14471563

zenC

Hi Itamar,
thank you for your reply.

I recreated that issue on your test website. The [field id="amount"] is not displayed in the ATE.
I also found out, that the problem is the space between "field" and "id".
I was also able to create a workaround by replacing the space with an underscore. The functionality still works, but then it is displayed in the ATE.
But since elementor is displaying to use the shortcode with a space, it would probably be good if the issue still would be fixed.

September 28, 2023 at 3:47 pm #14483361

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi, and thanks for replicating this issue on the sandbox site.

Some characters are not allowed or considered unsafe in URLs. Square brackets [] are allowed but not so common. However, quotes "x" are not allowed. Please see the following sources as a reference.

hidden link
hidden link

I can see that the ATE is removing even the square brackets. I'm consulting our ATE experts about this and will update you with their reply.

Meanwhile, I have found that if you convert the special characters to Unicode, then ATE accepts them. I used this convertor to convert your URL.

hidden link

It gave me this result.

hidden link

And then I could translate it like this in ATE.

hidden link

Please see the attached screenshot. You can also check the test site.

Please let me know if this workaround is good for you.

2023-09-28_18-37-00.jpg
September 28, 2023 at 3:53 pm #14483445

zenC

Hello Itamar,

thank you for your answer.
I did not have any problem with square brackets, nor with quotes. The only problematic character was the space. As i replaced the space with an underscore everything worked out.
So hidden link"amount"] works. No need for unicode.

September 28, 2023 at 4:27 pm #14483731

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I'm confused and maybe I misunderstood something.

Is [field id="amount"] a shortcode you add to this URL's end hidden link?

If so, how does this work?

Do you have it working without WPML, meaning does the shortcode convert to what it needs to be when you insert it in a dynamic Elementor field?

September 29, 2023 at 1:21 pm #14487825

zenC

Hi there,

you should try out the elementor pro forms.
You can use the shortcodes of the form fields in the „after submit“ actions. This allows things like using a submitted name in an confirmation email. When the form is submitted elementor replaces the shortcode with the field value.

In my case i use it to adjust the path of the redirect URL depending on a form field.

This works out fine. The only problem was that this shortcode wasn‘t displayed in the ATE, but i figured out that the space inside the shortcode was the problem. So i replaced it with an underscore.
This was important because i wanted to add a URL parameter behind the dynamic path, in order to tell the website im redirecting to from which language the visitor comes.

October 1, 2023 at 2:20 pm #14493275

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

Shortcodes are hidden in WPML's Advanced Translation Editor. There is a reason for this, as only the shortcode attributes should be translated. You should find the shortcodes and translate them using the search field if you need to. We explain this in the following guide.

https://wpml.org/faq/how-to-translate-urls-shortcodes-and-html-attributes-using-the-advanced-translation-editor/#how-can-i-translate-shortcodes-and-custom-html-attributes-with-the-advanced-translation-editor

As mentioned in the guide, you can register the shortcodes and attributes for translation in a wpml-config.xml file. You can learn how to do this in the following guide.

https://wpml.org/documentation/support/language-configuration-files/#page-builder-content

If you register them correctly, then you will be able to translate the attribute. In your example, you would need to translate "amount" into "amount". On the test site, I registered the shortcode you gave as an example like this.

<wpml-config>
  <shortcodes>
    <shortcode>
      <tag>field</tag>
      <attributes>
        <attribute>id</attribute>
      </attributes>
    </shortcode>
  </shortcodes>
</wpml-config>

Nevertheless, because I still don't fully understand how this works with a URL, I'm not sure that it will work for you by concatenating a parameter after the translation of the attribute.

To the best of my knowledge, please note that by adding an underscore (_) instead of space to the shortcode like this [field_id="amount"], you are, in practice, removing the shortcode name and leaving it only with an attribute. Please see WordPress's codex about shortcodes.

https://codex.wordpress.org/Shortcode_API

This is why WPML's Advanced Translation Editor does not consider this a shortcode, and you get it for translation. However, if this is a good workaround, please keep using it.

Regards,
Itamar.