This reference guide provides a list of ACF Multilingual (ACFML) constants and hooks. You’ll find detailed explanations of each constant and hook, along with examples of how to use them in your code.
ACF Multilingual (ACFML) Hooks
acfml_should_translate_acf_entity
This hook allows you to determine whether ACF fields or field groups should be translated. By using this filter, you can skip translating specific fields or groups based on your custom logic.
Type: Filter
Availability: ACFML 2.1.4
Parameters:
$shouldTranslate
(bool) (Required) Whether the field or field group should be translated. Defaults to true.
$entity
(array) (Required) The entity being translated, which is either a field array or a group array.
$entityType
(string) (Optional) The type of the entity being translated. It can be either ‘field’ or ‘group’.
Hook Example Usage:
add_filter( 'acfml_should_translate_acf_entity', function( $shouldTranslate, $entity, $entityType ) {
if ( 'field' === $entityType ) {
return false;
}
return $shouldTranslate;
} );
ACF Multilingual (ACFML) Constants
ACFML_EXCLUDE_FIELD_GROUP_STRINGS_IN_POST_JOBS
As of ACFML 2.0.4, you can use this constant to disable the feature to include field group strings in the post translation job.
To disable this feature, just add the following to your wp-config.php file:
define( 'ACFML_EXCLUDE_FIELD_GROUP_STRINGS_IN_POST_JOBS', true );
Notes:
- If you created a translation job before adding the code above to your wp-config.php file, cancel it and create a new job.
- If needed, you can translate field labels and Choices via String Translation.
ACFML_HIDE_FIELD_ANNOTATIONS
To each translated field, ACF Multilingual adds information about the value in the original language.
To remove this information from translated fields, you can add the following line to your site’s wp-config.php file:
define( 'ACFML_HIDE_FIELD_ANNOTATIONS', true );
ACFML_REPEATER_SYNC_DEFAULT
You can use this constant to set the default value of the Repeater field sync feature. It is set to true by default. This means that the Repeater fields are automatically synced across translations. If you set this constant to false, the Repeater field sync will be disabled.
You can override the default value of ACFML_REPEATER_SYNC_DEFAULT in your theme’s functions.php file:
define('ACFML_REPEATER_SYNC_DEFAULT', false);
ACFML_SCAN_LOCAL_FIELDS
Setting this constant to false disables scanning of JSON files for local fields.
This means that if you change the translation preference in local fields, it won’t sync to the database. You need to set the translation preference manually for fields.
For more information check out the official ACF documentation about using local JSON.