Support

Account

Home Forums Feature Requests Adjustable Textdomains and Textdomains in PHP Export Reply To: Adjustable Textdomains and Textdomains in PHP Export

  • It’s an older question, but since I was looking for a solution myself, here is mine:

    
    $textdomain = 'textdomain';
    
    $code = preg_replace( '/\'label\' => (.{3,})\,/', '\'label\' => esc_html_x( $1, \'ACF ' . $field_group['title'] . ' Label\', \'' . $textdomain . '\' ),', $code );
    $code = preg_replace( '/\'instructions\' => (.{3,})\,/', '\'instructions\' => esc_html_x( $1, \'ACF ' . $field_group['title'] . ' Instructions\', \'' . $textdomain . '\' ),', $code );
    $code = preg_replace( '/\'append\' => (.{3,})\,/', '\'append\' => esc_html_x( $1, \'ACF ' . $field_group['title'] . ' Append\', \'' . $textdomain . '\' ),', $code );
    $code = preg_replace( '/\'prepend\' => (.{3,})\,/', '\'prepend\' => esc_html_x( $1, \'ACF ' . $field_group['title'] . ' Prepend\', \'' . $textdomain . '\' ),', $code );
    


    @kokers
    you can use (.{3,}) instead of (.*). Then only matches with 3 or more chars are evaluated.