Support

Account

Home Forums General Issues Wrap labels and descriptions with __() in the PHP Export file Reply To: Wrap labels and descriptions with __() in the PHP Export file

  • Weee! I was about to crate post for this topic and now I fount it on To-do.. sweeet!

    Code that I’m using right now:

    // add the __() function to specific strings for translation in theme
    $html = preg_replace("/'title'(.*?)('.+?',)/", "'title'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'label'(.*?)('.+?',)/", "'label'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'instructions'(.*?)('.+?',)/", "'instructions'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'button_label'(.*?)('.+?',)/", "'button_label'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'placeholder'(.*?)('.+?',)/", "'placeholder'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'message'(.*?)('.+?',)/", "'message'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'prepend'(.*?)('.+?',)/", "'prepend'$1__($2 'acf_export'),", $html);
    $html = preg_replace("/'append'(.*?)('.+?',)/", "'append'$1__($2 'acf_export'),", $html);

    The ‘acf_export’ helps out to find and replace it with theme text domain.
    This helps out, but could make some improvements and find a way to add translation functions to choices.