Skip Navigation

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

Problem:
You need to translate scripts within a post, such as iframes or shortcodes, for different languages. However, when using the Advanced Translation Editor (ATE), you encounter issues where the original language script appears blank and modifications in the new language do not save correctly. After editing and saving the post, scripts revert back to the original language.
Solution:
We recommend not using the ATE for pages that contain scripts you need to translate. Instead, use a different method to manage translations for these specific pages to avoid the issues you're experiencing. For detailed guidance on how to implement this, please refer to our documentation on using different translation editors for different pages: Using Different Translation Editors for Different Pages.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.

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.

This topic contains 36 replies, has 2 voices.

Last updated by Bruno Kos 4 months, 2 weeks ago.

Assisted by: Bruno Kos.

Author Posts
July 4, 2024 at 12:42 pm #15891933

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

What I meant is that, in my experience, we haven't had clients needing to translate thousands of scripts, so we lack extensive use cases for this.

I don't think making scripts translatable is feasible. It's not just about ATE; much of our content goes to external translators and agencies. If they don't understand the code, they might translate script texts, potentially breaking the websites. For example, today, a client translated IDs for sections linked to JavaScript, which caused functionality issues because the IDs no longer matched the code triggers.

The more complex the script, the higher the risk of errors.

Regarding the last point, if you think this solution might work for your use case, let me know. I can prepare a sandbox for testing to see how we can translate it without causing issues.

July 4, 2024 at 1:03 pm #15892130

justinK-16

Hi Bruno

If you meant this as my last point:
But regarding shortcodes:

I created a shortcode of the script in both EN and IT (2 SC's).

Added the EN shortcode in place of the HTML widget

Translate the shortcode String

However, it too reverts to the original shortcode upon saving in the ATE. ALso changes the string shortcode back to the EN version...

Is there something that may solve this and possibly achieve the end result?

Then yes please, prepare a sandbox let's see if we can find a way to translate these shortcodes! 🙂
Hopefully, this is what you meant!

July 4, 2024 at 2:11 pm #15892699

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

That's what I meant, yes. Can you try here:
hidden link

You can do here whatever you want, install plugins, theme, etc.

July 4, 2024 at 3:23 pm #15893064

justinK-16

Hi Bruno

I have set up a sample display with both the original situation and the new option to be tested or worked on hopefully someone can supply a solution to this.
I did not translate though - explained why on the page.

I have supplied some basic info and images etc to explain the situation to whomever may look at it.

Let me know if you need more of anything - but it should be pretty clear on the page.

Thank you

July 5, 2024 at 5:18 am #15895915

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

I translated the shortcode parameter and even after editing original and resaving the translation remained in ATE (as it should).

Also note this is a new version of ATE, that is why a difference in layout.

And on hidden link I see that within "Possible Option" it shows German texts in listings.

Clipboard_07-05-2024_01.jpg
remained after the change.jpg
after editing original.jpg
July 5, 2024 at 5:56 am #15896138

justinK-16

Hi Bruno

Thats fantastic - it appears to work and will hopefully do the trick!

2 questions:

1. How can you get the Shortcodes to automatically appear in the ATE (without having to remember the shortcode name and search for it)?

2. Can you assist with the issue of the field populating the URL in the script field of the ATE - it is overwriting /wanting to add the URL to all HTML element fields.

I know it is kind of a 2nd issue (also arose from trying to solve this one) but you have some familiarity with the issue so far and would save a whole lot of confusion trying to explain to the next supporter.

Let me know if you can help.

Thank again 🙂

July 5, 2024 at 7:19 am #15896660

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

If you do this (according to https://wpml.org/documentation/support/language-configuration-files/translate-custom-shortcodes-with-wpml/#making-shortcodes-translatable):

<wpml-config>
  <shortcodes>
    <shortcode>
      <tag>sc</tag>
      <attributes>
        <attribute>name</attribute>
      </attributes>
    </shortcode>
  </shortcodes>
</wpml-config>

you will get the name attribute appearing in ATE without requirement to search for it.

As for the 2nd thing, it is how translation memory works and this can't be disabled:
https://wpml.org/documentation/translating-your-contents/how-wpml-keeps-track-of-your-translations/

Specifically: "When we use one of the same segments on another page, the saved translation is automatically applied when we go to translate it."

ss.jpg
July 5, 2024 at 11:22 am #15898209

justinK-16

Thanks Bruno

Translations all work perfectly and XML registration also now allows the shortcodes to appear in the main ATE without having to search.

Just on the Translation Memory part - This means that I cannot ever use the Elementor HTML widget (or maybe even the Text Widget) with any code that begins with <script> (irrespective of any differences within the code).

They will always populate that URL in the secondary language field.

Is there anything that I could add in front of existing scripts that will throw off Translation Memory but not affect or appear on the translated page if I leave the translation field empty?

For example any invisible code or masking to solve this.

Also is there a way to NOT display those HTML Script fields anymore so nobody will accidentally add anything to those fields?

July 5, 2024 at 12:50 pm #15898620

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

You can use such scripts but if you translate the URL for this it will be populated because translation memory will match it. There is no way around this.

Also fields that appear in translation editor must be filled in, they can't be left empty otherwise the translation will not get saved 100%.

July 5, 2024 at 2:09 pm #15898915

justinK-16

Well if that is not possible then how can we hide the html / script Field?

And do you have any experience or ideas as to what to add in front of <script> that will not show even on the primary language post?

July 8, 2024 at 7:25 am #15910501

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Can you show such example here as well?
hidden link

July 8, 2024 at 1:50 pm #15913638

justinK-16

On the page in the sandbox (at the bottom) are the examples of what is appearing in my ATE.

I don't know how to make them appear or remove them.

So, sorry I don't know how to add them to the sandbox example, as when I check the sandbox the fields do not appear???

I guess from the images in the sandbox you can see what I am referring to.

July 9, 2024 at 12:05 pm #15920615

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Can you share credentials for hidden link and tell me on which page does it occur? I can't seem to access the site using provided credentials no longer.

July 10, 2024 at 10:25 am #15927576

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Can you please try the following:

1. Add the following code to your WPML configuration file to prevent any HTML widget content from being sent for translation:

   <wpml-config>
      <elementor-widgets>
        <widget name="html">
          <fields>
            <field>none</field>
          </fields>
        </widget>
      </elementor-widgets>
    </wpml-config>

2. Regenerate the translation jobs on your site to ensure the changes take effect (so just resave the hidden link after making a minor change there (like adding "test" to the title).

Does it help?

July 10, 2024 at 2:44 pm #15928742

justinK-16

Hi Bruno

Thank you for the code - however I haven't tried it just yet.

I was translating posts all day yesterday with no issues.

I created a new post today and when I went to translate it - a 2700 word (approx) post used 11,000+ credits...

Upon scrolling through it appears the post now shows twice. Once as per normal (text editor fields), then directly below that now appears wpml_string_wrapper_content fields.

Is there something you may have done yesterday/this morning while looking for the solution above?

this is the post in the ATE:
hidden link

About halfway down the page, you will see the repeated fields as per the image.

repeat.jpg