Using
UsingTranslating Advanced Custom Fields (ACF)

Translating Advanced Custom Fields (ACF)

Gato AI Translations for Polylang can translate any custom field created with Advanced Custom Fields (ACF) that stores data in the meta tables (wp_postmeta and wp_termmeta).

How it works

In the Settings > Meta Configuration tab, define the meta keys to copy and translate for custom posts and media, under inputs:

  • Copy Meta for Custom Posts and Media
  • Translate Meta for Custom Posts and Media

...and for tags and categories, under inputs:

  • Copy Meta for Tags and Categories
  • Translate Meta for Tags and Categories

Each meta key can be defined via its name, or using a regex:

Configuring the meta keys for translation
Configuring the meta keys for translation

Defining fields to sync/translate

ACF stores 2 entries for each field:

  1. Entry _{field_name} contains internal metadata
  2. Entry {field_name} contains the field value

The first entry must be synchronized always.

The second entry must be either translated or copied, depending on the field type:

  • Translate text fields
  • Copy non-text fields
Meta KeyExampleAction
_{field_name}_description"field_68357a34e6fd7"Copy
{field_name}description"Integrate with the popular ACF plugin"Translate
{field_name}url"https://gatoplugins.com"Copy

Meta key patterns

ACF stores field data using the following meta key patterns:

  • For regular fields: {field_name}
  • For repeater fields: {field_name}_{row_index}_{subfield_name}
  • For flexible content fields: {field_name}_{row_index}_{layout_name}_{subfield_name}

For example:

  • my_text_field
  • my_repeater_0_title
  • my_flexible_0_text_block_content

You can use regex patterns to match these fields:

  • Match all fields: #^[a-zA-Z0-9_]+$#
  • Match repeater fields: #^[a-zA-Z0-9_]+_\d+_[a-zA-Z0-9_]+$#
  • Match flexible content fields: #^[a-zA-Z0-9_]+_\d+_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+$#

Example configuration

Here's an example configuration for common ACF fields:

Field TypeField NameMeta Keys to CopyMeta Keys to Translate
Text-baseddescription
subtitle
_description
_subtitle
description
subtitle
Non-text-basedfeatured_image
gallery
/^_?featured_image$/
/^_?gallery$/
Repeaterteam_member
- name
- url
- bio
/^_?team_member$/
/^_team_member_[0-9]+_.*/
/^team_member_[0-9]+_name$/
/^team_member_[0-9]+_url$/
/^team_member_[0-9]+_bio$/
Flexible Contentcontent/^_?content$/
/^_content_[0-9]+_.*/
/content_\d+_text_block_img/
/content_\d+_quote_block_bg/
/content_\d+_text_block_title/
/content_\d+_text_block_content/
/content_\d+_quote_block_quote/