Skip Navigation

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

Problem:
The client needed a way to translate the attributes of a shortcode but not its content. They were using a custom XML to register the attribute for translation but couldn't find a way to exclude the content from being translated.
Solution:
We recommended using a custom XML configuration to ignore the content of the shortcode while translating its attributes. Here is the XML configuration to achieve this:

<wpml-config>
  <shortcodes>
    <shortcode>
      <tag ignore-content="1">my-code</tag>
      <attributes>
        <attribute>title</attribute>
      </attributes>
    </shortcode>
  </shortcodes>
</wpml-config>

We advised the client to apply this configuration and make minor changes to the primary language page to ensure the custom XML settings take effect.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If the problem persists, we highly recommend opening a new support ticket here.

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

This topic contains 3 replies, has 2 voices.

Last updated by Kor 2 months, 2 weeks ago.

Assisted by: Kor.

Author Posts
July 5, 2024 at 4:04 pm #15899395

WaterBottle

Background of the issue:
Hi there,

I am having a shortcode, where I want the attributes to be translated but not the content itself.

Example:

[my-code title="hello" ] CONTENT [/my-code]

I use custom xml to register the attribute title to be translated:

my-code

title

Symptoms:
I could not find a solution to tell WPML to skip the translation of the shortcode content (or better: copy the original content).

Questions:
Is there anyway like a hook to tell WPML to skip the translation of the content or copy the original content for a specific shortcode?

July 5, 2024 at 4:11 pm #15899443

Kor
Supporter

Languages: English (English )

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

Thanks for your patience.

Here is the ticket. There is a way to ignore the contents as explained here https://wpml.org/documentation/support/language-configuration-files/register-page-builder-content-for-translation/#translate-media

For example.

<wpml-config>
  <shortcodes>
    <shortcode>
      <tag ignore-content="1">my-code</tag>
      <attributes>
        <attribute>title</attribute>       
      </attributes>
    </shortcode>   
  </shortcodes>
</wpml-config>

Please try and let me know how it goes. Remember to make minor changes to the primary language page so that the custom XML configuration can be applied.

July 5, 2024 at 5:09 pm #15899683

WaterBottle

That's awesome, works like a charm! Thank you!

July 5, 2024 at 5:39 pm #15899782

Kor
Supporter

Languages: English (English )

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

Thanks for your reply.

You can try adding glossaries as explained here https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/how-to-create-and-manage-glossary-entries/ . Could you check and see if it's what you're looking for?

WaterBottle confirmed that the issue was resolved on 2024-07-05 18:14:13.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.