bobbingwide / field-block-for-acf-pro

Field block for ACF PRO
https://www.oik-plugins.com/oik-plugins/field-block-for-acf-pro/
GNU General Public License v2.0
3 stars 0 forks source link

Internationalize and localize acf-field-block #11

Open bobbingwide opened 1 year ago

bobbingwide commented 1 year ago

Requirements

The acf-field-block plugin should be enabled as a free plugin downloadable from wordpress.org. It should therefore be:

Solution

PHP

block.json

bobbingwide commented 1 year ago

The l10n solution needs to be modified to support ACF's PHP blocks which don't require NPM to build them. As with other block plugins the strings to be translated come from:

To generate the .pot file to obtain the strings from block.json we can run

wp i18n make-pot . languages/acf-field-block.pot

To translate the strings we need to run l10n.

It's not necessary to generate the .json files that are normally used during localization of the block since there is no block JavaScript. Were it necessary we'd need to run

wp i18n make-json languages --no-purge

We need to call load_plugin_textdomain() to load the language files prior to calling acf_add_local_field_group() and the block.json file needs the textdomain attribute set to acf-field-block.