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: Custom Work
This topic contains 3 replies, has 2 voices.
Last updated by Minesh 1 year, 2 months ago.
Assisted by: Minesh.
Author | Posts |
---|---|
February 16, 2024 at 5:01 pm #15312610 | |
michaelT-92 |
Hello We've built a wedding registry site for a travel agency. WPML is set to translate everything automatically without manual approval, and this setup works well. But, we're stuck with an issue. When we add new content to posts through code (specifically, after a gift purchase, we update posts in the functions.php file), WPML doesn't catch these updates for translation and so auto-translate is not triggered. We attempted a workaround based on a suggestion from a WPML supporter, which involved using wp_update_post() after the purchase event. This approach appeared to initiate some activity—specifically, in the WordPress backend, the post shows a spinning arrow icon with a tooltip that reads "Waiting to be translated." Unfortunately, this status remains indefinitely, alternating between a spinning arrow and a gear icon, but the translation never actually occurs. The only method that successfully triggers the translation is manually opening the post in the editor and clicking update, which isn't viable for our use case. Do you have any advice or a fix to make WPML automatically translate content added programmatically? Thanks for your help. hidden link |
February 19, 2024 at 7:43 am #15316105 | |
Minesh Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hello. Thank you for contacting the WPML support. Any field inside the Classic Translation Editor or Segment inside the Advanced Translation Editor will need to be confirmed by the user. The thing is that WPML only update the translation from backend - in such case, if you are updating the post when admin is logged-in and dashboard is open then it should work. Otherwise, there is no way to auto-translate the posts after content added programmatically. I checked the API doc and there is not any hook for that purpose: You could achieve this by selecting the element with JS, and setting the checkbox attribute to "checked" once the text field has a value, but this is in fact custom work and not covered by our support policy: |
February 19, 2024 at 3:12 pm #15319309 | |
michaelT-92 |
Hi. Thank you for your reply. We are looking into alternatives. Regarding what you said here, "You could achieve this by selecting the element with JS, and setting the checkbox attribute to "checked" once the text field has a value..." If this will achieve what we need then we will look into it further, but we don't understand, could you please clarify, what attribute are you talking about? Thanks. |
February 20, 2024 at 9:56 am #15321505 | |
Minesh Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
I would like to clarify that the possible workaround I shared which involve the custom code is specifically applies for the Classic Translation Editor, it does not apply with your case as you are using "translate everything automatically without manual approval". I'm afraid that it's not possible or there is no such way around to accomplish what you want. That applies when you use Advanced Translation Editor but it does not seems that's not the case applied as you are using Automatic Translation Without approval. |