Support

Account

Home Forums General Issues Translating form field labels in frontend with Polylang Reply To: Translating form field labels in frontend with Polylang

  • I tried adding your code to themes functions.php:

    add_action('init', function () {
    	foreach (acf_get_field_groups() as $group) {
    		$fields = acf_get_fields($group['ID']);
    		if (is_array($fields) && count($fields)) {
    			foreach ($fields as &$field) {
    				pll_register_string('form_field_group'.$group['ID'].'_label_'.$field['name'], $field['label'], 'acf_form_fields');
    			}
    		}
    	}
    });
    
    add_filter('acf/prepare_field', function ($field) {
    	if (!is_admin()) {
    		$field['label'] = pll__($field['label']);
    	}
    	return $field;
    }, 10, 1);