Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 7 replies, has 2 voices.

Last updated by Dražen 1 year, 9 months ago.

Assisted by: Dražen.

Author Posts
October 9, 2023 at 5:57 am #14535857

michaelS-131

We had an issue some time ago and found a work around, now after an update, it's bitten us again. This has been an ongoing issue for almost 2 years now.

I'm trying to get the URL in a specific language given any site URL. Ie; URL in language A returns URL in language B. I've had some success using the wpml_permalink filter, but it doesn't work for all URLs.
I've tried tracing through the code to see how sitepress-multilingual-cms determines the URLs for each language in the language switcher, but it's convoluted and there doesn't seem to be something as simple as a function call to get the URL for a given language.
Why isn't the wpml_permalink filter working for all URLs? And is there a function I can call passing a URL and target language to get back the correct URL?

I've deactivated all but essential plugins and changed the theme to Twenty Twenty-One. In the header.php for the theme, I've added some basic code to get the converted URL for a sample of site URLs in several languages. I've tried both with an without the $full_resolution flag set. I've cleared the WPML cache and cleared all transients. Using a browser that has had all cache cleared, I've navigated to a product category page. The result is that none of the URLs are correctly converted for any language.

wpml_permalink is clearly broken. The URLs in the language switcher are correct, but it doesn't use the wpml_permalink filter.

Untitled.png
October 10, 2023 at 5:58 am #14544239

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for contacting us.

We have not had such reports, and it should work fine.

The best I can do is ask you to replicate in the simple example in minimum environment, and then if the issue still happens I can escalate further to our 2nd tier to check if something is wrong in the approach or if it is a bug from our side.

Please try to keep it simple and custom code to a minimum.

Please share the steps you did and how can we check the issue.

Sandbox website:
- hidden link

Let me know how it goes.

Thanks,
Drazen

October 10, 2023 at 7:53 am #14546723

michaelS-131

As detailed in my post; I have created a minimal instance. I've removed all non-essential plugins, cleared all caching, and switched to a core theme.
The only code added is the code required to test the problem.
I've done some more testing and there are several URLs which for some languages do translate correctly, so I'm tending to think that it's a combination of the hook not working properly (given that the language switcher has the correct URLs), and the state of the data.
I've looked at the icl_translations table and termmeta, and there's nothing obviously wrong. Can someone who knows how the hook works confirm if there are any DB queries with inner joins to other tables that could be causing dropped rows?

October 10, 2023 at 8:00 am #14546927

Dražen
Supporter

Languages: English (English )

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

Hello,

I understand your point, but this is the procedure for bug reports, and as said hook should work fine, we do not have any other reports.

We need to have it reproduced in the test site, so I can escalate further. This will also tell us if the issue is specific to your site or a bug from our side.

- https://wpml.org/purchase/support-policy/

This will help speed things up and proceed from our side.

Please let me know how it goes.

Regards,
Drazen

October 11, 2023 at 2:56 am #14554487

michaelS-131

How is what you're proposing going to consider state as persisted in the DB?

October 11, 2023 at 6:43 am #14555357

Dražen
Supporter

Languages: English (English )

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

Hello,

you first reported that wpml_permalink filter is not working correctly, so I am trying to confirm this if it is a bug and needs escalation further.

Why isn't the wpml_permalink filter working for all URLs? And is there a function I can call passing a URL and target language to get back the correct URL? wpml_permalink is clearly broken. The URLs in the language switcher are correct, but it doesn't use the wpml_permalink filter.

As I said it should work fine, and that is the method/filter we suggest using for getting URLs in another language. So if the issue is not happening on the sandbox I provided, we will check further your website and see what might be causing the issue you have.

Let me know how it goes.

Regards,
Drazen

October 11, 2023 at 1:59 pm #14559987

michaelS-131

Of course it should work fine. In an ideal world, everything would work fine. The thing about these kind of bugs, is that they often only occur given a certain set of circumstances or configuration. Proving it works once in a sandbox environment is not going to cut it. Not to mention the time that would be required to attempt to ensure that all of the settings in the sandbox match my settings; it's a very poor use of my time for troubleshooting the issue.

October 12, 2023 at 5:35 am #14562563

Dražen
Supporter

Languages: English (English )

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

Hello,

we are still not sure if it works or not in the sandbox, and of course, we do not need you to reproduce everything, just show us with 1 post that the hook is not working. In that case, it would be simpler and quicker to escalate further.

Another way would be for me to check your staging site and take a copy to confirm it further on our test server before escalating to our 2nd tier.

Let me know if that is okay, and then I will enable private boxes in my next reply where you can share wp-admin and FTP access.

Thanks,
Drazen

The topic ‘[Closed] Get URL in another language’ is closed to new replies.