Skip Navigation

[Resolved] AJAX not working correctly with WPML

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.20 hours from now. Thank you for your understanding.

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: Africa/Casablanca (GMT+00:00)

This topic contains 60 replies, has 3 voices.

Last updated by simonM-5 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#1702703

Hi Support

We would like to use the Custom Search Setting AJAX results update when visitors change any filter values however it doesn't seem to work reliably with WPML.

For example, when switched on in View "Find a Native Nanny Search and Results View":
1) I click on Find a Native Nanny viewing the site in English >> no results
2) However, when I switch the site to German, results appear (Deutsch).

I saw some other posts on here where people hadn't switched on the option WPML > Languages > Language filtering for AJAX operations > Store a language cookie to support language filtering for AJAX, but it is on our site and the filtering still doesn't work correctly.

This must work no matter what language I am viewing the site in.

Please provide a private reply so I can give you logins to try this out.

Kind regards
Simon

#1703455

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Simon and thank you for contacting the Toolset support.

If you check WPML->Settings->Post Type Translation, you will see that "Nanny Ads" are not translatable, Which means that German does not have any Nanny Ads, and of course the search results will always be empty. Check this screenshot hidden link

You will have to configure "Nanny Ads" to be:
- Either: Translatable - use translation if available or fallback to default language
- Or: Translatable - only show translated items
In the second case, you will have to translate all the "Nanny Ads" to German or duplicate them from WPML->Translation Management.
In case you choose the first one, keep in mind that it will work only on one direction(English "Nanny Ads" will appear on German, not the opposite).

I hope this answers your request. Let me know if you have any questions.

#1707643

Hi Jamal

When we have Post Type Translation set to anything other than "Do not translate" then we run into issues with English and German becoming out of sync with each other.

I opened several tickets about this before (eg https://toolset.com/forums/topic/split-posts-created-updated-in-2nd-language-only-visible-in-2nd-language-update-post-form-with-wpml-with-translations/page/2/).

It appears that contrary to advertisements, WPML and Toolset together are not able to achieve the simple goal of having the website 100% multilingual, without having to write custom code.

This is quite disappointing, as our site is a listing site, which Toolset is supposed to be ideal for and was one of the reasons why we chose Toolset in the first place. However whenever a user creates a listing, it should be viewable and updatable (using Toolset Forms) in all languages. Currently our site is English and German - we had to remove Spanish to reduce complexity unfortunately.

If we set to Translatable or Translatable - Fallback, then editing a listing using Toolset Forms in the "secondary" language (German) does not update the listing in the primary language, and the two languages get out of sync which is unacceptable. (Please feel free to correct me if any statement I have made is incorrect or inaccurate! Perhaps with the current versions of the various plugins, that has changed? We try to always be on the latest version. But as far as I can see my statements are still correct.)

If we set it to Do Not Translate, then we can view, edit and search the listings in both languages successfully and all updates are shown in the other language successfully.

Of course we would be absolutely delighted if this serious design flaw has been corrected with the WPML duplication/translation issue that updates to listings in a "secondary" language are not automatically propagated to or reflected in other languages. 🙂

Should it work if we set WPML > Languages > Language filtering for AJAX operations > Store a language cookie to support language filtering for AJAX to OFF and leave the Ads (listings) on Do Not Translate?

Kind regards
Simon

#1707851

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Simon,

I'll first try to answer your last question, then I'll give more insights on how WPML works and then how it is being integrated to Toolset.

Should it work if we set WPML > Languages > Language filtering for AJAX operations > Store a language cookie to support language filtering for AJAX to OFF and leave the Ads (listings) on Do Not Translate?
This option is only useful if there is data that will be queried. If for example, you only have the posts in German, this option will not help with English, and vice-versa.

Regarding WPML, it may seem difficult to use, especially, because it tries to provide a solution for a huge range of use cases from a small website to very big websites. That may be overwhelming. But once, we understand how it works, it becomes simpler.
The best practice with WPML is to translate from the primary language to the secondary languages. And sometimes, it is useful to duplicate instead of translating(which is helpful for SEO reasons). But it is always a one-way direction. If the original post is updated, the modification is propagated to the duplicate, but not in the other direction.

I can't really say what option to choose for WPML(translatable or not, with fallback or without), that depends on the project use case. I would say, that duplication is probably the best solution, but it will need custom code to be implemented. And If you desire to update the duplicate with CRED forms and propagate the modification to the original post, it will need additional custom code.

Regarding the integration with Toolset, we will be publishing a new version of the plugins, soon, probably next month, that was focused on the integration with WPML.

Basically, the translation mode to choose will depend on your use case, so depending on what you expect to have, I can suggest what to do. Currently, I can see that the search form is working for both languages. German only contains 2 posts right now.
So, let me know what you would like to have in terms of functionality(need German posts to be also viewable in English and vice-versa, etc.) and I'll suggest what to do.

Best regards,
Jamal

#1708117

Hi Jamal

Firstly thank you for your polite and considerate response.

I understand well the complexities of the job that WPML is trying to do, and for the most part it does so quite well, even if the interface is a little clunky and inconsistent at times.

Our goals are very straightforward. We want to use Toolset and WPML as our preferred plugins to handle most of our site and to avoid having to be a PHP programmer to get a decent site up and running, which is functional and easy to use.

More specifically:
1) When creating Ads, users should be able to view and edit their Ads in any language.
2) The newly created Ads should be instantly available in all languages. We only have one text field which doesn't need translation, the rest of the fields are taxonomies which are already translatable, or numbers or dates, which require no translation. (Please note, this works perfectly when Do Not Translate is selected. Our only problem is having AJAX instant search switched on and having Do Not Translate selected).
2) Any updates performed via Toolset Edit Forms must propagate to all other languages, regardless of whether they are primary or secondary.
3) The search functionality must find all results, regardless of whether they primary or secondary, for the same reasons as in point 2: the taxonomies are translatable and numbers and dates need no translation.

