Skip to content Skip to sidebar

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

Problem:
The client was experiencing an issue where Elementor container templates translated into Russian were still displaying in English on the Russian version of the site, despite using the correct translated shortcodes.

Solution:
The issue was resolved by modifying the code snippet used in the template. The original code forced the template to revert to English after switching languages, which prevented the Russian translation from displaying. The corrected code snippet ensures that the template switches back to the original language after fetching data in English, allowing the Russian version to display correctly. Here is the corrected code:

$curr_lang = ICL_LANGUAGE_CODE;<br />do_action('wpml_switch_language', 'en');<br />$usd_prices = json_decode(get_option('ukgov_visa_costs_usd'), true);<br />do_action('wpml_switch_language', $curr_lang);

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

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 0 reply, has 1 voice.

Last updated by Carlos Rojas 4 months ago.

Assisted by: Carlos Rojas.

Author Posts
March 31, 2025 at 2:49 pm #16880007

christopherW-28

Hi Carlos

The issue is fixed, thank you for your assistance.

It was being caused by a piece of code in a snippet that was being used in the template:

do_action('wpml_switch_language', 'en');
$usd_prices = json_decode(get_option('ukgov_visa_costs_usd'), true);
do_action('wpml_restore_language');

The do_action('wpml_restore_language'); line was suggested in an online forum to restore the original language to what it was before a switch. This didn't work and so the language for templates was always staying in English.

Replacing the code with:

$curr_lang = ICL_LANGUAGE_CODE;
do_action('wpml_switch_language', 'en');
$usd_prices = json_decode(get_option('ukgov_visa_costs_usd'), true);
do_action('wpml_switch_language', $curr_lang);

Now, the template correctly returns to whichever language it was originally in and allows it to show Russian correctly.

Many thanks for your help.

Best regards

April 1, 2025 at 9:37 am #16882078

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

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

Great! I'm happy to hear that you found a solution to the issue.

Please don't hesitate to contact us if you need our help in the future with WPML.
Have an excellent day!