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.
Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Background of the issue:
I am trying to switch languages using $sitepress->switch_lang and output strings using the __() function. The issue can be seen on this page: hidden link.
We are seeing this issue on another website as well, but I was able to reproduce it on a clean install with Twenty Twenty-Four. I created a test plugin that outputs this code via a shortcode:
Symptoms:
When visiting the site in English, switch_lang does not work. Strings are always output in English: hidden link. When visiting the site in German, switch_lang is working as expected and strings are output in the currently specified locale: hidden link.
Questions:
Why is switch_lang not working consistently when switching to English?
How can I ensure that strings are output in the current locale when using switch_lang?
Thank you for the sandbox credentials. I was able to reproduce the issue there.
Here is the German page where switch_lang works as expected: hidden link
And here is the English page where switch_lang does not work. Strings are always output in English: hidden link
For context again: I created a plugin "ATOM WPML Test" that registers the shortcode [atom_wpml_test]. This shortcode switches between languages using $sitepress->switch_lang and then outputs strings using __().
I have feedback from our 2nd Tier Support. They advise against directly accessing the method and recommend using the hook instead - you can find more information here: https://wpml.org/wpml-hook/wpml_switch_language/
Thank you for your reply. I replaced $sitepress->switch_lang('de') with do_action('wpml_switch_language', 'de') in the sandbox. The issue still remains the same. It appears that in some cases the translation files are not loaded correctly.
Hi, I just want to emphasise that this is a huge issue for us as we can no longer trust WPML to output the correctly translated content. And looking at the "known issues" page, this seems to be part of a larger problem where translation files are just not loaded under certain conditions.
This ticket is now nearly two months old. In the meantime you released String Translations 3.2.14 which "Fixed an issue with untranslated content being rendered on the frontend in certain cases with WordPress 6.5.". But unfortunately it did not fix the issue in our case.
I've reviewed the report, and it appears that no actions have been taken by our developers yet. However, I see multiple reports confirming the issue. I don't have an estimated resolution time at the moment, but I will keep monitoring the situation closely.
Hi, it appears that half a year later this is still not fixed. The issue still occurs in 4.7.3.
Just wanted to ask if you plan on fixing this at all? This is a serious bug affecting the core functionality of this plugin that we paid for. Over half a year of response time is not acceptable for this kind of issue.