NICE TO HAVES once 1, 2 and 3 are given:
4) If possible, not to have to create (in my opinion superfluous) duplicates of the content. From a database point of view, this is a very strange practice to have to duplicate everything (and triplicate, quadruplicate etc for each additional languages), rather than just translating labels etc.
5) AJAX "instant" search should work, regardless of language

We are also SUPER curious as to the content of the upcoming updates! 🙂
Is this a big major new release? Are you allowed to divulge any more details yet? 😉

Thanks and regards
Simon

#1708795

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you Simon!

Regarding (1), let's first see how we can view ads in any language with WPML. The possible ways are:
1. Configure Ads to be translatable with fallback to the original language if no translation is available. But this only works for posts in the default/primary language. Check this article https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/
2. Duplicate the post to other languages. This needs "WPML Translation Management" activated and configured. And needs to be done from the backend. https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/using-content-duplication/
To do it automatically, it needs custom code. If you need this feature built into WPML plugin, I'll suggest asking for it here https://wpml.org/suggest-a-new-feature-for-wpml/
3. Custom code again, by hooking into the actual WP_Query and modifying the "suppres_filters" argument. Check this support forum https://wpml.org/forums/topic/new-wp_query-in-all-languages/

Regarding editing ads in all languages, that's is also limited. Because the link between posts and their translations/duplicates goes on one way. And the best practice with WPML is to always create original content in the default language.
In case, duplication or translation is used, it will need custom code to sync the post data across languages.

Regarding (2), if the ads are translatable, newly created Ads can't be instantly available in all languages without some custom code.
If "Do Not Translate is selected" is used. It's working except AJAX filtering, maybe we can hook into the view and switch to original language. I am not sure if it will work, I did not test it. This is similar to this previous ticket https://toolset.com/forums/topic/search-results-show-in-different-language-with-wpml/#post-626401

Regarding (3), WPML can't mix the translation of taxonomies and duplication or non-translation. If you need to translate the taxonomies, you will need to translate the posts too. And you will need to always translate edit content on the primary language.

Regarding (4), from a database point of view, I think that it will be fine to duplicate posts. Databases can handle millions of records in milliseconds. WPML offers duplication to overcome integration limitations with 3rd party themes and plugins.
We are the author of both, WPML and Toolset, and we work on improving the integration every day. But that would take some time before getting to a big number of features integrated.

Regarding (5), I am not yet sure of a solution or if that can't be done under the site current state.

What I would suggest, is preparing a test site on our platform and exploring the possible solutions and what limitations will arise:
- Not translating, and hooking into the view process.
- Translating or duplicating, and hooking into the "edit" an ad process.
- Working with translated taxonomies.
If you would agree on that, please use the following URL to login, configure WPML, and prepare enough data(CPTs, Taxonomies, posts) and we'll explore all the possible ways. hidden link

Sounds good? Please let us know your feedback.

#1712405

Hi Jamal

It doesn't sound good, it sounds great!!!! 🙂 May I again express our deep appreciation for this helpful proactive offer. If I understood you correctly, you would like us to create/provide a site where Toolset/WPML experts can trial the various translation scenarios?

I do believe it is in onTheGoSystems's interest to find a fundamental solution to this issue, as I am sure you have 100s of customers facing exactly the same challenges as us, who have bought Toolset and might be disappointed when they discover it can't run the site 100% multilingually natively out-of-the-box.

A few points worth mentioning at this stage:

• The worst problem is that updates are not reflected in all languages. In general most Ads would be created and then deleted or would expire, but we have to allow the user the possibility to change the Ad.
• All Ads would be created by front end users, so it's not like we create in English and then translate to German.
• Our site would work well already without duplication if the AJAX searching could work with Do Not Translate set for our Ads, but you're right - database speed shouldn't be an issue these days:
• our taxonomies translate automatically after creation or editing
• our date and number fields don't need translation
• we only have one large freeform text field where the Nanny or Family can describe themselves, and this field doesn't need translation
• the Custom Code snippets included in the site are mostly from Toolset support anyway, as I am not a PHP programmer. I have more of a database background.

