Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internationalize and localize acf-field-block #11

Open
bobbingwide opened this issue Jul 11, 2023 · 1 comment
Open

Internationalize and localize acf-field-block #11

bobbingwide opened this issue Jul 11, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Jul 11, 2023

Requirements

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

  • internationalized so that its strings are translatable from US English to other languages
  • and localized - translated into UK English and the test locale bb_BB
  • and (eventually) tested in each of these languages

Solution

PHP

  • Use a text domain of acf-field-block
  • Localize using l10n
  • Deliver UK English language version
  • Test with the Color picker in UK English?

block.json

  • Use make-json?
@bobbingwide bobbingwide added the enhancement New feature or request label Jul 11, 2023
@bobbingwide bobbingwide self-assigned this Jul 11, 2023
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 11, 2023

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:

  • PHP files
  • block.json files
  • and potentially other JavaScript files

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.

  • But l10n.php needs to be modified to not run makeoik.
  • Function maybe_do_makeoik(), which currently checks for folders called node_modules and src can alternatively check for a folder called blocks.
  • The blocks folder is currently used in acf-field-block, acf-oik-blocks and oik-testimonials.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant