acf-builder
acf-builder copied to clipboard
WPML Gutenberg blocks & Blocks reusable with ACF Builder
Hello,
I'm using ACF Builder and I'm looking for an easy way to translate my Gutenberg blocks created with it. How can I configure this when creating blocks with acf builder? At the moment it seems complex... Is there a solution to do what ACF allows when using its UI?
Exemple ... how said this block must be translate with WPML `<?php
namespace App; use StoutLogic\AcfBuilder\FieldsBuilder;
$promoicon = ['green' => 'Green'];
$promoblocks = new FieldsBuilder('promoblocks'); $promoblocks ->setLocation('block', '==', 'acf/promoblocks'); $promoblocks ->addText('heading', [ 'label' => 'Heading', 'required' => 1]) ->addText('sticktext', [ 'label' => 'Stick Text', 'required' => 0]) ->addSelect('promoicon', ['label' => 'Promo Icon','required' => 0, 'choices' => $promoicon, 'default_value' => [], 'allow_null' => 1, 'multiple' => 0, 'return_format' => 'value']);
return $promoblocks; `
Thanks
hi @mazero
you can make use of WPs localization function and write your code like this:
$promoblocks
->addText('heading', [ 'label' => __('Heading', 'your-textdomain'), 'required' => 1])
->addText('sticktext', [ 'label' => __('Stick Text', 'your-textdomain'), 'required' => 0])
->addSelect('promoicon', ['label' =>__('Promo Icon', 'your-textdomain'), 'required' => 0, 'choices' => $promoicon,
'default_value' => [], 'allow_null' => 1, 'multiple' => 0, 'return_format' => 'value']);
return $promoblocks;