This thread is resolved. Here is a description of the problem and solution.
Problem:
How to force square brackets not to be considered as a shortcode part?
Solution:
Replace "[The Hotel]" with
<span class="square_braces">The hotel</span>
Add this CSS to theme:
.square_braces::before { content: "["; } .square_braces::after { content: "]"; } html[lang="en-US"] .square_braces::after, html[lang="en-US"] .square_braces::before { display: none; }
In the above CSS replace “en-US” with the language code in which you don’t want to display the brackets.
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 14 replies, has 2 voices.
Last updated by Eric Moss 2 years, 7 months ago.
Assisted by: Christopher Amirian.
Author | Posts |
---|---|
May 27, 2022 at 4:07 pm #11328637 | |
Eric Moss |
Hello hidden link In the above blog article, you can see the text "[names]" and "[The hotel]". Neither are shortcodes but WPML thinks they are, which means that they are being picked up as "wpcodeself" in the ATE. I can't skip using these "shortcodes" in the string without getting a formatting error, and translating them as "shortcode attrs" is not ideal because the translated text does not need the square brackets like the english translation does, and the words keep their spaces. Eg, this sentence in English: Comes out as this in French: But it should be this: Is there a way to let WPML know that these are not shortcodes? I tried escaping the shortcodes as WordPress suggests by using double square brackets [[like this]], and I also tried using HTML entities [like this] Neither solutions worked. Any help would be appreciated. Thanks |
May 30, 2022 at 6:08 am #11339301 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, Would you please make sure that on your original post escape the brackets? Use the Unicode equivalent: [ with [ Then save the page and go to the translation and this time you should see the result as a normal text. Thanks. |
May 30, 2022 at 12:52 pm #11343927 | |
Eric Moss |
Hi Christopher That worked for one of the instances of the brackets, but not the other. The HTML entities are showing properly in the block editor (see screenshot) but WPML still seems to read it as a shortcode. |
May 30, 2022 at 1:05 pm #11344133 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, Would you please do a test here? hidden link I created a clean installation and set up WPML. I want to know if it is possible to replicate the issue that you say there or not. Thank you. |
May 30, 2022 at 2:04 pm #11344791 | |
Eric Moss |
Hi Christopher Yes I've recreated the issue on the sandbox site English: hidden link If you use the ATE, you'll see that the first instance of the brackets is read as wpcodeself , and the second instance is read as translatable text. Additionally, viewing the original post on the frontend shows the HTML entities. If I insert the HTML entities using the "Edit as HTML" option in the block editor, they are converted to brackets and WPML will read them as shortcodes. So either way, we're back to square one. Thanks for your help so far. Let me know how I can proceed. |
May 31, 2022 at 9:19 am #11351271 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, Thank you. I reported this to the second-tier support and waiting for their reply. Going to update you as soon as I have news. Thanks. |
May 31, 2022 at 1:03 pm #11353371 | |
Eric Moss |
Thank you! |
May 31, 2022 at 1:16 pm #11353669 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, I have an answer from the second tier. Would you please use the top left search box in the Advanced Translation Editor and search for the text of the shortcode there? You will find it and you can translate that. For more information: Thank you. |
May 31, 2022 at 1:17 pm #11353675 | |
Eric Moss |
Hi Christopher Yes, I addressed that in my original post. This solution does not make sense for all languages. |
May 31, 2022 at 1:50 pm #11353987 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, I am not sure what you mean it does not make sense for other languages. That is the way it is possible to translate the Shortcodes in ATE. The reason behind that is to avoid the Automatic Translation to translate unrelated content as explained in the documentation that I shared. Thanks. |
May 31, 2022 at 1:54 pm #11354003 | |
Eric Moss |
The problem is that the original text is not a shortcode, it's just text within square brackets, used in this way: hidden link As I described originally, the issue comes because the text does not need to be in square brackets in the French translation. And translating the shortcode text as individual words puts spaces between those words where there does not need to be. Eg, this sentence in English: Comes out as this in French (notice the space between L' and hôtel as well as the square brackets): But it should be this: |
May 31, 2022 at 2:03 pm #11354037 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, I see. It seems that I misunderstood the issue. I now see what you want, I updated the issue with the second-tier and will get back to you to see if there is a solution for that or not. Thanks. |
May 31, 2022 at 2:04 pm #11354041 | |
Eric Moss |
Thank you |
June 1, 2022 at 8:32 am #11360019 | |
Christopher Amirian Supporter
Languages: English (English ) Timezone: Asia/Yerevan (GMT+04:00) |
Hi there, I have an answer from the second-tier:
Here is a workaround that is suggested but besides this, there is no method available in WPML: Replace [] with <span class="square_braces">The hotel</span> Add this CSS to theme: .square_braces::before { content: "["; } .square_braces::after { content: "]"; } html[lang="en-US"] .square_braces::after, html[lang="en-US"] .square_braces::before { display: none; } In the above CSS replace “en-US” with the language code in which they don’t want to display the brackets. Thanks |
June 6, 2022 at 4:37 pm #11397963 | |
Eric Moss |
Thank you. Not the answer I was looking for, but this should work! |