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.

Tagged: 

This topic contains 11 replies, has 3 voices.

Last updated by Sumit 1 year, 2 months ago.

Assisted by: Dražen Duvnjak.

Author Posts
September 6, 2023 at 2:58 pm #14353443

pierreB-13

I am trying to:
In the translated language of a post have an empty ACF field.

Link to a page where the issue can be seen:

Post in isolated dev env: hidden link
WP Admin [deleted]
See the "Hero Title" field in the "Page Fields" ACF Field Group.

Feel free to test everything in this test setup.

I expected to see:
My field stays empty when I update the German version of the post multiple times and reload the edit screen.

Instead, I got:
My field value gets overwritten with the source language value, if that isn't empty also.

More Information:

I've setup an isolated testing environment with only WP + ACF + WPML + ACFML in their recent versions and demonstrate the issue here in more detail in this 5min video:
hidden link

It seems to be a reappearing bug that we reported 2 years and thought to be fixed (maybe was) in ACFML 1.9.0. From ACML Changelog:
"Fixed an issue with copying field value every time when set to Copy Once but user wants to empty translated value."

Also seems to relate to this Errata that is marked as "resolved" with 1.9.0 (but isn't):
https://wpml.org/errata/advanced-custom-fields-acf-copy-once-is-copied-every-time-if-the-translated-custom-field-is-empty/

Thanks for checking.
Aaron

September 8, 2023 at 6:50 am #14363727

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello Aaron,

thanks for contacting us and sharing the detailed report.

I was able to confirm the bug and have escalated this issue further.

I will update you when I have more news.

Regards,
Drazen

September 11, 2023 at 8:47 am #14373691

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello,

our 2nd tier and ACFML developers checked, and it is not a bug as per us.

In such cases when you wish to use different values in 2nd language and use a native WordPress editor you should use the TRANSLATE option.

Regards,
Drazen

September 11, 2023 at 2:44 pm #14377459

pierreB-13

Hi Drazen

Switching the fields translation setting to "translate" would mean a very different behavior since it would mean that all initial content needs to be copied over manually which hardly is an option.

All of our customers always start with the original language as initial content, but then modify / translate that. That is also the behaviour of "copy once" as described on your documentation page:
"Copy Once – This option copies the value of the field from the default language, but the value of the field can be changed later in the WordPress native editor. After the first copy, it will not be kept in synchronization with the default language."
Source: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/

This is exactly what we would want and also how it works for all fields that aren't empty in the target/translated language. Only if a field is empty in the secondary language version of a post the values gets carried over again if the target/translated post is updated.

As you can also see from the Changelog of ACFML 1.9.0 this seems to be a Bug that was previously fixed and came up again:
"Bugfixes: Fixed an issue with copying field value every time when set to Copy Once but user wants to empty translated value."
Source: https://wpml.org/download/acfml/?section=changelog

Could you please recheck?

Thank you,
Aaron

September 12, 2023 at 6:12 am #14380297

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello Aaron,

I understand your point, and I have already checked with our ACFML devs, not just 2nd tier.

It was fixed when using the WPML editor for translation, but for the WP editor behavior is different and we suggest setting it to Translate not Copy once, and that is the correct way to use it. What our docs say is related to when the field has values to be copied, not when an empty field needs to be synced.

Anyway, if you still wish to use Copy once, the old workaround with adding blank space still works and you can use that one.

Hope you understand.

Regards,
Drazen

September 12, 2023 at 8:13 am #14381295

pierreB-13

Hi Drazen

I find it very hard to follow along your / the dev teams argumentation:

Why should "copy once" behave differently if there's a value in the target language's field than when that is empty?

The behaviour seems inconsistent and intransparent:
- Only copy once if the target field has a value
- Always copy if the target field is empty

Why would the term "once" suddenly mean "always"? That seems very misleading to me 🤷🏻‍♂️

The whole idea behind the terminology seems to me that it is about only being copied one time, on first duplication / translation of the page...and after that nothing would ever happen with the target field. Which is also how it works as expected with non-empty fields.

Sorry to be so persistent on this issue, but WPML is really going to stick with that choice? I would urge you to clarify this again with the product / dev team.

From my perspective (as a dev and also as editor of several websites using WPML) that would not be a standpoint I can reproduce. It definitely (and to me obviously) leads to more posts containing unwanted and wrong content, which will often only be realisied later on if the final published post is thoroughly checked.

Thank you for a final comment on this.
Aaron

September 12, 2023 at 8:19 am #14381347

Dražen Duvnjak
Supporter

Languages: English (English )

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

Hello Aaron,

I have shared your reply with our 2nd tier and ACFML dev, we will update you soon.

Regards,
Drazen

September 12, 2023 at 9:49 am #14382363

pierreB-13

@Dražen

Thanks a lot, that is appreciated 👏🏻

September 12, 2023 at 4:17 pm #14385375

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

I am Sumit from 2nd tier support. I understand your concern and let me explain to you what is happening here.

Our copy-once feature works only when creating a new post and there is no value in the translated post meta even the empty one.
This works fine if we speak about just normal custom fields and not ACF.

In ACF, ACF saves the empty values in post meta as soon as translation is added even before WPML can copy the value. WPML sees there is an empty value so it does not copy the values.
To fix this problem we added logic in ACFML that as soon as ACFML sees the empty value it removes post meta (i.e. save as NULL) so that our copy-once logic can work.

But after it we got another problem when the user saves the empty value the copy-once is triggered.

To fix this we added another fix to check the previous value If this was empty trigger the copy once if there was a non-empty value and intentionally being cleared halt the copy once.
This is what you are seeing, on the first save it works, on 2nd update you see the original meta value.

We decided not to fix it because
- We recommend using Translation Editor/ATE to translate the post/page. If you need to have empty translated field you can switch the language manually from admin language swticher and change it to empty string This will work. And next time if you translate the post/page again with Translation Editor it will not override the empty value no matter how many times you save the translation.

- When using Native Editor, the recommended mode is to use different fields across the language or set the field to translate in expert mode. Because in native editor you have control over the fields of what to translate.

- You can use &nbsp instead of empty value. This is almost same as an empty value.

I don't deny your comment and I understand this can be improved more but this depends on workflow. A native editor is not commonly used with Expert mode instead it is used with Different fields across the language as users want to take control of the fields entirely and do not want WPML to interfere with it.

However, if we see this should be improved in the future we will upgrade the logic. But for now, we have offered you the possible solution and explained the behavior differences.

I hope you understand!

September 13, 2023 at 6:09 am #14387021

pierreB-13

@Sumit thank you for taking the time to respond to this request and explain, in detail, why you're taking that path. It's still not what we would like and causes problems in the client's editorial workflow, but I think we have no other choice than accepting it for the time being, working around it with the empty string, and hoping it might be improved in the future.

I'll share some more insight into how the site setup / editor works, maybe this might show you a different way of how WP & ACF & WPML work together in this case (see screenshot attached):

The editing experience we usually provide to customers is based on a main "page Components" ACF flexible content field (hidden link). This offers the customer a set of pre-built components that each page can be flexibly built with.
Each component ("layout" in ACF language) contains multiple ACF fields, typically set to "copy once".

So the typical workflow for an editor would be:
1. Create the post in the main language, add some components in the "page components" flexible content field, enter data into the fields.
2. Translate the post to new language using WPML (create a duplicate)
3. Edit the translation using the classic editor / ACF.
- Often the translated post will be similar to the source language post, but it might also contain different components or have content removed.
- In the DB data is stored just the same as when you have an ACF flexible content field on the top level of a page.

Using the Advanced Translation editor doesn't really work because that would mean that translated post need to be copies of the source post; it would not allow the client to add new components / remove others from a post.

Using "translatable" as a field setting would mean the editors need to make the "duplicate" of the post themselves manually to start with...which would mean quite a bit of work and is certainly not a great or efficient experience.

An idea that I had to improve the situation for similar cases would be to be able to have a sort of "don't copy" / "copy once done" setting that could be set per post (programmatically, not through an interface) so that ACF would no longer try to copy the field values and would ignore the empty fields.

Greetings from Switzerland 🇨🇭 and thanks again,
Aaron

September 13, 2023 at 6:10 am #14387023

pierreB-13

Uploading the screenshot didn't work with me previous post...so here it is again.

Screenshot 2023-09-13 at 07.49.03.jpeg
September 13, 2023 at 7:13 am #14387279

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Often the translated post will be similar to the source language post, but it might also contain different components or have content removed.

To avoid mixing the workflow we decided to introduce new modes https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/#selecting-a-translation-option in which you choose "Different fields across languages" if you want to have a different layout.

We were allowing customers to set the translation preference for each field and that was causing issues so we decided to give two simple options only the same fields or different fields.
The Expert mode is legacy mode.

Here I would suggest keeping the "Different fields across languages" and when you translate the post in this mode, ACF will copy the fields (The Layout field that you want) for you on first time and then you can modify them.

Please let me know if this works for you.

Thanks