MWDelaney / sage-acf-wp-blocks

Composer library for generating ACF Gutenberg blocks from templates. Intended for use with Roots/Sage (http://roots.io)
346 stars 66 forks source link

Translatable #55

Open jnaklaas opened 3 years ago

jnaklaas commented 3 years ago

Could we do something like this in order to make the block title translatable?

{{-- Title: ('My custom block') Description: ('This is my custom block!') --}}

tombroucke commented 3 years ago

If translation is a must, you could add a filter:

add_filter('sage/blocks/my-custom-block/register-data', function ($data) {
    $data['title'] = __('My custom block title', 'sage');
    $data['description'] = __('My custom block description', 'sage');
    return $data;
});

As an alternative, you can use the acf/register_block_type_args filter in the same way if you want to add translations in only one function.