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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Bobby 6 months, 3 weeks ago.

Assisted by: Bobby.

Author Posts
July 12, 2024 at 7:19 pm #15943319

cliffA

Background of the issue:
Whenever I do an ajax call from the frontend of my website, WPML seems to serve me whatever language is configured in the backend (admin screen) of the website. I am on the English site browsing it from the client (frontend) side of things but logged in as an administrator and have my admin language setup as French. Whenever I do any ajax calls on the front end of the site using wp.apiRequest call or The Events Calendar ajax calls, I am served the admin language (French) content. Link to a page where the issue can be seen: hidden link

Symptoms:
Ajax calls on the frontend are returning content in the backend (admin) language instead of the frontend language.

Questions:
Why are ajax calls on the frontend returning content in the backend language?
How can I ensure ajax calls return content in the frontend language?

July 12, 2024 at 11:20 pm #15944937

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

What is the ajax call you are calling and what are the expected results ?

When logged in there is a cookie saved based on the admin language, if you give me more information regarding the action and desired results I'll be able to better help you.

July 19, 2024 at 12:45 am #15975256

cliffA

I am noticing this issue with several ajax calls, one is a call to the WordPress POSTS Rest Controller for searching the posts on the site.

This ajax call is using the wp.apiRequest function so it is sending the proper nonce to verify if the user is logged in etc. I have since fixed this by simply just appending lang={language_code} to the query parameters to force WPML to use that specified language.

I was hoping that it would instead use the current front end language cookie instead though but that issue has been resolved.

The other issue that I am not able to resolve though is the ajax calls from "The Events Calendar" plugin, it works fine when you are not logged in or if you are logged in and the admin language matches the front end language.

However as soon as the admin language differs from the front end language there is an issue.

July 19, 2024 at 10:27 pm #15980053

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for the above information!

Is that issue related to the language displayed in the WP admin bar? What is the issue you are experiencing with the Events Calendar plugin?

July 19, 2024 at 10:53 pm #15980159

cliffA

Correct this is related to BOTH the language selected on the Admin Bar as well as the language selected on the front end.

If I try to paginate between months on the calendar it IGNORES the language on the front end and uses whatever language is setup on the admin bar.

July 22, 2024 at 6:23 pm #15988507

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Thank you for confirming.

Regarding the WP Admin bar this is a known issue, our team is aware of it and at the moment there is no workaround.

Regarding the events calendar translation, just to verify this is happening only when logged in correct?

Please review this known issue here: https://wpml.org/errata/the-events-calendar-events-archive-pagination-not-working-and-redirects-to-pageseiteseite-d_-resulting-in-eventsveranstaltungen/ , if this is the issue you are experiencing please make sure to try the workaround listed.

Otherwise, try the following:

Go to WPML->languages and enable the Language Ajax cookies.
Clear your cache and test in a new browser window.

Let me know your results, please.

July 22, 2024 at 6:43 pm #15988710

cliffA

Hello Bobby,

Correct it only happens when logged in and the language on the front end differs from the language set in the admin panel(admin bar).

So I will await for the fix/work around.

Thank you.

July 22, 2024 at 7:11 pm #15988847

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hi there,

Were you able to resolve the other issue in pagination when enabling the Language Ajax cookies?

Regarding the admin bar, I cant say with certainty when a fix or workaround will be provided for this.

The topic ‘[Closed] Frontend Ajax calls are using Backend Language to fulfill them.’ is closed to new replies.