Home › Forums › Add-ons › Flexible Content Field › Layouts label translation missing › Reply To: Layouts label translation missing
Hi @acf-support
thank you very much, this code snippet solve the problem.
I did not know about the existance of it.
But I wish to say that, however, any label that are exposed to the public such as layout label and button label (in flexible content) as well as button label (in repeater field) should be all wrapped into the __()
function by default.
Really, The snippet solve the problem perfectly, but Elliot should consider the suggestion to include even this labels into the acf translation process.
Anyway I’ve improved the snippet code including other labels that needs translations:
function my_acf_fix_layout_translate( $field ) {
//flexible content
if( $field['type'] == 'flexible_content' ){
//layout labels
foreach( $field['layouts'] as $k => $layout ){
$field['layouts'][$k]['label'] = acf_translate( $field['layouts'][$k]['label'] );
}
//button label
$field['button_label'] = acf_translate( $field['button_label'] );
}
//repeater
if( $field['type'] == 'repeater' ){
//button label
$field['button_label'] = acf_translate( $field['button_label'] );
}
return $field;
}
add_filter('acf/translate_field', 'my_acf_fix_layout_translate');
Thank you very much again.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.