StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
788 stars 61 forks source link

WPML Gutenberg blocks & Blocks reusable with ACF Builder #123

Open mazero opened 4 years ago

mazero commented 4 years ago

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

mortensassi commented 3 years ago

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;