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.

This topic contains 1 reply, has 2 voices.

Last updated by Dražen 3 years, 5 months ago.

Assisted by: Dražen.

Author Posts
November 9, 2021 at 4:54 am #9952347

harisA-5

Hello!, I develop a plugin that using ACF Pro as custom field library. I want to make all of the plugin's custom field are translate able with WPML.

I have successfully done this with wpml-config.xml except for the ACF repeater field.

I have followed the documentation about this and also a thread here: https://wpml.org/forums/topic/xml-config-option-to-translate-repeater-custom-fields/

Is this wpml-config.xml support for ACF repeater has changed?

Below is the wpml-config.xml for the repeater field:

```
<wpml-config>
<custom-types>
<custom-type translate="1">route</custom-type>
</custom-types>
<custom-fields>
<custom-field action="translate">acf_prettyroutes_waypoints</custom-field>
</custom-fields>
<custom-fields-texts>
<key name="acf_prettyroutes_waypoints">
<key name="*">
<key name="tooltip" />
</key>
</key>
</custom-fields-texts>
</wpml-config>
```

And below are the compact version (issued repeater field only) of the exported php file of the ACF fields that included to my plugin to generate the ACF fields

```
<?php

if( function_exists('acf_add_local_field_group') ):

acf_add_local_field_group(array(
'key' => 'prettyroutes_acf_group_60a72e436d9b0',
'title' => 'Route Options',
'fields' => array(
array(
'key' => 'prettyroutes_acf_field_60a7763dc0835',
'label' => 'Detail Waypoints',
'name' => 'acf_prettyroutes_waypoints',
'type' => 'repeater',
'instructions' => 'This field is based on above maps waypoints items. Add some waypoints on the map above and add theirs details here.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'row',
'button_label' => '',
'sub_fields' => array(
array(
'key' => 'prettyroutes_acf_field_60a77725c083a',
'label' => 'Tooltip',
'name' => 'tooltip',
'type' => 'textarea',
'instructions' => 'This is the brief text that appears in the tooltip when a user hovers over this location.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
),
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'route',
),
),
),
'menu_order' => 0,
'position' => 'acf_after_title',
'style' => 'default',
'label_placement' => 'left',
'instruction_placement' => 'field',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));

endif;
```

November 10, 2021 at 1:07 pm #9965991

Dražen
Supporter

Languages: English (English )

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

Hello!

Welcome to WPML Support. I'll do my best to help you solve this issue.

Make sure you are using The Advanced Custom Fields Multilingual (ACFML) plugin. ACFML is a bridge plugin that makes WPML and Advanced Custom Fields plugin compatible.

- https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/

I am afraid I do not think XML config ever worked in such a way for ACF repeatable fields. If you check WPML > Settings > Custom fields, you will see each new subfield has a unique name. So for subfield named "text", for repeatable named "rep", it will say rep_0_text, for second 1, and so on.

You can set them via XML for each by defining custom field translating settings and it will work, but not in a way you tried with subfields and etc. Image attached.

Another way you can try is by setting translation directly in ACF PHP/JSON file via wpml _cf_ preferences tag. You can create ACF groups with WPML normally then export and add code inside your theme/plugin and it should work fine with already set WPML settings.

- https://wpml.org/compatibility/2021/09/acf-multilingual-1-9-support-for-importing-and-exporting-translated-custom-fields/

I hope I was helpful. Don't hesitate to ask if you find any problem along the way, I'll gladly help you.

Regards,
Drazen

Screenshot_7.jpg