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: Exception
This topic contains 16 replies, has 3 voices.
Last updated by Nigel 1 year, 3 months ago.
Assisted by: Nigel.
Author | Posts |
---|---|
July 26, 2023 at 12:35 pm #14103825 | |
erezS-3 |
Hi, Many times on this page and on many other pages across my website, I have internal links to urls that look like this "machiningdoctor.com/mds/?matId=xxxx" (xxx is a number that varies). I am looking to automate (Or semi-automate) it because I am starting with the translation of the site and there will be many similar cases. Thanks! |
July 26, 2023 at 2:48 pm #14105123 | |
Ahmed Mohammed Supporter Timezone: Africa/Cairo (GMT+02:00) |
Hi Erez, Thank you for contacting WPML support. While you are waiting for one of my colleagues to take this ticket and work on it, let me provide you with the first debugging steps or if I can help with the issue quickly. WPML can automatically update internal links to point to the translated content. Go to WPML > Settings > Translate Link Targets and run the scan. (See the screenshot.) When there is new content with links that need updating, you should see a small info box at the top of the WPML > Settings page. With that said, I'm not sure about the URL structure (mds?matid) and whether it would work as expected. Please give that a try and let us know how it goes. |
July 27, 2023 at 10:50 am #14109779 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Hi Erez How are you getting on? Did scanning the link targets fix the problem? I ran a quick check on my local test site to confirm that internal links are still handled correctly during translation if they contain added URL parameters, and they were, but if you are still facing problems let me know. |
July 27, 2023 at 12:38 pm #14110759 | |
erezS-3 |
The scanning did nothing. I am looking for a solution that each time WPML encounters the link machiningdoctor.com/mds/, On any existing and future pages, it will translate it to machiningdoctor.com/de/mds/ (Or machiningdoctor.com/es/mds/), depending on the language. This is what I did, that does not work: (See screenshots of each step) Thanks! |
July 27, 2023 at 2:32 pm #14111765 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Translating internal links is handled automatically, and you really shouldn't have to do anything at all for them to work. (External links are essentially just copied, so if you included a link to google.com and you wanted that to be to google.de on the German page you would need to translate the link manually.) Just to be clear about one thing: if your staging server had links with URLs from the production server, they would be considered external links. Now, take a look at the screenshot from my own test site, where I'm translating a post that includes a link to the sample-page that I also added a URL parameter to for testing. Ordinarily link URLs are hidden from the editor, because there is no need to translate them (internal links, at least) and if you don't then everything will be handled automatically when it comes to displaying the correct links on the front end. In my screenshot, as in yours, you can see the link url, but only because I used the search box to help locate it. But actually, I shouldn't translate it, and I should just make sure when translating the text if came from that the link is applied to the correct part of the text. (See the documentation here for more about these HTML markers in the ATE editor: https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/#html-markers.) When I mark the translation as complete—without translating the link URL—then everything works correctly on the front end. In this case the original front-end link to Sample Page (hidden link) is automatically updated to point to the translation of that page at hidden link on the translated post. So I would suggest you remove translations of the URLs that you have added so far and let WPML handle updating them automatically. |
July 27, 2023 at 5:33 pm #14112851 | |
erezS-3 |
Hi, All the links are internal and belong to the staging copy. What am I doing wrong? Thanks! |
July 28, 2023 at 6:48 am #14114777 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
>What am I doing wrong? I don't know! That test page you described, I visited it (and the original English version) and the first and third links should be automatically transformed to point to the corresponding translated pages. I can't see why that isn't happening without checking the process myself. Would it be possible to access the back end of the site and do some testing and debugging? Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site. |
July 28, 2023 at 9:31 am #14115873 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Thank you for that. I just translated the same test page to Spanish, and got the same result, and now I can see why. The pages that "already have a translation" being linked to have draft status, they are not published. When logged in as an administrator I can see the different language versions of the page about the machinability of cast iron you linked to, for example, but if I visit the same page logged out then I can only see the English original because the other language versions are not published. And WPML won't update links in translations to point to pages that are unpublished. When I went to WPML > Translations I see that content is translated but pending review, hence why they remain as drafts. When you link to pages that have actual published translations then those links should be handled automatically, as described before. (Note I'm not actually working today but didn't want to leave you without a reply. If you still have problems once you have reviewed and published translations, I'll get back to you with further help on Monday.) |
July 29, 2023 at 8:27 am #14120703 | |
erezS-3 |
Many thanks for helping out on your free day. You are much appreciated! I understood your explanation, and it seems logical. 1) I created a new post in English: hidden link Please help! Thanks, |
July 31, 2023 at 7:33 am #14124467 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
OK, I checked back on your site, and this is odd, it's not behaving how it should, now that we've identified the problem with translations being published or not. I'll keep looking into why. I will likely need to install some utility plugins to help with debugging; you said I could play around with this staging site copy. |
July 31, 2023 at 7:36 am #14124475 | |
erezS-3 |
Yes, You can do anything you like on this staging copy |
August 1, 2023 at 7:47 am #14131013 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Just to keep you up-to-date, I need to do some code tracing to track what happens when the translation is returned from the translation editor (which is when the link swapping should occur), and I can only do that locally, so I am taking a copy to work on. I'll update you later when I've gone through that. |
August 1, 2023 at 11:24 am #14133173 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
Further update: the locally-installed copy of your site works as expected, the links are automatically updated, so the problem seems to only occur on your server. So I am back to working on the staging site to search for the cause. Unfortunately it is harder to debug remotely, but I am persisting, and will get back to you. |
August 1, 2023 at 1:36 pm #14134759 | |
erezS-3 |
Thanks for keeping me updated, and waiting for positive news. |
August 2, 2023 at 3:33 pm #14143705 | |
Nigel Supporter Timezone: Europe/Madrid (GMT+01:00) |
I dug down into the minutae of the code on your staging server, only to discover that the problem was somewhat trivial. The settings for your site URLs are wrong, they use http protocol even though the site actually uses https protocol. That is something that will affect matching links for translation. I changed the settings on the staging site I've been working on and found it now works as expected. Can you please check your sites on other servers. You will likely want to go to WPML > Settings > Translate Link Targets and run the scan to fix links, which should work for existing links once you have updated the WordPress URLs correctly. |