We would be more than willing for you to use a duplicate of our current dev site for testing purposes as it is not yet live, rather than having to re-create everything again from scratch. What do you think?

Please let me know how you would like to proceed.

Kind regards
Simon

#1713641

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Simon,

I suggested that we offer a test site on our platform for testing, but we can also work on your duplicate site, instead of recreating this from scratch. I suppose that the provided access credentials are for your duplicate site or would you need a private reply to share credentials to another test site?

I understand your opinion regarding the integration of WPML and Toolset, and you are right, it is on our interest to make the integration as smooth as possible and I assure you that we are working on it.
I just want to point out, that your use case is not really the common use case for multilingual content, as you do not need to translate anything except the taxonomies.

Let me know what site would you like me to test on it and I'll start away. If you need a private reply to share new credentials, just send an email(jamal.b(at)onthegosystems.com) and reply here and I'll check it.

Once we agree on the test site, I'll first test "Not translating, and hooking into the view process."
If we can make it work, that's fine, if not, I'll check the duplication solution.

I'll first work with a default theme, so we don't get some compatibility issues to interfere with our working. Then we'll see how it will work with your current theme.

Thank you Simon!
I'll be waiting for your reply.

#1714721

HI Jamal

I'm still cleaning up a few loose ends for Job Ads and Nanny Ads, including testing another Ticket we have open with you.

When I'm done with that in the next few hours, should I just create a copy of our site using our Duplicator Pro plugin? I could make the files available via FTP. I believe we did this together on another ticket I had with you.

Does that work?

Thanks and best regards
Simon

#1714843

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Yes, Duplicator would work fine to copy the website to another location.

I am setting your next reply as private if you want me to build the Duplicator copy on our servers.

#1715783

Hi Jamal

Sorry, we got bogged down yesterday on sorting issues with WPML(it will be my next ticket 😊).

But I think the dev environment is in a state where you could start your testing. I tried already with Duplicator Pro but had difficulties finding the files on the FTP Server, something has changed in the Plugin.

Is there a possibility for us to have a short video or phone call to discuss how to proceed? I would love to be able to provide you the site ASAP and perhaps it would make sense if I could give you a quick 5 minute walkthrough of our site somehow via screen-sharing eg via hidden link to show you how we intend it to work and what the issues are we are facing.

You could also reach me on [Phone number removed].

I'm currently working for another company today and will be able to react better tomorrow, but I also don't want to delay your testing, so I'd be willing to take time out to get you up to speed.

What do you think?

Kind regards
Simon

#1716357

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Simon,

Actually, I can't contact you another way than what we currently offer, the chat, and the forum here on our website.

I preferred to start on a clean install, so, I run a couple of tests on a new installation and we can work on your test site after.
It appears that the first option is not possible. We can't set the custom post type as not translatable and filter the view in all languages.
And we can't set it to fall back to the original language if we intend to create posts in all languages.

Which leaves us with the option to duplicating posts using custom code. I use the following code to duplicate the post from a Toolset Form in any language, note that my create form ID is 19:

function quick_duplicate_save_data_action( $post_id, $form_data ){
        // Change your CRED Form "ID" accordingly below
        if ($form_data['id']==19){

            // Use WPML API   
            do_action( 'wpml_make_post_duplicates', $post_id ) ;
        }      
}    
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );

This actually leaves us with possible issues when editing the posts. And it depends on how you implement the editing workflow. We'll need to always allow the user to edit the original post instead of its duplicate.

Can you explain how an Ads is edited on your website? How your users will edit their Ads?

You can check my installation here hidden link

#1717135

HI Jamal

We are using Toolset Forms to edit Ads. Click Ad icon in the menu - a list of all the Ads the user has created is shown.

There they have the possibility to place a new Ad using Toolset Forms, edit an existing Ad using Toolset Forms or Delete an existing Ad.

OK, can you please remove my phone number from the post above?

I will send you logins for our site via email, which you can use to play the roles of a Nanny or a Family.

Thanks and regards
Simon

#1717441

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hi Simon,

I visited both pages, find-a-job and find-a-native-nanny, but I was not able to get to a point where I can edit an Ad, maybe I need to log in using a different user!
Can you please record a short video or explain step-by-step, how a user can edit an Ad?

I will need to check this, to make sure that a post will always be edited in the language where it was created. I am still working for a couple of hours today, and I'll be working tomorrow too.

#1717459

Hi Jamal

You simply click the Ads icon in the menu - it looks like a megaphone. Could be that those two logins haven't created any Ads yet, so they're not seeing anything there - feel free to create a few. There you can create any amount of Ads you need and edit them on the same page once they've been created.

Did you get my email with the logins?

Cheers
Simon

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.