Support

Account

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

  • If anyone is interested I’ve modified a file /wp-content/plugins/advanced-custom-fields-pro/admin/views/settings-export-generate.php

    By adding this:

    //textdomain and i18n for label
    $code = preg_replace('/\'label\' => \'(.*)\'/', '\'label\' => _x(\'$1\',\'ACF - '.$field_groups[0]['title'].'\',\''.$current_textdomain.'\')',$code);
    
    //textdomain and i18n for label
    $code = preg_replace('/\'instructions\' => \'(.*)\'/', '\'instructions\' => _x(\'$1\',\'ACF - '.$field_groups[0]['title'].'\',\''.$current_textdomain.'\')',$code);

    just before echo. There is only one thing I can’t figure out – as I genuinely hate regex – how to skip empty strings as this is also changed
    'instructions'=>'' to _x('','ACF','textdomain')

    This doesn’t work for choices in checkbox/select/radio etc and by looking at structure of the var_export it would be almost impossible to make “choice” translatable.

    So I am thinking that maybe a way out would be in label/instructions/choices adding lang:My label name, and later search and replace everything that starts with lang: and make it as __() or_x() depending on preferences. It would have to be striped in the frontend tho, or maybe even changed in frontend to __(). That way it could work even without export.

    What you think?