Ok I created a new code:
// add the __() functions for theme translations (by BaLu.LT)
$ignore_keys = array(
'id',
'key',
'name',
'type',
'field',
'operator',
'value',
'allorany',
'formatting',
'position',
'layout',
'save_format',
'preview_size',
'library',
'param',
'toolbar',
'media_upload',
'date_format',
'display_format',
'return_format',
'taxonomy',
'field_type',
'default_value'
);
$ikeys = "";
foreach ( $ignore_keys as &$ikey ) $ikeys .= "(?<!\'" . $ikey . ")";
$regular_expression = "/((?<=" . $ikeys . "\' => )\'.+\'(?=,))/";
$html = preg_replace( $regular_expression, "__($1, 'acf_export')", $html );
Few things to mention:
No translation support for ‘default_value’ using it as default text (alternative: placeholder)
No translation support for choices with identically matched keys to any of $ignore_keys or if it’s an integer
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.
This is my first thought to solving this was:
To add checkbox option on tab field to stop tabs instead of creating one.
Second version:
New Layout field: Separator
Added image example
This could also help for styling field groups in general
Same thing… have to change any random field value to trigger hide.
I’m using ACF 4.2.2 and WP 3.6.1
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.