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.

This topic contains 6 replies, has 3 voices.

Last updated by Ricardo Alday 12 months ago.

Assigned support staff: Ricardo Alday.

Author Posts
September 28, 2018 at 6:53 am #2772706

carecweb

Hello WPML Support,

From my tests, there seems to be a bug or wrong functionality when working with ACF repeaters and the "Copy Once" setting of custom fields.

This happens under the ff. scenario:

STARTING POINT:

1) there is already an existing translation and
2) the translation doesn't have repeater field values

Either because original post didnt have repeater data, or that the repeater fields and subfields were set to "Don't Translate" when the original post was saved (thus value didn't carry over to translation);

PROCEDURE:

1) The translation is updated (Publish or Save Draft) within WP (not translation editor).

After step 1, ACF saves the main repeater field setting (meta_key) with blank data (meta_value) for the translation, even if there is no repeater data on it yet.

2) The repeater data is added to the original post and/or the repeater settings are changed to "Copy Once", and the user updates the original post or updates the translation in the "translation manager"

In step 2), even if the repeater subfield value are carried over (copied once) to the translation, the value of the main repeater field is NOT since as stated above, there is already a setting with blank value.

----------------------------------------

I have to set the main repeater field to "Copy Once" since we use the repeater fields for news articles and downloadables, and those things are not always available in the translation. I cannot set it to "Copy" as your video says since that would not be applicable for us.

Based from your hidden link

I haven't thought about what to do for our case. For now I would like to report that this is a potential bug waiting to happen. Please suggest a possible workflow, since as the admin, I want the users to be able to update and correct entries on their own, and not to have to rely on me since I have access to the entire WPML settings and the WP database.

Thanks

Aldwin

September 28, 2018 at 9:02 pm #2774878

Ricardo Alday

Hi Aldwin,

Thank you for contacting WPML support.

Have you checked our documentation on how to synchronize custom fields? If not, you can see the steps in our documentation: https://wpml.org/documentation/getting-started-guide/translating-custom-fields/

Also, the "Copy Once" option will not synchronize after it has already been saved. That is, if you have already saved this page previously, this option will no longer be copied and you also need to be sure that corresponding "hidden" fields are also set to be copied. Did you do this?

e.g. if you have an ACF field called "window" then you will also find a system field "_window". Both of these custom fields need to have the translation options set.

October 9, 2018 at 4:06 am #2798215

carecweb

Hi Ricardo,

I'm afraid this did not help me.

Yes I have already read the page mentioned plus other related support posts I can find. As you can see from the original ticket, I have done more than cursory reading of the documentation, as I have tested, recreated, and identified a potential bug in the process.

I also understand fairly the limitations of "copy once". But your WPML-ACF "glue" plugin should take into account how ACF handles/saves repeater fields in the first place.

Can you perform the steps above on your end and then get back on how to proceed with this? Seems to me a high priority fix must be added to the code.

Regards

October 10, 2018 at 1:24 am #2802421

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

I would like to take care of your ticket from now. Thanks for following Ricardo's instructions, in that case, I am not sure if I have understood correctly what you are trying to achieve.

>>> I have to set the main repeater field to "Copy Once" since we use the repeater fields for news articles and downloadables, and those things are not always available in the translation. I cannot set it to "Copy" as your video says since that would not be applicable for us.

The base should be marked as "Copy". This is critical for WPML to know that the amount of repeater must be synchronized.

In this case, how did you set up your site? In my test environment, I marked the base field as "Copy" and the repeater fields as "Copy Once" and worked correctly. I'll attach an image for you to see.

By following the steps above, I can make it work correctly in my testing environment. Are you following any steps other than that?

Thank you.

October 10, 2018 at 1:59 pm #2804622

carecweb

Thanks for taking a crack at this Bruno.

My concern here is the use of "copy once" when the translation has a "blank" value for the main repeater field when saved (the translation, not original) using WP (not translation manager). It is blank because of the ff:

1) either you don't have repeater data yet on the original (more probable) or that the main repeater field setting is "Dont Translate" yet (less probable), AND

2) ACF by default assigns a blank value on the main repeater field if the post has no repeater data.

Once you add repeater data to the original or set the main repeater field setting to "Copy once", and then save it, the main repeater value from the original is not copied to the translation since as stated above, the translation already has a blank value in the database.

I get your point to assign the main repeater field as "copy" instead of "copy-once". In cases where the translation will have the same number of repeater data, then it is the right setting. However, "copy-once" is appropriate in our case because our translations will not always have the same number of repeater data as the original.

To illustrate, our original post has repeater data consisting of related external news articles. However, these news articles will (in most cases) not always be available in the translated language. Hence, the translated post will naturally have a repeater data consisting of entirely different set of news articles.

As you can see, Copy is definitely the wrong setting in this scenario, while Don't Translate is perhaps the most appropriate. However, I prefer to use Copy-once so that the translation will have a ready-list of repeater news articles (in the original language) that our translator will then update, add to, or subtract instead of starting from scratch when Dont Translate is used.

I suggest a new feature or bug fix to update the "copy-once" setting to include a check if the "copy-once" has already been performed or not. For now if there is data already present, then it will not overwrite it anymore even if WPML did not actually write that data. So "copy-once" in this case functioned as "Dont Translate" and never performed an initial copy. Copy-once should always perform an initial write. A check will resolve the situation I've described where ACF field already saved a blank value on the main repeater field, a situation you can bet is not uncommon and will happen a number of times.

Please note that I don't know the internal workings of your code and this is simply my observation using ACF repeaters and looking at the database. Please confirm if this is so and what your recommendation for my settings and workflow.

Thanks

October 11, 2018 at 7:30 am #2806945

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for the explanation. As they are two different versions, then these fields should be marked as "Translate" and then you could translate it any way you want - including different fields numbers between the original content and the translated content.

Note, however, that the expected of a translation page is to have the same fields, only with the translated content. To have two pages with different content - different fields, for example, then "Copy-Once" should not work as expected. I'll test this a little more and I'll contact you soon.

Thank you.

October 19, 2018 at 12:01 am #2829804

Ricardo Alday

Closing this ticket now. If you have any other questions feel free to open a new support ticket.

Thanks.