ACF PRO comes with the Repeater and Flexible Content field types. Here, we’ll show you how to translate the content from these fields using WPML.
You may want to use Repeater and Flexible Content fields for different custom field structures across languages. For example, you may want your Flexible Content fields to have various Layouts, or to have Repeater fields with an uneven number of subfields in different languages. In such cases, you need to translate the field values using the native WordPress editor. To learn more, see our page about Using Flexible Content Fields for Different Custom Field Structures Between Languages.
Setting the Translation Preferences for Repeater and Flexible Content Fields
When using Repeater and Flexible content fields, you need to set the translation preferences for:
The main Repeater and Flexible Content fields
The sub fields assigned to your main Repeater or Flexible content fields.
Below, we cover the steps for setting the translation preference for Repeater fields, which is exactly the same for setting the translation preference for Flexible Content fields.
Start by navigating to the Custom Fields Translation section in WPML → Settings. You need to set the translation preference for the main Repeater field, or the main Flexible Content field to Copy and Save your changes. This allows you to have the same custom fields and the same number of Repeater and Flexible Content field instances in all languages.
Setting the Translation Preferences for Repeatable Sub Fields
Repeater and Flexible Content fields allow you to add custom fields as sub fields. Any kind of custom field can be used as a sub field.
WPML allows you to choose between four translation options for your repeatable sub fields. You can learn which translation preference to use for each field type by reading our documentation about recommended translation settings for ACF and WPML.
To set the translation preferences for your custom fields, go to WPML →Settings and scroll down to the Custom Fields Translation section. Remember to Save your changes once you’re done.
Please note that you only need to set the translation preference for each sub field once. Every following sub field you add on the post edit screen will have the defined translation preference applied.
Translating Repeatable Sub Fields
Once you set the translation preferences for the subfields added to your main Repeater or Flexible Content field, you can translate the custom field values.
In the example below, we have set the field group Location Rule to Post type is equal to Post. You can set the location rule to show the fields in a specific custom post type such as Properties, Books, or Recipes. No matter the post type, the translation process is the same.
Start by creating a post in the default language and add values to the custom fields. Once you Publish the post:
In the Language section, click the plus icon. You will be taken to the Advanced Translation Editor page. The post content along with the values of the custom field that are set to Translate are available for translation.
If you have translation credits, you can click the Translate automatically button to add the machine translations. If not, enter the translations for each line manually. When you’re done, click Complete to publish the translations.
Translating Choice Labels for Repeatable Select, Checkbox, and Radio Button Sub Fields
ACF allows you to add Select, Checkbox, and Radio button field types to your main Repeater or Flexible Content fields. You may want to translate the Choice labels for these field types. No matter if your Select, Checkbox, and Radio button field types are assigned to a post as custom fields or repeatable subfields, the translation process is the same.