Skip Navigation

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

Problem:
Link does not translate correctly if there are square brackets like a short code but in fact, it is not a short code.

Solution:
https://wpml.org/forums/topic/using-square-brackets-without-declaring-it-as-a-shortcode/

Relevant Documentation:

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 roliM 1 year, 6 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
July 12, 2023 at 9:19 am #14021197

roliM

On this page...

hidden link

There is a link on "www.gartner.com" (almost at he bottom) which leads to "hidden link"

We have translated the page:

hidden link

... but for some reason the link on "www.gartner.com" is incorrect. It just leads to it's own page/

I could be wrong but I had the feeling it had to do with the square brackets run the "[back]" link that was immediately after "www.gartner.com". I added the unclickable "." in an effort to fix the issue but it did not solve it. I had noticed issues with square brackets before, hence my feeling.

Strangely enough, when searching for "www.gartner.com" on the WPML translation page. An empty "url" field shows (see screenshot). We have tried populating it but it returns to being empty after saving.

Screenshot 2023-07-12 at 11.18.15.png
July 12, 2023 at 9:58 am #14021937

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

First of all, I see that the "WP Memory Limit" is set to 40M. WPML requires a memory limit of at least 128MB while 256MB is recommended. See https://wpml.org/home/minimum-requirements/ for detailed information. You can set WP Memory Limit in your wp-config.php file by adding following code:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Remember to add these lines before the line where it says:
/* That's all, stop editing! Happy publishing. */

IMPORTANT: Take full backup of your website and database before proceeding further.

Then please update WPML plugins to the latest versions. And any other plugin/theme if needed.

Then edit the page in default language, make a little change like a word, save and then update the translation. I hope this 'll fix the problem.

If not, try the troubleshooting commands mentioned in this guide https://wpml.org/documentation/support/wpml-troubleshooting-options/. Try in the mentioned order and wait for each to complete before trying the next one. You can find these in WPML → Support and click the Troubleshooting link.

Please let me know if it helps fixing the problem or I'll try my best to further assist you on the matter.

Regards.

July 12, 2023 at 11:51 am #14023467

roliM

Hi Waqas,

Thanks for your fast rely. I did what you suggested (some of it I treid again because I allready tried it before asking this question). Sadly it did not solve the iussue. The link on the Dutch version of the post is still wrong. Also the "url" field on the WPML page is still emptied when the translation is 100% and saved.

Still not sure if it's relevant but I'm also having issues with the anchor links "[back]" on the page. While trying to fix the issue I rand into an issue with the following paragraph, just below the paragraph we are referring to for this ticket's issue.

"2 In 2019 was Spacewell het enige bedrijf dat als ‘Leader’ wordt geclassificeerd in de Verdantix Green Quadrant rapporten voor zowel Geïntegreerde managementsystemen voor werkplekken als IoT-platformen voor slimme gebouwen. [terug][back]"

I added [terug] manually

I was not able to set this field as "completed" in WPML so now the Dutch translation is at 96% complete but can not be completed. I might be wrong but I think it is because of the square brackets arround the "[Back]" link.

July 12, 2023 at 1:42 pm #14024791

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

May I ask for admin access to your website to check the issue in detail? You can create a separate admin user for this purpose, which can be deleted afterwards.

Also provide detailed steps to reproduce the issue and links to pages in admin and on frontend.

Remember to take full backup of your website and database before proceeding. However, a staging/test site is highly recommended, because I may need to try some changes/fixes on the site, which may cause conflicts with the live site otherwise. Please confirm it in your next reply or let me know if you do not agree with the mentioned.

I've set your next reply as private to share this information safely.

IMPORTANT: If you don't see the section for providing access information, do not write in the message box or the information may appear as public.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

July 13, 2023 at 6:07 am #14029037

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the access, I am working on it and 'll get back to you as soon as I've some progress.

July 13, 2023 at 1:19 pm #14033469

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and my apologies for the delay. But I am still working on this and 'll get back to you as soon as possible.

July 14, 2023 at 6:07 am #14037191

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience on this. I was able to fix the issue after trying some different approaches.

Using square brackets makes WP to consider it a short code and tries to render it, as you know. With WPML this also leads to a problem and in fact, its not a WPML problem.

To deal with it, usually you can use double square brackets and WordPress leave it as-it-is and shows 1 set of square brackets. But this also didn't work here and the "back" was shown in double brackets (see attached). Although the problem with URLs was resolved.

Another alternate would be the corresponding Unicode HTML Entities, but block editor renders these back to actual character, thus leading to the same problem.

To deal with this, one of our supporter used a solution (https://wpml.org/forums/topic/using-square-brackets-without-declaring-it-as-a-shortcode/) and I've followed the same and it worked just fine. I did followings:

- Removed square brackets from the word "back".
- Switched to code editor and added class="square_brackets" to the A tag for word "back".
- Saved and updated the translation. The word "back" was part of the content and I translated it as "terug". Completed and saved the translation.
- At this point, the URLs were shown as separate fields in ATE, thus giving the opportunity to fix or change accordingly. But these were just fine as you had defined in the content.
- Then I went to Appearance -> Customize -> Additional CSS and added following CSS at end of the existing one:

/* Square Brackets */
a.square_brackets::before {
    content: "[";
}

a.square_brackets::after {
    content: "]";
}

- This adds square brackets to where the "square_brackets" class is applied on an A tag. In this case, to the word "back".

All screenshots are attached to explain the above mentioned.

For the thing that you weren't able to complete the translation, please note that if the default language content contains HTML tags like superscript, subscript, A or etc, this is shown for translation as HTML Markers. And the same HTML markers need to be applied in the translated content to complete the translation (https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/#html-markers).

The content which isn't shown in the ATE by default but you can search within ATE, does not count towards the completion of the translation. That's the additional content, so if you leave that untranslated, you can still complete the translation by completing all the visible ones by default.

I hope this explains all about it. Please check and confirm.

Screenshot 2023-07-14 105101.jpg
Screenshot 2023-07-14 105050.jpg
Screenshot 2023-07-14 105035.jpg
Screenshot 2023-07-14 105000.jpg
double brackets.jpg
July 14, 2023 at 6:40 am #14037543

roliM

Wow, that's a lot, just because of square brackets 😉

The CSS fix seems a bit overkill just to be able to use square brackets in text. At this point it seems easyer just to avoid square brackets.

Thanks!