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.
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.
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?
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.
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.
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.
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.