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 1 reply, has 2 voices.

Last updated by Bruno Kos 2 weeks, 6 days ago.

Assigned support staff: Bruno Kos.

Author Posts
October 3, 2019 at 7:57 am #4685533

pascalE-4

I am trying to: Get the chose language in string translations

I expected to see: The correct translation language

Instead, I got: I got always the translation with the language chose by default (french)

The option -> Language filtering for AJAX operations "Store a language cookie to support language filtering for AJAX" is checked, but when we made an ajax call it only gets the default language that it's french.

Hint:

When I get the cookie value from "_icl_current_language" before the "require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';" the language is correct.

When I get the value from "_icl_current_language" after the "require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';" the language is always french (language by default).

What am I doing wrong ?

October 3, 2019 at 11:52 am #4687217

Bruno Kos
Supporter

Languages: English (English )

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

Hi,

Can you please try the following
https://wpml.org/wpml-hook/wpml_current_language/

That's the proper way to get this data, so to use our API. Everything else is considered as custom work and not included into support.

Regards,
Bruno Kos